@cogniplay/logic-games 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -2
- package/board.d.ts +102 -0
- package/board.d.ts.map +1 -0
- package/board.js +201 -0
- package/board.js.map +1 -0
- package/clues.d.ts +16 -0
- package/clues.d.ts.map +1 -0
- package/clues.js +64 -0
- package/clues.js.map +1 -0
- package/digits/generated/digits.d.ts +10 -0
- package/digits/generated/digits.d.ts.map +1 -0
- package/digits/generated/digits.js +397 -0
- package/digits/generated/digits.js.map +1 -0
- package/digits.d.ts +7 -0
- package/digits.d.ts.map +1 -0
- package/digits.js +38 -0
- package/digits.js.map +1 -0
- package/fair-shares.d.ts +20 -0
- package/fair-shares.d.ts.map +1 -0
- package/fair-shares.js +164 -0
- package/fair-shares.js.map +1 -0
- package/fills.d.ts +31 -0
- package/fills.d.ts.map +1 -0
- package/fills.js +142 -0
- package/fills.js.map +1 -0
- package/geometry.d.ts +14 -0
- package/geometry.d.ts.map +1 -0
- package/geometry.js +55 -0
- package/geometry.js.map +1 -0
- package/index.d.ts +12 -0
- package/index.d.ts.map +1 -0
- package/index.js +9 -0
- package/index.js.map +1 -0
- package/line-counts.d.ts +25 -0
- package/line-counts.d.ts.map +1 -0
- package/line-counts.js +136 -0
- package/line-counts.js.map +1 -0
- package/marks.d.ts +17 -0
- package/marks.d.ts.map +1 -0
- package/marks.js +50 -0
- package/marks.js.map +1 -0
- package/outline.d.ts +31 -0
- package/outline.d.ts.map +1 -0
- package/outline.js +150 -0
- package/outline.js.map +1 -0
- package/package.json +21 -4
- package/positions.d.ts +7 -0
- package/positions.d.ts.map +1 -0
- package/positions.js +28 -0
- package/positions.js.map +1 -0
- package/regions.d.ts +20 -0
- package/regions.d.ts.map +1 -0
- package/regions.js +84 -0
- package/regions.js.map +1 -0
- package/solution.d.ts +15 -0
- package/solution.d.ts.map +1 -0
- package/solution.js +50 -0
- package/solution.js.map +1 -0
- package/src/board.ts +377 -0
- package/src/clues.ts +91 -0
- package/src/digits/OFL.txt +93 -0
- package/src/digits/README.md +5 -0
- package/src/digits/generated/digits.ts +404 -0
- package/src/digits.ts +58 -0
- package/src/fair-shares.ts +257 -0
- package/src/fills.ts +176 -0
- package/src/geometry.ts +66 -0
- package/src/index.ts +31 -0
- package/src/line-counts.ts +211 -0
- package/src/marks.ts +68 -0
- package/src/outline.ts +196 -0
- package/src/positions.ts +35 -0
- package/src/regions.ts +108 -0
- package/src/solution.ts +75 -0
- package/src/svg.ts +46 -0
- package/src/tray.ts +114 -0
- package/src/types.ts +106 -0
- package/svg.d.ts +7 -0
- package/svg.d.ts.map +1 -0
- package/svg.js +29 -0
- package/svg.js.map +1 -0
- package/tray.d.ts +32 -0
- package/tray.d.ts.map +1 -0
- package/tray.js +58 -0
- package/tray.js.map +1 -0
- package/types.d.ts +95 -0
- package/types.d.ts.map +1 -0
- package/types.js +2 -0
- package/types.js.map +1 -0
package/README.md
CHANGED
|
@@ -1,3 +1,173 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cogniplay/logic-games
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Draws logic-game boards as SVG. One drawing for every place a board appears: the content repository's render command and catalogue, the `/edu` views, and the printed sheet.
|
|
4
|
+
|
|
5
|
+
It is a library of pure functions with no runtime dependencies, no DOM and no React, so it runs the same in Node and in the browser. It draws any instance in the logic-games format from the instance's own data, and knows nothing about families, variants, kits or codes. It draws three games, told apart by the data's `$type`: Amoeba (`amoeba`, or no `$type`), Line Counts (`line-counts`) and Fair Shares (`fair-shares`). The designs are in `docs/superpowers/specs/2026-11-04-logic-games-renderer-design.md`, `docs/superpowers/specs/2026-11-10-line-counts-drawing-design.md` and `docs/superpowers/specs/2026-11-11-fair-shares-drawing-design.md`.
|
|
6
|
+
|
|
7
|
+
## Installing
|
|
8
|
+
|
|
9
|
+
The package is published on npm. Pin the exact version, so that a board drawn differently arrives by a commit of your own:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add --save-exact @cogniplay/logic-games
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The package holds the built JavaScript, its types, the source under `src/` and this README, so the API can be read in place.
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { type Instance, positions, renderBoard, renderSolution } from "@cogniplay/logic-games";
|
|
21
|
+
|
|
22
|
+
// An instance file, or an instance in a family file, keeps its board in `data`.
|
|
23
|
+
const instance: Instance = delivery.variants[0].instances[0].data;
|
|
24
|
+
|
|
25
|
+
// The start, as a complete SVG document in millimetres.
|
|
26
|
+
const start = renderBoard(instance);
|
|
27
|
+
|
|
28
|
+
// The board after the second move.
|
|
29
|
+
const afterTwo = renderBoard(instance, { position: 2 });
|
|
30
|
+
|
|
31
|
+
// Every position in order, left to right, as one SVG.
|
|
32
|
+
const whole = renderSolution(instance, { perRow: 4 });
|
|
33
|
+
|
|
34
|
+
// The positions themselves, for anything that isn't a drawing.
|
|
35
|
+
for (const { pieces, moved } of positions(instance)) {
|
|
36
|
+
// `moved` names the piece the last move placed; absent at the start.
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The input is the format's instance. For Amoeba: `geometry`, `board`, `blockers`, `pieces` (each with its `shape`, `origin` and `orientation`), `marks` and `solution`. Extra fields, such as `id`, `number` and `withdrawn`, are ignored, so an instance from a delivery file or an `/edu` response is valid input as it is.
|
|
41
|
+
|
|
42
|
+
| Function | Returns |
|
|
43
|
+
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
44
|
+
| `renderBoard(instance, options?)` | The board at one position, the start by default (`options.position`). An SVG document. |
|
|
45
|
+
| `renderSolution(instance, options?)` | Amoeba: every position, wrapping after `options.perRow` (default 4). Line Counts and Fair Shares: the solved board alone. An SVG document. |
|
|
46
|
+
| `positionCount(instance)` | How many positions `renderBoard` can draw, for any game. |
|
|
47
|
+
| `isLineCounts(instance)` | Whether the data is a Line Counts board. |
|
|
48
|
+
| `isFairShares(instance)` | Whether the data is a Fair Shares board. |
|
|
49
|
+
| `gridGapCells` | The room between two grids of a Fair Shares board, across and down, in cells: 1. |
|
|
50
|
+
| `clueBands(clues)` | The cells the clues take beside a Line Counts board: `left` and `top`, each 0 or 1. |
|
|
51
|
+
| `positions(instance)` | Amoeba only: the start, then one position per move, each with `moved` set. |
|
|
52
|
+
| `orientations(shape)` | The shape's distinct orientations, in the convention's order, each normalised. |
|
|
53
|
+
| `place(shape, placement)` | The cells a placement covers. |
|
|
54
|
+
| `normalise(cells)` | The cells shifted so their smallest x and y are 0, sorted by y then x. |
|
|
55
|
+
|
|
56
|
+
### Line Counts
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { type LineCountsInstance, positionCount, renderBoard, renderSolution } from "@cogniplay/logic-games";
|
|
60
|
+
|
|
61
|
+
const board: LineCountsInstance = delivery.variants[0].instances[0].data;
|
|
62
|
+
|
|
63
|
+
const start = renderBoard(board); // the board, its clues, and the pieces to place under it
|
|
64
|
+
const solved = renderSolution(board); // every piece placed; the same as position 1
|
|
65
|
+
positionCount(board); // 2: the start and the solved board. 1 for an illustration.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The data is `geometry`, `board`, `regions` (the small boards, each a list of cells), `clues` (each a `direction`, an `index`, a `kind` and a `value`), `pieces` and `solution`. A piece with an `origin` and an `orientation` starts on the board; one without, or with both null, is to place. The solution is one placement per piece to place, in any order.
|
|
69
|
+
|
|
70
|
+
- **Clues** sit outside the board: a row's on its left, a column's above it. When any row has a clue the drawing is one cell wider, and when any column has one it is one cell taller. A count of covered cells is a white number in a solid square; a count of empty cells is a dark number in an outlined square. A line with no clue shows nothing.
|
|
71
|
+
- **Thick lines** run where two regions meet, over the pieces.
|
|
72
|
+
- **The pieces to place** lie in a tray under the board, in the order of `pieces`, each in its least tall orientation. They wrap to a new row at `trayWidthMm`. They are always tiles, also with `pieceStyle: "ghost"`.
|
|
73
|
+
- **The solved board** has no tray. The pieces the solution placed have the heavy outline and the class `placed`; the ones that started on the board are plain.
|
|
74
|
+
|
|
75
|
+
### Fair Shares
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { type FairSharesInstance, positionCount, renderBoard, renderSolution } from "@cogniplay/logic-games";
|
|
79
|
+
|
|
80
|
+
const board: FairSharesInstance = delivery.variants[0].instances[0].data;
|
|
81
|
+
|
|
82
|
+
const start = renderBoard(board); // the pieces to share, and under them an empty grid for each share
|
|
83
|
+
const solved = renderSolution(board); // every share's pieces on its grid; the same as position 1
|
|
84
|
+
positionCount(board); // 2: the start and the solved board. 1 for an illustration.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The data is `geometry`, `board` (the cells of one grid), `shares` (how many grids), `leftOut` (how many pieces stay outside every share), `pieces` and `solution`. A piece with a `share`, an `origin` and an `orientation` starts on that share's grid; one without, or with all three null, is to share. The solution is one placement per piece to share, each with its `share`; a piece to share that it doesn't place is left out.
|
|
88
|
+
|
|
89
|
+
- **The grids** are `shares` copies of the board, a cell apart across and down, in rows of `gridsPerRow`. By default that is as near a square as there is: two side by side for two shares, two above one for three. A short last row is centred. The grids are alike: nothing marks which share is which.
|
|
90
|
+
- **The pieces to share** lie in a tray as Line Counts' pieces to place do, above the grids unless `trayPosition` is `below`. They have the class `to-share`.
|
|
91
|
+
- **The solved board** has each share's pieces on its grid. The pieces the solution placed have the heavy outline and the class `placed`; one that started on a grid is plain. A piece left out stays in the tray with the class `left-out`, and a dashed box, `left-out-box`, stands around it. The start draws no place for it.
|
|
92
|
+
- **Nothing shows a share's size:** no count of cells and no sum.
|
|
93
|
+
|
|
94
|
+
### Options
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
interface RenderOptions {
|
|
98
|
+
/** The side of a cell in millimetres. Default 16. */
|
|
99
|
+
cellSizeMm?: number;
|
|
100
|
+
/** Drawings for mark kinds, by kind. Overrides the standard ones. */
|
|
101
|
+
marks?: Record<string, MarkDrawer>;
|
|
102
|
+
/** A flat colour per piece id, such as the kit's. Greyscale fills without. */
|
|
103
|
+
pieceColours?: Record<string, string>;
|
|
104
|
+
/** `tile` (default), or `ghost` for the child's sheet, where the real piece covers the drawing. */
|
|
105
|
+
pieceStyle?: "tile" | "ghost";
|
|
106
|
+
/** Line Counts and Fair Shares: the tray's cell size as a share of the board's. Default 1. */
|
|
107
|
+
trayScale?: number;
|
|
108
|
+
/** Where the tray's row wraps, in millimetres. Default: the board's width with its clues, or the grids' width together. */
|
|
109
|
+
trayWidthMm?: number;
|
|
110
|
+
/** Where the tray lies. Default `below` for Line Counts, `above` for Fair Shares. */
|
|
111
|
+
trayPosition?: "above" | "below";
|
|
112
|
+
/** Fair Shares: how many grids lie side by side. Default: as near a square of grids as there is. */
|
|
113
|
+
gridsPerRow?: number;
|
|
114
|
+
/** Keep the tray's room at every position, so stepping through them moves nothing. Default false. */
|
|
115
|
+
keepTrayRoom?: boolean;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The standard mark kinds are `target` and `star`, exported as `standardMarks` and listed in `standardMarkKinds`. A kind with no drawing shows as a dashed placeholder, so a draft's new kind is visible rather than an error. To draw one, pass a `MarkDrawer`: a function from the cell's top-left and side in millimetres to an SVG fragment.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { type MarkDrawer, renderBoard } from "@cogniplay/logic-games";
|
|
123
|
+
|
|
124
|
+
const moon: MarkDrawer = ({ x, y, size }) => `<circle cx="${x + size / 2}" cy="${y + size / 2}" r="${size * 0.3}" fill="#000"/>`;
|
|
125
|
+
|
|
126
|
+
renderBoard(instance, { marks: { moon } });
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
A drawer must use no `id` attributes, no `<defs>` and no text, for the reasons under "The output".
|
|
130
|
+
|
|
131
|
+
### Orientations
|
|
132
|
+
|
|
133
|
+
The convention is cognipuzzle's, and the content repository's Python and the backend's C# implement the same:
|
|
134
|
+
|
|
135
|
+
- A piece's orientations are a list of distinct cell sets, each normalised: shifted so that its smallest x and its smallest y are both 0.
|
|
136
|
+
- First come the shape's quarter turns clockwise, starting with the shape itself, normalised. With `y` growing down, a quarter turn clockwise maps `(x, y)` to `(-y, x)`. A turn equal to an earlier entry is left out.
|
|
137
|
+
- Then come the quarter turns of the shape's mirror image, `(x, y)` to `(-x, y)`, in the same order, leaving out any already in the list.
|
|
138
|
+
- An orientation number is a position in that list, from 0. Orientation 0 is always the shape itself.
|
|
139
|
+
- A placement's cells are the chosen orientation's cells with the origin added to each.
|
|
140
|
+
|
|
141
|
+
The content repository's shared geometry fixture pins the order for every kit piece, and the tests here run it.
|
|
142
|
+
|
|
143
|
+
### What throws
|
|
144
|
+
|
|
145
|
+
- `renderBoard` and `renderSolution` on a geometry other than `square`.
|
|
146
|
+
- `renderBoard` on a position past the solution. A Line Counts or a Fair Shares board has position 0, and position 1 when its solution places anything.
|
|
147
|
+
- A Line Counts or a Fair Shares solution that places a piece the board doesn't have.
|
|
148
|
+
- A Fair Shares piece or placement on a share the board doesn't have, or a board with no share.
|
|
149
|
+
- `positions` and `place` on an orientation past the piece's list, or a move naming a piece the instance doesn't have. The message names the piece.
|
|
150
|
+
|
|
151
|
+
Nothing else is checked. The renderer draws what it is given; validating content is the content repository's validator's job.
|
|
152
|
+
|
|
153
|
+
## The output
|
|
154
|
+
|
|
155
|
+
- **Millimetres.** Cells are `cellSizeMm` wide, and the root `<svg>` carries `width` and `height` in `mm` with a matching `viewBox`, so one user unit is one millimetre. Placed in a PDF or printed as is, a board is true size; on screen, scale it as any SVG.
|
|
156
|
+
- **No text,** so nothing needs a font. A clue's number is a path: the outline of Roboto Regular's digits, the font the sheet embeds. See `src/digits/README.md` for its origin and licence.
|
|
157
|
+
- **No `id` attributes and no `<defs>`,** so many boards can be inlined into one page without their definitions colliding.
|
|
158
|
+
- **Readable in black and white.** Pieces are told apart by fill: greys, hatching and dots, each with a heavy outline. Blockers are dark. In a position after the start, the moved piece has a heavier outline and its previous placement is drawn as a dashed hint.
|
|
159
|
+
- **Classes for styling and tests:** `board`, `cell`, `board-outline`, `blockers`, `blocker`, `moved-from`, `pieces`, `piece` (with `moved`, and `data-piece`), `marks`, `mark` (with `data-kind`), and `position` in a solution. For Line Counts also: `clues`, `clue` (with `data-direction`, `data-index`, `data-kind` and `data-value`), `clue-square`, `clue-number`, `regions`, `region-line`, `tray`, and on a piece `to-place` in the tray and `placed` on the solved board. For Fair Shares: `shares`, `share` (with `data-share`, holding its own `board` and `pieces`), `tray`, `left-out-box` (with `data-piece`), and on a piece `to-share` or `left-out` in the tray and `placed` on the solved board.
|
|
160
|
+
|
|
161
|
+
## Releasing
|
|
162
|
+
|
|
163
|
+
A pull request that changes what the package holds (its source, this README, the fields of its manifest that npm gets, or its build config) raises `version` in `package.json`: a minor bump for anything that changes a drawing or the API, a patch for a fix that changes neither. The Pipeline's checks fail when a change keeps its version, on the pull request and again on `main` (`scripts/check-lib-versions.mjs`), and on `main` the Pipeline publishes every version npm doesn't have yet (`scripts/publish-libs.mjs`), signed in by npm's trusted publishing. A release of the renderer releases the sheet too, since the sheet's peer range is built from the renderer's version. The design is `docs/superpowers/specs/2026-11-23-publish-logic-games-design.md`.
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
pnpm --filter @cogniplay/logic-games test # vitest
|
|
169
|
+
pnpm --filter @cogniplay/logic-games typecheck
|
|
170
|
+
pnpm --filter @cogniplay/logic-games build # dist/, self-contained
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`test/fixtures/` holds copies of the content repository's valid examples, its kit list and its geometry fixture; its README says which commit they came from. `test/snapshots/` holds SVGs the tests compare against. Open them in a browser to see what the renderer draws; update them with `vitest run -u` when the look changes on purpose.
|
package/board.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type Fill } from "./fills.js";
|
|
2
|
+
import { type MarkDrawer } from "./marks.js";
|
|
3
|
+
import type { Cell, GameData, Instance, Position } from "./types.js";
|
|
4
|
+
export interface RenderOptions {
|
|
5
|
+
/** The side of a cell in millimetres. Default 16. */
|
|
6
|
+
cellSizeMm?: number;
|
|
7
|
+
/** Drawings for mark kinds, by kind. Overrides the standard ones. */
|
|
8
|
+
marks?: Record<string, MarkDrawer>;
|
|
9
|
+
/**
|
|
10
|
+
* A flat colour per piece id, such as the kit's. A piece without one gets
|
|
11
|
+
* the greyscale fills, which print well.
|
|
12
|
+
*/
|
|
13
|
+
pieceColours?: Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* How pieces are drawn. A `tile` is filled and heavily outlined, as a piece
|
|
16
|
+
* on the board looks. A `ghost` is a thin outline with light stripes, for
|
|
17
|
+
* the child's sheet, where the real piece covers the drawing: it marks the
|
|
18
|
+
* place without competing with the blockers. Default `tile`.
|
|
19
|
+
*/
|
|
20
|
+
pieceStyle?: "tile" | "ghost";
|
|
21
|
+
/**
|
|
22
|
+
* The cell size of the tray, where a Line Counts board's pieces to place
|
|
23
|
+
* and a Fair Shares board's pieces to share are drawn, as a share of the
|
|
24
|
+
* board's. Default 1: the board's scale.
|
|
25
|
+
*/
|
|
26
|
+
trayScale?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Where the tray's row of pieces wraps, in millimetres. Default: the
|
|
29
|
+
* board's width with its clues, or the grids' width together.
|
|
30
|
+
*/
|
|
31
|
+
trayWidthMm?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Where the tray lies: above the board or under it. Default `below` for
|
|
34
|
+
* Line Counts and `above` for Fair Shares, whose pieces are what the child
|
|
35
|
+
* reads first.
|
|
36
|
+
*/
|
|
37
|
+
trayPosition?: "above" | "below";
|
|
38
|
+
/**
|
|
39
|
+
* How many of a Fair Shares board's grids lie side by side before the next
|
|
40
|
+
* row starts. Default: as near a square of grids as there is, so two for
|
|
41
|
+
* two shares, and two above one for three.
|
|
42
|
+
*/
|
|
43
|
+
gridsPerRow?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Keeps the tray's room at every position: the drawing is as large as at
|
|
46
|
+
* the start, and the board and any piece still to place stay where they
|
|
47
|
+
* were, so a view that steps through the positions doesn't move. On a Fair
|
|
48
|
+
* Shares board whose solution leaves a piece out, the start then has the
|
|
49
|
+
* room of the box drawn around that piece. Default false: the drawing is
|
|
50
|
+
* as large as what it shows.
|
|
51
|
+
*/
|
|
52
|
+
keepTrayRoom?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** SVG content without a root, and its size in millimetres. */
|
|
55
|
+
export interface Drawing {
|
|
56
|
+
body: string;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
/** The cells a drawing must hold: the board, and anything placed on or off it. */
|
|
61
|
+
export interface Bounds {
|
|
62
|
+
minX: number;
|
|
63
|
+
minY: number;
|
|
64
|
+
columns: number;
|
|
65
|
+
rows: number;
|
|
66
|
+
}
|
|
67
|
+
/** Millimetres around the board, so the heavy outline isn't clipped. */
|
|
68
|
+
export declare const padding = 1;
|
|
69
|
+
export declare const defaultCellSize = 16;
|
|
70
|
+
/** A piece's fill and outline, by the options and its order. */
|
|
71
|
+
export interface Look {
|
|
72
|
+
fill: Fill;
|
|
73
|
+
outline: Record<string, string | number>;
|
|
74
|
+
}
|
|
75
|
+
export declare function lookOf(pieceId: string, index: number, options: RenderOptions): Look;
|
|
76
|
+
export declare function requireSquare(instance: {
|
|
77
|
+
geometry: string;
|
|
78
|
+
}): void;
|
|
79
|
+
/**
|
|
80
|
+
* The bounds of the board together with every piece and mark in the given
|
|
81
|
+
* positions, so nothing placed off the board is clipped away silently. For a
|
|
82
|
+
* valid instance that is the board alone.
|
|
83
|
+
*/
|
|
84
|
+
export declare function bounds(instance: Instance, included: Position[]): Bounds;
|
|
85
|
+
/**
|
|
86
|
+
* One position's board as SVG content, without a root. `previous` is the
|
|
87
|
+
* position before it, for the moved-from hint. The bounds default to the
|
|
88
|
+
* board and this position's pieces.
|
|
89
|
+
*/
|
|
90
|
+
export declare function drawPosition(instance: Instance, position: Position, previous: Position | undefined, options?: RenderOptions, within?: Bounds): Drawing;
|
|
91
|
+
/** The board's cells and its heavy outline, as a group. */
|
|
92
|
+
export declare function drawCells(cells: readonly Cell[], toMm: (cell: Cell) => [number, number], size: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* One piece as a tile over the cells it covers: its fill, its pattern and its
|
|
95
|
+
* outline, which is the heavier one when `heavy`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function drawTile(pieceId: string, cells: readonly Cell[], { fill, outline }: Look, classes: string, heavy: boolean, toMm: (cell: Cell) => [number, number], size: number): string;
|
|
98
|
+
/** The board at one position, the start by default, as a complete SVG document. */
|
|
99
|
+
export declare function renderBoard(instance: GameData, options?: RenderOptions & {
|
|
100
|
+
position?: number;
|
|
101
|
+
}): string;
|
|
102
|
+
//# sourceMappingURL=board.d.ts.map
|
package/board.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board.d.ts","sourceRoot":"","sources":["src/board.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,KAAK,UAAU,EAA8B,MAAM,YAAY,CAAC;AAIzE,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACn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AE,MAAqC,GAC5C,OAAO,CA+ET;AAiCD,2DAA2D;AAC3D,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,IAAI,EAAE,MAAM,GACX,MAAM,CAwBR;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,IAAI,EAAE,MAAM,GACX,MAAM,CAUR;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,aAAa,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,MAAM,CAoBR"}
|
package/board.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { isFairShares, renderFairShares } from "./fair-shares.js";
|
|
2
|
+
import { flatFill, ghostFill, ghostGrey, pieceFill, } from "./fills.js";
|
|
3
|
+
import { place } from "./geometry.js";
|
|
4
|
+
import { isLineCounts, renderLineCounts } from "./line-counts.js";
|
|
5
|
+
import { placeholder, standardMarks } from "./marks.js";
|
|
6
|
+
import { insetLoops, loopsPath } from "./outline.js";
|
|
7
|
+
import { positions } from "./positions.js";
|
|
8
|
+
import { element, root } from "./svg.js";
|
|
9
|
+
/** Millimetres around the board, so the heavy outline isn't clipped. */
|
|
10
|
+
export const padding = 1;
|
|
11
|
+
export const defaultCellSize = 16;
|
|
12
|
+
const gridStroke = { stroke: "#c4c4c4", "stroke-width": 0.2 };
|
|
13
|
+
const heavyStroke = {
|
|
14
|
+
stroke: "#000",
|
|
15
|
+
"stroke-width": 0.8,
|
|
16
|
+
"stroke-linejoin": "round",
|
|
17
|
+
fill: "none",
|
|
18
|
+
};
|
|
19
|
+
const movedStroke = { ...heavyStroke, "stroke-width": 1.4 };
|
|
20
|
+
const ghostStroke = (colour) => ({
|
|
21
|
+
stroke: colour,
|
|
22
|
+
"stroke-width": 0.4,
|
|
23
|
+
"stroke-linejoin": "round",
|
|
24
|
+
fill: "none",
|
|
25
|
+
});
|
|
26
|
+
export function lookOf(pieceId, index, options) {
|
|
27
|
+
const colour = options.pieceColours?.[pieceId];
|
|
28
|
+
if (options.pieceStyle === "ghost") {
|
|
29
|
+
return {
|
|
30
|
+
fill: ghostFill(colour),
|
|
31
|
+
outline: ghostStroke(colour ?? ghostGrey),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
fill: colour === undefined ? pieceFill(index) : flatFill(colour),
|
|
36
|
+
outline: heavyStroke,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const movedFromStroke = {
|
|
40
|
+
stroke: "#777",
|
|
41
|
+
"stroke-width": 0.5,
|
|
42
|
+
"stroke-dasharray": "1.5 1",
|
|
43
|
+
"stroke-linejoin": "round",
|
|
44
|
+
fill: "none",
|
|
45
|
+
};
|
|
46
|
+
const blockerStyle = { fill: "#8c8c8c", stroke: "#666", "stroke-width": 0.3 };
|
|
47
|
+
/** Pieces and blockers are tiles: a little smaller than their cells, with rounded corners, so neighbours show a seam. */
|
|
48
|
+
const insetOf = (size) => size * 0.04;
|
|
49
|
+
const radiusOf = (size) => size * 0.06;
|
|
50
|
+
export function requireSquare(instance) {
|
|
51
|
+
if (instance.geometry !== "square") {
|
|
52
|
+
throw new Error(`Only square geometry is drawn, not "${instance.geometry}"`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The bounds of the board together with every piece and mark in the given
|
|
57
|
+
* positions, so nothing placed off the board is clipped away silently. For a
|
|
58
|
+
* valid instance that is the board alone.
|
|
59
|
+
*/
|
|
60
|
+
export function bounds(instance, included) {
|
|
61
|
+
if (instance.board.length === 0) {
|
|
62
|
+
throw new Error("The board has no cells");
|
|
63
|
+
}
|
|
64
|
+
const cells = [
|
|
65
|
+
...instance.board,
|
|
66
|
+
...(instance.marks ?? []).map((mark) => mark.cell),
|
|
67
|
+
...included.flatMap((position) => position.pieces.flatMap((piece) => place(piece.shape, piece))),
|
|
68
|
+
];
|
|
69
|
+
const xs = cells.map(([x]) => x);
|
|
70
|
+
const ys = cells.map(([, y]) => y);
|
|
71
|
+
const minX = Math.min(...xs);
|
|
72
|
+
const minY = Math.min(...ys);
|
|
73
|
+
return {
|
|
74
|
+
minX,
|
|
75
|
+
minY,
|
|
76
|
+
columns: Math.max(...xs) - minX + 1,
|
|
77
|
+
rows: Math.max(...ys) - minY + 1,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* One position's board as SVG content, without a root. `previous` is the
|
|
82
|
+
* position before it, for the moved-from hint. The bounds default to the
|
|
83
|
+
* board and this position's pieces.
|
|
84
|
+
*/
|
|
85
|
+
export function drawPosition(instance, position, previous, options = {}, within = bounds(instance, [position])) {
|
|
86
|
+
requireSquare(instance);
|
|
87
|
+
const size = options.cellSizeMm ?? defaultCellSize;
|
|
88
|
+
const { minX, minY, columns, rows } = within;
|
|
89
|
+
const toMm = ([x, y]) => [
|
|
90
|
+
padding + (x - minX) * size,
|
|
91
|
+
padding + (y - minY) * size,
|
|
92
|
+
];
|
|
93
|
+
const board = drawCells(instance.board, toMm, size);
|
|
94
|
+
const inset = insetOf(size);
|
|
95
|
+
const blockers = element("g", { class: "blockers" }, (instance.blockers ?? [])
|
|
96
|
+
.map((cell) => {
|
|
97
|
+
const [x, y] = toMm(cell);
|
|
98
|
+
return element("rect", {
|
|
99
|
+
class: "blocker",
|
|
100
|
+
x: x + inset,
|
|
101
|
+
y: y + inset,
|
|
102
|
+
width: size - 2 * inset,
|
|
103
|
+
height: size - 2 * inset,
|
|
104
|
+
rx: radiusOf(size),
|
|
105
|
+
...blockerStyle,
|
|
106
|
+
});
|
|
107
|
+
})
|
|
108
|
+
.join(""));
|
|
109
|
+
const movedFrom = (() => {
|
|
110
|
+
if (position.moved === undefined || previous === undefined)
|
|
111
|
+
return "";
|
|
112
|
+
const before = previous.pieces.find((p) => p.pieceId === position.moved);
|
|
113
|
+
if (before === undefined)
|
|
114
|
+
return "";
|
|
115
|
+
return element("path", {
|
|
116
|
+
class: "moved-from",
|
|
117
|
+
d: tilePath(place(before.shape, before), toMm, size),
|
|
118
|
+
...movedFromStroke,
|
|
119
|
+
});
|
|
120
|
+
})();
|
|
121
|
+
const pieces = element("g", { class: "pieces" }, position.pieces
|
|
122
|
+
.map((piece, index) => drawPiece(piece, lookOf(piece.pieceId, index, options), position.moved, toMm, size))
|
|
123
|
+
.join(""));
|
|
124
|
+
const drawers = { ...standardMarks, ...options.marks };
|
|
125
|
+
const marks = element("g", { class: "marks" }, (instance.marks ?? [])
|
|
126
|
+
.map((mark) => {
|
|
127
|
+
const [x, y] = toMm(mark.cell);
|
|
128
|
+
const draw = drawers[mark.kind] ?? placeholder;
|
|
129
|
+
return element("g", { class: "mark", "data-kind": mark.kind }, draw({ x, y, size }));
|
|
130
|
+
})
|
|
131
|
+
.join(""));
|
|
132
|
+
return {
|
|
133
|
+
body: board + blockers + movedFrom + pieces + marks,
|
|
134
|
+
width: padding * 2 + columns * size,
|
|
135
|
+
height: padding * 2 + rows * size,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** The tile a set of cells makes: its outline, inset and rounded, as one path. */
|
|
139
|
+
function tilePath(cells, toMm, size) {
|
|
140
|
+
return loopsPath(insetLoops(cells, toMm, size, insetOf(size)), radiusOf(size));
|
|
141
|
+
}
|
|
142
|
+
function drawPiece(piece, look, moved, toMm, size) {
|
|
143
|
+
const isMoved = piece.pieceId === moved;
|
|
144
|
+
return drawTile(piece.pieceId, place(piece.shape, piece), look, isMoved ? "piece moved" : "piece", isMoved, toMm, size);
|
|
145
|
+
}
|
|
146
|
+
/** The board's cells and its heavy outline, as a group. */
|
|
147
|
+
export function drawCells(cells, toMm, size) {
|
|
148
|
+
return element("g", { class: "board" }, cells
|
|
149
|
+
.map((cell) => {
|
|
150
|
+
const [x, y] = toMm(cell);
|
|
151
|
+
return element("rect", {
|
|
152
|
+
x,
|
|
153
|
+
y,
|
|
154
|
+
width: size,
|
|
155
|
+
height: size,
|
|
156
|
+
class: "cell",
|
|
157
|
+
fill: "#fff",
|
|
158
|
+
...gridStroke,
|
|
159
|
+
});
|
|
160
|
+
})
|
|
161
|
+
.join("") +
|
|
162
|
+
element("path", {
|
|
163
|
+
class: "board-outline",
|
|
164
|
+
d: loopsPath(insetLoops(cells, toMm, size, 0), radiusOf(size)),
|
|
165
|
+
...heavyStroke,
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* One piece as a tile over the cells it covers: its fill, its pattern and its
|
|
170
|
+
* outline, which is the heavier one when `heavy`.
|
|
171
|
+
*/
|
|
172
|
+
export function drawTile(pieceId, cells, { fill, outline }, classes, heavy, toMm, size) {
|
|
173
|
+
const loops = insetLoops(cells, toMm, size, insetOf(size));
|
|
174
|
+
const d = loopsPath(loops, radiusOf(size));
|
|
175
|
+
return element("g", { class: classes, "data-piece": pieceId }, element("path", { class: "piece-fill", d, fill: fill.colour }) +
|
|
176
|
+
fill.pattern({ cells: cells.map(toMm), size, loops }) +
|
|
177
|
+
element("path", { d, ...(heavy ? movedStroke : outline) }));
|
|
178
|
+
}
|
|
179
|
+
/** The board at one position, the start by default, as a complete SVG document. */
|
|
180
|
+
export function renderBoard(instance, options = {}) {
|
|
181
|
+
if (isLineCounts(instance))
|
|
182
|
+
return renderLineCounts(instance, options);
|
|
183
|
+
if (isFairShares(instance))
|
|
184
|
+
return renderFairShares(instance, options);
|
|
185
|
+
requireSquare(instance);
|
|
186
|
+
const index = options.position ?? 0;
|
|
187
|
+
const count = (instance.solution ?? []).length + 1;
|
|
188
|
+
if (!Number.isInteger(index) || index < 0 || index >= count) {
|
|
189
|
+
throw new RangeError(`No position ${index}; there are ${count}, numbered 0 to ${count - 1}`);
|
|
190
|
+
}
|
|
191
|
+
// Replay only up to the position asked for, so a bad later move doesn't
|
|
192
|
+
// stop earlier positions from drawing.
|
|
193
|
+
const all = positions({
|
|
194
|
+
...instance,
|
|
195
|
+
solution: (instance.solution ?? []).slice(0, index),
|
|
196
|
+
});
|
|
197
|
+
const position = all[index];
|
|
198
|
+
const drawing = drawPosition(instance, position, all[index - 1], options);
|
|
199
|
+
return root(drawing.width, drawing.height, drawing.body);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=board.js.map
|
package/board.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board.js","sourceRoot":"","sources":["src/board.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAEL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAmB,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAqEzC,wEAAwE;AACxE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AAEzB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,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,CAClB,eAAe,KAAK,eAAe,KAAK,mBAAmB,KAAK,GAAG,CAAC,EAAE,CACvE,CAAC;IACJ,CAAC;IACD,wEAAwE;IACxE,uCAAuC;IACvC,MAAM,GAAG,GAAG,SAAS,CAAC;QACpB,GAAG,QAAQ;QACX,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;KACpD,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAa,CAAC;IACxC,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC"}
|
package/clues.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Cell, Clue } from "./types.js";
|
|
2
|
+
/** The bands the clues need beside the board, in cells: one on the left for rows' clues, one on top for columns'. */
|
|
3
|
+
export declare function clueBands(clues: readonly Clue[]): {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
};
|
|
7
|
+
/** The cell of the band a clue sits in: left of its row, above its column. */
|
|
8
|
+
export declare function clueCell(clue: Clue, minX: number, minY: number): Cell;
|
|
9
|
+
/**
|
|
10
|
+
* The clues as a group; empty when there are none. A count of covered cells
|
|
11
|
+
* is a white number in a solid square; a count of empty cells is a dark
|
|
12
|
+
* number in an outlined one. The square is smaller than a cell and stands off
|
|
13
|
+
* the board, so it reads as neither a cell nor a blocker.
|
|
14
|
+
*/
|
|
15
|
+
export declare function drawClues(clues: readonly Clue[], minX: number, minY: number, toMm: (cell: Cell) => [number, number], size: number): string;
|
|
16
|
+
//# sourceMappingURL=clues.d.ts.map
|
package/clues.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clues.d.ts","sourceRoot":"","sources":["src/clues.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAW7C,qHAAqH;AACrH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAKA;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAIrE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,IAAI,EAAE,MAAM,GACX,MAAM,CA+CR"}
|
package/clues.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { numberPath } from "./digits.js";
|
|
2
|
+
import { element } from "./svg.js";
|
|
3
|
+
/** The clue's square, the number's height and its widest, as shares of a cell. */
|
|
4
|
+
const square = 0.62;
|
|
5
|
+
const corner = 0.1;
|
|
6
|
+
const outline = 0.05;
|
|
7
|
+
const digitHeight = 0.36;
|
|
8
|
+
const digitWidth = 0.44;
|
|
9
|
+
const ink = "#222";
|
|
10
|
+
/** The bands the clues need beside the board, in cells: one on the left for rows' clues, one on top for columns'. */
|
|
11
|
+
export function clueBands(clues) {
|
|
12
|
+
return {
|
|
13
|
+
left: clues.some((clue) => clue.direction === "row") ? 1 : 0,
|
|
14
|
+
top: clues.some((clue) => clue.direction === "column") ? 1 : 0,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** The cell of the band a clue sits in: left of its row, above its column. */
|
|
18
|
+
export function clueCell(clue, minX, minY) {
|
|
19
|
+
return clue.direction === "row"
|
|
20
|
+
? [minX - 1, clue.index]
|
|
21
|
+
: [clue.index, minY - 1];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The clues as a group; empty when there are none. A count of covered cells
|
|
25
|
+
* is a white number in a solid square; a count of empty cells is a dark
|
|
26
|
+
* number in an outlined one. The square is smaller than a cell and stands off
|
|
27
|
+
* the board, so it reads as neither a cell nor a blocker.
|
|
28
|
+
*/
|
|
29
|
+
export function drawClues(clues, minX, minY, toMm, size) {
|
|
30
|
+
if (clues.length === 0)
|
|
31
|
+
return "";
|
|
32
|
+
const side = size * square;
|
|
33
|
+
const margin = (size - side) / 2;
|
|
34
|
+
return element("g", { class: "clues" }, clues
|
|
35
|
+
.map((clue) => {
|
|
36
|
+
const [x, y] = toMm(clueCell(clue, minX, minY));
|
|
37
|
+
const covered = clue.kind === "covered";
|
|
38
|
+
// The outline is drawn inside the square, so both kinds are one size.
|
|
39
|
+
const stroke = covered ? 0 : size * outline;
|
|
40
|
+
return element("g", {
|
|
41
|
+
class: "clue",
|
|
42
|
+
"data-direction": clue.direction,
|
|
43
|
+
"data-index": clue.index,
|
|
44
|
+
"data-kind": clue.kind,
|
|
45
|
+
"data-value": clue.value,
|
|
46
|
+
}, element("rect", {
|
|
47
|
+
class: "clue-square",
|
|
48
|
+
x: x + margin + stroke / 2,
|
|
49
|
+
y: y + margin + stroke / 2,
|
|
50
|
+
width: side - stroke,
|
|
51
|
+
height: side - stroke,
|
|
52
|
+
rx: size * corner,
|
|
53
|
+
fill: covered ? ink : "#fff",
|
|
54
|
+
...(covered ? {} : { stroke: ink, "stroke-width": stroke }),
|
|
55
|
+
}) +
|
|
56
|
+
element("path", {
|
|
57
|
+
class: "clue-number",
|
|
58
|
+
d: numberPath(clue.value, x + size / 2, y + size / 2, size * digitHeight, size * digitWidth),
|
|
59
|
+
fill: covered ? "#fff" : ink,
|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G,CAAC,CAAC,CAAC,MAAM;YAC5B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;SAC5D,CAAC;YACA,OAAO,CAAC,MAAM,EAAE;gBACd,KAAK,EAAE,aAAa;gBACpB,CAAC,EAAE,UAAU,CACX,IAAI,CAAC,KAAK,EACV,CAAC,GAAG,IAAI,GAAG,CAAC,EACZ,CAAC,GAAG,IAAI,GAAG,CAAC,EACZ,IAAI,GAAG,WAAW,EAClB,IAAI,GAAG,UAAU,CAClB;gBACD,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG;aAC7B,CAAC,CACL,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A path command and its coordinates, in font units, with y growing down from the top of a capital. */
|
|
2
|
+
export type GlyphCommand = [letter: string, ...coordinates: number[]];
|
|
3
|
+
/** The height of a capital, and of a digit, in font units. */
|
|
4
|
+
export declare const capHeight = 1456;
|
|
5
|
+
/** The digits 0 to 9: how far each advances, and its outline. */
|
|
6
|
+
export declare const digitGlyphs: readonly {
|
|
7
|
+
advance: number;
|
|
8
|
+
commands: readonly GlyphCommand[];
|
|
9
|
+
}[];
|
|
10
|
+
//# sourceMappingURL=digits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digits.d.ts","sourceRoot":"","sources":["../../src/digits/generated/digits.ts"],"names":[],"mappings":"AAGA,wGAAwG;AACxG,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAEtE,8DAA8D;AAC9D,eAAO,MAAM,SAAS,OAAO,CAAC;AAE9B,iEAAiE;AACjE,eAAO,MAAM,WAAW,EAAE,SAAS;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;CACnC,EAsYA,CAAC"}
|