Skip to content

Commit 7b48995

Browse files
committed
Added half renders and randomized hex field
1 parent 4497296 commit 7b48995

File tree

7 files changed

+247
-21
lines changed

7 files changed

+247
-21
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
@abstractplay:registry=https://npm.pkg.github.com/
2+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.6.1] - 2025-01-13
9+
10+
### Added
11+
12+
- Added support for half rendering of `hex-of-*` boards.
13+
- Added the randomized modular hex field option.
14+
815
## [1.6.0] - 2024-11-13
916

1017
### Added

package-lock.json

Lines changed: 45 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "abstractplay-designer",
33
"private": true,
4-
"version": "1.6.0",
4+
"version": "1.6.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
@@ -29,7 +29,8 @@
2929
"vite": "^4.4.5"
3030
},
3131
"dependencies": {
32-
"@abstractplay/renderer": "^1.0.0-ci-11827297972.0",
32+
"@abstractplay/renderer": "^1.0.0-ci-12737305773.0",
33+
"honeycomb-grid": "^4.1.5",
3334
"nanoid": "^4.0.2",
3435
"peerjs": "^1.4.7",
3536
"rfdc": "^1.3.0",

src/components/Board.svelte

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import type { IRenderOptions } from "@abstractplay/renderer";
1010
import { onMount } from "svelte";
1111
import ColorPicker from "svelte-awesome-color-picker";
12+
import { generateField as genField } from "@/lib/modular";
1213
1314
const boardTypes = new Map<SupportedBoards, string>([
1415
[
@@ -128,14 +129,19 @@
128129
let whichWidth: "abs" | "minmax" | undefined;
129130
let canBlock = false;
130131
let canAlternate = false;
132+
let canHalf = false;
131133
let symmetryLocked = true;
132134
let invertOrientation = false;
133135
let canInvertOrientation = false;
134136
let startDiamonds = false;
135137
let selectedOptions: ValidOption[] = [];
138+
let selectedHalf: "full"|"top"|"bottom" = "full";
139+
let numModules = 7;
136140
const initVars = () => {
137141
canBlock = false;
138142
canAlternate = false;
143+
canHalf = false;
144+
selectedHalf = "full";
139145
if ($state.board.style === undefined) {
140146
whichWidth = undefined;
141147
} else if (
@@ -185,6 +191,7 @@
185191
if ($state.board.style.startsWith("hex-of")) {
186192
canBlock = true;
187193
canAlternate = true;
194+
canHalf = true;
188195
}
189196
} else {
190197
// go board here
@@ -202,6 +209,16 @@
202209
$state = $state;
203210
}
204211
212+
$: if (selectedHalf !== undefined) {
213+
if (selectedHalf === "full") {
214+
delete $state.board.half;
215+
} else {
216+
$state.board.alternatingSymmetry = false;
217+
$state.board.half = selectedHalf;
218+
}
219+
$state = $state;
220+
}
221+
205222
const handleInvertClick = () => {
206223
if ($state.board.style === "cairo-collinear") {
207224
if (invertOrientation) {
@@ -361,6 +378,11 @@
361378
return false;
362379
};
363380
381+
const generateField = () => {
382+
$state.board = genField(numModules) as (BoardBasic & { style: SupportedBoards | "modular-hex"; });
383+
$state = $state;
384+
}
385+
364386
let previewDiv: HTMLDivElement;
365387
onMount(() => {
366388
const updatePreview = (state: RenderRepModified) => {
@@ -544,6 +566,22 @@
544566
</label>
545567
</div>
546568
{/if}
569+
{#if canHalf}
570+
<div class="control">
571+
<label class="radio">
572+
<input type="radio" name="half" value="full" bind:group="{selectedHalf}" />
573+
Full
574+
</label>
575+
<label class="radio">
576+
<input type="radio" name="half" value="top" bind:group="{selectedHalf}" />
577+
Top half
578+
</label>
579+
<label class="radio">
580+
<input type="radio" name="half" value="bottom" bind:group="{selectedHalf}" />
581+
Bottom half
582+
</label>
583+
</div>
584+
{/if}
547585
{#if canInvertOrientation}
548586
<div class="control">
549587
<label class="checkbox">
@@ -606,6 +644,19 @@
606644
>
607645
{/if}
608646
<hr />
647+
<div class="content">
648+
<p>You can generate a randomized hex field composed of modules (hexhex 2s) arranged to always touch another at two points. Select the number of modules and then the `Generate field` button.</p>
649+
</div>
650+
<div class="field padTop">
651+
<label class="label" for="numModules">Number of modules</label>
652+
<div class="control">
653+
<input class="input" name="numModules" type="number" min="1" max="30" bind:value="{numModules}" />
654+
</div>
655+
<div class="control">
656+
<button class="button apButton" on:click="{generateField}">Generate field</button>
657+
</div>
658+
</div>
659+
<hr />
609660
<div class="content">
610661
<p>
611662
The renderer supports a number of other options that might be

0 commit comments

Comments
 (0)