@clockgrove/assetgrove-tiles 0.0.0-stage → 0.3.2
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/LICENSE +21 -0
- package/README.md +260 -2
- package/dist/animation.d.ts +8 -0
- package/dist/animation.js +46 -0
- package/dist/corner16.d.ts +55 -0
- package/dist/corner16.js +122 -0
- package/dist/extension.d.ts +3 -0
- package/dist/extension.js +10 -0
- package/dist/imported.d.ts +7 -0
- package/dist/imported.js +171 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/kind.d.ts +38 -0
- package/dist/kind.js +320 -0
- package/dist/labels.d.ts +25 -0
- package/dist/labels.js +67 -0
- package/dist/objects.d.ts +34 -0
- package/dist/objects.js +192 -0
- package/dist/sheet.d.ts +123 -0
- package/dist/sheet.js +279 -0
- package/package.json +55 -3
- package/skills/assetgrove-tiles/SKILL.md +144 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clockgrove
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,261 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @clockgrove/assetgrove-tiles
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The tiles pack for Assetgrove: tile sheets as assets. A corner-16 terrain tile set between two terrains, made as one atlas image and checked for its grid and its seams; a generated sheet of object tiles held to its grid and the palette; and a bought or hand-drawn sheet in a published autotile layout (corner-16, blob-47, side-16, corner-16-2x2) imported by cell with its origin on record and its cells labelled (kind, walkable, draw order) from a model's proposal a person confirms.
|
|
4
|
+
|
|
5
|
+
## Extension API
|
|
6
|
+
|
|
7
|
+
The package declares `"assetgrove": { "api": 3 }` and a peer range on `@clockgrove/assetgrove`. It declares, as extension `tiles`, the kind `tiles:terrain` with its operations `tiles:atlas` and `tiles:seams` and its three checks; the kind `tiles:objects` with its operation `tiles:objects` and its checks `tiles:grid`, `tiles:palette` and `tiles:in-cell`; and the kind `tiles:sheet`, which is imported and has the checks `tiles:grid` and `tiles:animation`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Install it beside core and list it in the developer settings:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{ "extensions": ["@clockgrove/assetgrove-tiles"] }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## The `tiles:terrain` kind
|
|
18
|
+
|
|
19
|
+
A set is one atlas asset: an image whose `output.fields` are `{ layout, grid, terrains, autotile }`, with `layout` `corner-16` and `autotile` its table (see [Autotile layouts](#autotile-layouts)). The spec names the two terrains as `fields.terrains`, `lower` and `upper`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"kind": "tiles:terrain",
|
|
24
|
+
"assetId": "grass-dirt",
|
|
25
|
+
"fields": { "terrains": { "lower": "dirt", "upper": "grass" } }
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The target profile carries a `kinds["tiles:terrain"]` block:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"kinds": {
|
|
34
|
+
"tiles:terrain": {
|
|
35
|
+
"tileSize": 16,
|
|
36
|
+
"layout": { "media": "assets/tiles/{{spec.assetId}}.{{output.extension}}" }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- `tileSize`: whole pixels, the side of one square tile. The grid is 4 × 4 cells of `tileSize` with no margin or spacing, so the sheet is `4 * tileSize` square.
|
|
43
|
+
- `layout`: optional, as for any kind (`kinds.<kind>.layout`).
|
|
44
|
+
|
|
45
|
+
A profile without the block, or a spec without both terrains, is refused at plan: exit 2 `invalid_input`.
|
|
46
|
+
|
|
47
|
+
## The `tiles:sheet` kind: a bought or hand-drawn sheet
|
|
48
|
+
|
|
49
|
+
A sheet someone bought or drew is imported, not generated: `assetgrove import --spec <spec.json>` takes it in by cell, with its bytes as given (no background removal, no repacking, no re-encoding), and stages it as candidate `c1` of a run that `pick` takes. It makes no model call and spends nothing, unless `--propose-labels` asks a model for [cell labels](#cell-labels).
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"kind": "tiles:sheet",
|
|
54
|
+
"assetId": "meadow",
|
|
55
|
+
"fields": {
|
|
56
|
+
"layout": "blob-47",
|
|
57
|
+
"grid": { "cellWidth": 16, "cellHeight": 16, "margin": 1, "spacing": 2 },
|
|
58
|
+
"terrains": { "lower": "dirt", "upper": "grass" }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
assetgrove import --sheet meadow.png --spec meadow-sheet.json --profile profile.json \
|
|
65
|
+
--origin origin.json --tool "the shop's download" --digital-source-type digitalCreation --asset meadow
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `fields.layout`: a name from the layouts list. Declared, it is used as stated, and `none` is a layout like the others. Left out, the import works out the grid and, when its columns × rows fit one or more terrain layouts (`layoutsFitting`), stages nothing and exits 2 `invalid_input` with `fields.read.layouts` (the fitting names, plus `grid` when the grid was read), for the developer to confirm by stating `fields.layout` (or `none`) in the spec. A grid that fits no terrain layout imports as `none`.
|
|
69
|
+
- `fields.terrains`: optional `{ lower, upper }`, non-empty strings, recorded in `output.fields` as given.
|
|
70
|
+
- `fields.grid`: the cell size, and the `margin` and `spacing` (default 0), in whole pixels, as the developer states them. Columns and rows are as many whole cells as fit the image. Without `fields.grid`, the grid is read from the sheet's gutters (rows and columns that are wholly transparent or wholly the top-left pixel's colour, one margin all round, one spacing, equal cells); nothing is staged, and the import exits 2 `invalid_input` with what it read in `fields.read`, for the developer to confirm by stating it in the spec. A sheet with no gutters to read must be stated.
|
|
71
|
+
- `--origin` is required and third-party: the supplier as `source`, the evidence of purchase as `evidence`, and the licence `terms` (see core's [declared origins](../../docs/sheet-import.md#declared-origins)). Pick, adopt and deliver enforce the terms.
|
|
72
|
+
- The kind's exact check, `tiles:grid`, runs on the sheet as on a generated one, and a failing one refuses the import (exit 2). Empty cells are kept as empty: the candidate's `fields.emptyCells` lists their addresses, and an empty cell the layout's autotile table needs fails the check. `tiles:palette` does not run on an import: the sheet's colours are its supplier's, kept as given.
|
|
73
|
+
- `fields.animations` (optional): animated tiles, each `{ frames, durationMs }`. `frames` are cell addresses (`r<row>c<column>`), the base tile first, at least two; `durationMs` is the time of each frame in milliseconds, above 0. One tile with frames, not a tile per frame: `{ "frames": ["r0c0", "r0c1", "r0c2"], "durationMs": 150 }`.
|
|
74
|
+
- The exact check `tiles:animation` gives one reason per declared animation, and refuses the import (exit 2) when it fails: a frame that is malformed or off the grid, a cell used as a frame twice, a layout with an autotile table (every cell its own tile), or a loop that jumps, the last frame's distance to the first beyond core's loop-seam bound (`qa.loopSeam`). Frames share a size because every cell does. A sheet without animations gives no reason.
|
|
75
|
+
- `output.fields` are `{ layout, grid, emptyCells }`, with `terrains` when given, `autotile` when the layout has one, and `animations` as declared when given. The target profile's `kinds["tiles:sheet"]` block is optional and holds only core's `layout` and `values`.
|
|
76
|
+
- `stage` of a `tiles:sheet` spec is refused at plan (exit 2 `invalid_input`).
|
|
77
|
+
|
|
78
|
+
### Cell labels
|
|
79
|
+
|
|
80
|
+
A cell can carry a kind, whether it is walkable, and whether it draws above or below characters. A model proposes them from the image and a person confirms them by stating them in the spec as `fields.cellLabels`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"cellLabels": {
|
|
85
|
+
"grid": { "cellWidth": 16, "cellHeight": 16, "margin": 1, "spacing": 2 },
|
|
86
|
+
"cells": { "r0c0": { "kind": "ground", "walkable": true, "draw": "below" } }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- `cells`: by cell address, each `{ kind, walkable, draw }`. `kind` is one of the project's tile kinds (`tileKinds` in the nearest `.assetgrove/labels.json` at or above the `--profile` file's directory, else `ground`, `wall`, `object`, `water`), `walkable` a boolean (`false` is blocked) and `draw` `above` or `below`. Not every cell needs a label. An address outside the grid, a later frame of an animated tile (its first frame carries the tile's label), or a kind outside the project's, is refused `invalid_input`.
|
|
92
|
+
- `grid`: the cell size, margin and spacing the labels were confirmed on. A re-import of the sheet carries the labels while these match `fields.grid`, even when the pixels changed; with another grid the cells moved, and the import is refused `invalid_input`: propose again.
|
|
93
|
+
- `assetgrove import --spec <spec.json> --propose-labels` (with the other import options) makes one paid `tiles:labels` call (role `vision`) once the sheet imports cleanly by the spec. It proposes labels for the drawn cells only, stages nothing and exits 0 with `fields.read.cellLabels` for the person to confirm. A spec's import without labels and without `--propose-labels` reads no vocabulary.
|
|
94
|
+
- The labels ride in the candidate's `output.fields.cellLabels`, and the Godot pack's `godot:tile-set` writes them as custom data and whole-cell collision on each tile.
|
|
95
|
+
|
|
96
|
+
## The `tiles:objects` kind: generated object tiles
|
|
97
|
+
|
|
98
|
+
A sheet of nine unrelated object tiles (a crate, a pot, a bush) for a top-down or isometric game, generated in one call and held to its grid and the palette. The spec names the nine objects in cell order, from the top left, row by row:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"kind": "tiles:objects",
|
|
103
|
+
"assetId": "garden-things",
|
|
104
|
+
"fields": {
|
|
105
|
+
"objects": [
|
|
106
|
+
"a wooden crate",
|
|
107
|
+
"a clay pot",
|
|
108
|
+
"a round bush",
|
|
109
|
+
"a grey rock",
|
|
110
|
+
"a tree stump",
|
|
111
|
+
"a signpost",
|
|
112
|
+
"a log",
|
|
113
|
+
"a flower bed",
|
|
114
|
+
"a lantern"
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The target profile carries a `kinds["tiles:objects"]` block with the cell size:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{ "kinds": { "tiles:objects": { "tileSize": 16 } } }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- `fields.objects`: exactly nine names. Another count is refused at plan (exit 2 `invalid_input`), as is a profile without the block.
|
|
127
|
+
- The sheet is 3 × 3 cells of `tileSize`, no margin or spacing, layout `none`, so the Godot tile-set export takes it as a plain atlas. `output.fields` are `{ layout, grid, objects }`.
|
|
128
|
+
- Generation: one `tiles:objects` call (role `image`). The prompt names the objects, the 3 × 3 cells, a flat `#ff00ff` background, the bible's palette and its style notes. Pixels within RGB distance 64 of the image border's median colour become transparent. The image is scaled to fit `3 * tileSize` square, centred, and the profile's alpha and colour rule are applied.
|
|
129
|
+
- Checks, all exact, free and filtering: `tiles:grid` (the size, and no cell empty: every object drawn), `tiles:palette` and `tiles:in-cell`.
|
|
130
|
+
|
|
131
|
+
This is the one shape the qualification run held to its grid (on `openai/gpt-image-2`, the `image` role's default, and `bfl/flux-2-pro`), at 16 px cells ([decisions](../../docs/decisions.md#generated-tile-sheets-object-tiles-qualify-a-larger-autotile-layout-does-not-691)). No route held a larger autotile layout, so none is generated.
|
|
132
|
+
|
|
133
|
+
## The sheet
|
|
134
|
+
|
|
135
|
+
A sheet is one image cut into a grid of cells, with a layout that gives the cells their meaning. `output.fields` carries `layout` and `grid`:
|
|
136
|
+
|
|
137
|
+
- `grid`: `{ cellWidth, cellHeight, columns, rows, margin, spacing }`, all whole pixels. `margin` applies on every side of the sheet and `spacing` between every pair of neighbouring cells. Cell `(column, row)` starts at `x = margin + column * (cellWidth + spacing)`, `y = margin + row * (cellHeight + spacing)`. The sheet is `2 * margin + columns * cellWidth + (columns - 1) * spacing` wide, and likewise tall.
|
|
138
|
+
- `layout`: a name in the pack's layouts list. The layouts are `corner-16` (4 × 4), `blob-47` (12 × 4), `side-16` (4 × 4), `corner-16-2x2` (4 × 4) and `none`. The first four fix a grid shape and carry an autotile table. `none` fixes nothing: a plain grid of unrelated tiles, any of which may be empty.
|
|
139
|
+
- cell address: `r<row>c<column>`, zero-based from the top left, so `r1c1` is row 1, column 1. Review notes, labels and exports point at a cell by it.
|
|
140
|
+
|
|
141
|
+
The pack exports `LAYOUTS`, `layoutNamed`, `autotileOf`, `layoutsFitting`, `AUTOTILE_NEIGHBOURS`, `cellAddress`, `parseCellAddress`, `cellBox`, `sheetSize`, `sheetCells`, `gridProblems`, `emptyCells`, `gridFor` and `readGrid`.
|
|
142
|
+
|
|
143
|
+
## Autotile layouts
|
|
144
|
+
|
|
145
|
+
A layout with an `autotile` table says what each cell draws. The table has one string per grid row, one space-separated token per cell: `<centre>/<bits>`, where the centre and each bit are `0` (the lower terrain) or `1` (the upper), and a leading `?` marks a cell the layout may leave blank: `tiles:grid` does not need it. The bits follow the table's mode (`AUTOTILE_NEIGHBOURS`):
|
|
146
|
+
|
|
147
|
+
| Mode | Bits, in order |
|
|
148
|
+
| ------------------- | ------------------- |
|
|
149
|
+
| `corners` | nw ne sw se |
|
|
150
|
+
| `sides` | n e s w |
|
|
151
|
+
| `corners-and-sides` | n ne e se s sw w nw |
|
|
152
|
+
|
|
153
|
+
`blob-47`, `side-16` and `corner-16-2x2` are Godot 3's autotile templates ("3x3 minimal", "3x3 16 tiles", "2x2"), the arrangements published Godot packs are drawn to; their per-cell data is from [TileBitTools](https://github.com/dandeliondino/tile_bit_tools)' templates (MIT), with the drawn terrain as the upper. `autotileOf(layout)` gives the table as `{ mode, tiles }`, `tiles` in row-major order, each `{ cell, terrain, peering, optional? }` with `cell` an address (`r0c1`) and `peering` a record of neighbour name to 0 or 1 and `optional` `true` on a cell the layout may leave blank (the all-lower spare of `blob-47` and `corner-16-2x2`, which Godot 3's templates leave empty); it is undefined for `none`. `tiles:terrain` and `tiles:sheet` record it as `output.fields.autotile`.
|
|
154
|
+
|
|
155
|
+
## The corner-16 cell table
|
|
156
|
+
|
|
157
|
+
A corner-16 set has 16 tiles on a 4 × 4 grid. Each tile gives a label to each of its four corners: `L`, the lower terrain, or `U`, the upper. Tile `i` has corner bits NW = 1, NE = 2, SW = 4, SE = 8, set for `U`. It sits at column `i % 4` and row `floor(i / 4)`, origin top-left. So tile 5 is NW `U`, NE `L`, SW `U`, SE `L`, and tile 15 is `UUUU`.
|
|
158
|
+
|
|
159
|
+
| Tile | Column | Row | Address | NW | NE | SW | SE |
|
|
160
|
+
| ---: | -----: | --: | ------- | --- | --- | --- | --- |
|
|
161
|
+
| 0 | 0 | 0 | r0c0 | L | L | L | L |
|
|
162
|
+
| 1 | 1 | 0 | r0c1 | U | L | L | L |
|
|
163
|
+
| 2 | 2 | 0 | r0c2 | L | U | L | L |
|
|
164
|
+
| 3 | 3 | 0 | r0c3 | U | U | L | L |
|
|
165
|
+
| 4 | 0 | 1 | r1c0 | L | L | U | L |
|
|
166
|
+
| 5 | 1 | 1 | r1c1 | U | L | U | L |
|
|
167
|
+
| 6 | 2 | 1 | r1c2 | L | U | U | L |
|
|
168
|
+
| 7 | 3 | 1 | r1c3 | U | U | U | L |
|
|
169
|
+
| 8 | 0 | 2 | r2c0 | L | L | L | U |
|
|
170
|
+
| 9 | 1 | 2 | r2c1 | U | L | L | U |
|
|
171
|
+
| 10 | 2 | 2 | r2c2 | L | U | L | U |
|
|
172
|
+
| 11 | 3 | 2 | r2c3 | U | U | L | U |
|
|
173
|
+
| 12 | 0 | 3 | r3c0 | L | L | U | U |
|
|
174
|
+
| 13 | 1 | 3 | r3c1 | U | L | U | U |
|
|
175
|
+
| 14 | 2 | 3 | r3c2 | L | U | U | U |
|
|
176
|
+
| 15 | 3 | 3 | r3c3 | U | U | U | U |
|
|
177
|
+
|
|
178
|
+
The atlas, each cell as its index and its corners NW NE / SW SE:
|
|
179
|
+
|
|
180
|
+
```text
|
|
181
|
+
col 0 col 1 col 2 col 3
|
|
182
|
+
row 0 0 LL/LL 1 UL/LL 2 LU/LL 3 UU/LL
|
|
183
|
+
row 1 4 LL/UL 5 UL/UL 6 LU/UL 7 UU/UL
|
|
184
|
+
row 2 8 LL/LU 9 UL/LU 10 LU/LU 11 UU/LU
|
|
185
|
+
row 3 12 LL/UU 13 UL/UU 14 LU/UU 15 UU/UU
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The pack exports `cornersOf(index)`, `CORNER16_TABLE` and `corner16Grid(tileSize)`, which this table is computed from.
|
|
189
|
+
|
|
190
|
+
## Generation
|
|
191
|
+
|
|
192
|
+
One `tiles:atlas` call (role `image`) with a template reference: the table above drawn in flat dark grey `#404040` for the lower terrain and light grey `#c0c0c0` for the upper. The prompt names both terrains and the profile's palette. The image is scaled to fit `4 * tileSize` square, centred, and the profile's alpha and colour rule are applied.
|
|
193
|
+
|
|
194
|
+
## Checks
|
|
195
|
+
|
|
196
|
+
| Check | Mode | Judges |
|
|
197
|
+
| ------------------------ | ----- | ------------------------------------------------------------------ |
|
|
198
|
+
| `tiles:grid` | exact | The sheet is its grid's size, no cell empty that the layout needs. |
|
|
199
|
+
| `tiles:class-uniformity` | exact | Tiles sharing a side's corner labels share that edge. |
|
|
200
|
+
| `tiles:seam-quality` | model | The seams look continuous and the pure tiles wrap. |
|
|
201
|
+
| `tiles:palette` | exact | Under a palette rule, every visible pixel is a palette colour. |
|
|
202
|
+
| `tiles:in-cell` | exact | Each object of a `tiles:objects` sheet sits inside its own cell. |
|
|
203
|
+
|
|
204
|
+
### `tiles:grid`
|
|
205
|
+
|
|
206
|
+
Exact, free, and it filters. One check for every kind: a `tiles:terrain` sheet is held to 4 × 4 cells of `tileSize`, a `tiles:objects` sheet to 3 × 3, a `tiles:sheet` to the grid its `output.fields` record. The sheet must be exactly its grid's size, no cell its layout's autotile table needs may be empty, and on a `tiles:objects` sheet no cell may be empty. A cell is empty when no pixel has alpha at or above the profile's alpha threshold. Reasons:
|
|
207
|
+
|
|
208
|
+
- a wrong size: `the sheet is 60 × 60, not 64 × 64 (4 × 4 cells of 16 × 16 px)`;
|
|
209
|
+
- an empty cell, one reason each: `cell r1c1 is empty: no pixel at alpha 1 or above`;
|
|
210
|
+
- passing: `the sheet is 4 × 4 cells of 16 × 16 px (64 × 64), no cell empty`;
|
|
211
|
+
- passing, when the empty cells are not needed (for example under `none`), with the empty cells kept: `the sheet is 3 × 2 cells of 8 × 8 px (30 × 20); cells r1c2 are empty and kept as empty`.
|
|
212
|
+
|
|
213
|
+
### `tiles:class-uniformity`
|
|
214
|
+
|
|
215
|
+
Exact, free, and it filters. Tiles that meet along the same kind of edge must have the same edge, or the set shows seams when placed. A class is a side and the corner-label pair along it, read along the side: north NW NE, south SW SE, west NW SW, east NE SE. Tiles 1, 5, 9 and 13 are the class (north, `UL`).
|
|
216
|
+
|
|
217
|
+
The outermost 1-px strip of each tile on a side is compared byte-exact as RGBA with the others of its class. The strip most of the class shares wins; on a tie the strip held by the lowest index wins. Each tile off the winning strip fails, naming the cell, the tile, the side and the class: `cell r1c1 (tile 5): its north strip differs from its class (north, UL) in 3 px`.
|
|
218
|
+
|
|
219
|
+
It applies only when the profile's resolved colour rule is `palette`, since only then are colours exact. Otherwise it passes with a reason starting `skipped:` that says why. On a sheet of the wrong size it also passes as `skipped:`, because `tiles:grid` reports that.
|
|
220
|
+
|
|
221
|
+
The pixel-art spike ([decisions](../../docs/decisions.md#generated-tile-sheets-object-tiles-qualify-a-larger-autotile-layout-does-not-691)) held the 47-tile blob layout to this rule on real routes, and no route kept it: most edge strips of every sheet were off their class. Here it is proven on the scripted provider.
|
|
222
|
+
|
|
223
|
+
### `tiles:palette`
|
|
224
|
+
|
|
225
|
+
Exact, free, and it filters, on generated kinds (`tiles:objects`), not on `tiles:sheet` imports, whose colours are kept as the supplier made them. Under a palette colour rule, every pixel at or above the profile's alpha threshold must be one of the palette's colours: the profile's `style.color.palette`, else the bible's. A failing reason counts the pixels and colours off it: `12 px in 3 colours are off the palette, for example #ff0000, ...`. Under the full colour rule, or with no palette, it passes with a reason starting `skipped:`. A generated sheet is snapped to the palette, so it fails only when the profile's palette and the one it was snapped to differ.
|
|
226
|
+
|
|
227
|
+
### `tiles:in-cell`
|
|
228
|
+
|
|
229
|
+
Exact, free, and it filters, on `tiles:objects`. No pixel at or above the alpha threshold may sit on a cell's outermost 1-px ring, where the grid would cut an object, and each cell's object must cover at least 5% of the cell. One reason per problem: `cell r2c1: 6 px on the cell's edge, so the grid cuts its object`. On a sheet of the wrong size it passes as `skipped:`, as `tiles:grid` reports it.
|
|
230
|
+
|
|
231
|
+
### `tiles:seam-quality`
|
|
232
|
+
|
|
233
|
+
A model check, advisory. One boolean decision (operation `tiles:seams`, role `decisions`) over two images: the atlas, and a wrap preview of the two pure tiles (0, all lower; 15, all upper) each repeated 2 × 2. The pack ships no stability entry, so its reasons are advisory (`shadow`) and never filter, until a measured stability entry qualifies it ([QA checks](../../docs/extensions.md#qa-checks)).
|
|
234
|
+
|
|
235
|
+
## Changing one tile
|
|
236
|
+
|
|
237
|
+
Mark the tile's cell with `request-change`, using `cellBox(grid, cell)` (`x = margin + column * (cellWidth + spacing)`, `y = margin + row * (cellHeight + spacing)`, `w = cellWidth`, `h = cellHeight`). Tile 5 is cell `r1c1`; at `tileSize` 16 its box is `16,16,16,16`:
|
|
238
|
+
|
|
239
|
+
```sh
|
|
240
|
+
assetgrove request-change <address> --region "16,16,16,16 : the dirt looks too green at the corners"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The edit runs the kind's exact checks, and a failing edit is filtered.
|
|
244
|
+
|
|
245
|
+
## Routing
|
|
246
|
+
|
|
247
|
+
Settings `routes["tiles:atlas"]`, `routes["tiles:objects"]` and `routes["tiles:seams"]` choose the route. Without them the roles `image` and `decisions` do. `tiles:objects` is qualified on `openai/gpt-image-2` and `bfl/flux-2-pro` at 1024x1024; on another model it runs, and its exact checks filter what does not hold the grid.
|
|
248
|
+
|
|
249
|
+
## Limits
|
|
250
|
+
|
|
251
|
+
This pack generates two shapes: the corner-16 terrain set and nine object tiles on a 3 × 3 grid. No larger autotile layout is generated, since no route holds one; the other layouts, `none` and any margin or spacing are imported, recorded and addressed but not generated. Two terrains per set. Square tiles. Sets of more than two terrains are not made by this pack.
|
|
252
|
+
|
|
253
|
+
## Development
|
|
254
|
+
|
|
255
|
+
```sh
|
|
256
|
+
pnpm install --frozen-lockfile --ignore-scripts
|
|
257
|
+
pnpm check
|
|
258
|
+
pnpm test
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The tests use the scripted provider and never call a model.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `tiles:animation` check: each animated tile a `tiles:sheet` declares has frames that are
|
|
3
|
+
* cells of the grid, of one size, and a loop that closes without a visible jump.
|
|
4
|
+
*/
|
|
5
|
+
import type { ExtensionContext, KindCheck, KindCheckInput } from "@clockgrove/assetgrove/extension";
|
|
6
|
+
import type { Sheet } from "./sheet.ts";
|
|
7
|
+
export declare const ANIMATION_CHECK = "tiles:animation";
|
|
8
|
+
export declare function animationCheck(context: ExtensionContext, sheetOf: (input: KindCheckInput) => Sheet): KindCheck;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { animationProblems, cellBox, parseCellAddress, sheetSize } from "./sheet.js";
|
|
2
|
+
export const ANIMATION_CHECK = "tiles:animation";
|
|
3
|
+
export function animationCheck(context, sheetOf) {
|
|
4
|
+
const { raster, qa } = context;
|
|
5
|
+
return {
|
|
6
|
+
name: ANIMATION_CHECK,
|
|
7
|
+
mode: "exact",
|
|
8
|
+
source: "deterministic",
|
|
9
|
+
run(input) {
|
|
10
|
+
const { profile, bible, output } = input;
|
|
11
|
+
const sheet = sheetOf(input);
|
|
12
|
+
const { grid } = sheet;
|
|
13
|
+
const animations = sheet.animations ?? [];
|
|
14
|
+
if (animations.length === 0)
|
|
15
|
+
return [];
|
|
16
|
+
const base = { check: ANIMATION_CHECK, source: "deterministic" };
|
|
17
|
+
const { threshold } = raster.resolveStyle(profile.style, bible.palette).alpha;
|
|
18
|
+
const image = raster.decode(output.bytes);
|
|
19
|
+
const { width, height } = sheetSize(grid);
|
|
20
|
+
const sized = image.width === width && image.height === height;
|
|
21
|
+
const problems = animationProblems(sheet);
|
|
22
|
+
return animations.map(({ frames, durationMs }, i) => {
|
|
23
|
+
const named = frames.join(", ");
|
|
24
|
+
const found = [...problems[i]];
|
|
25
|
+
if (!sized)
|
|
26
|
+
found.push(`the sheet is ${image.width} × ${image.height}, not ${width} × ${height}`);
|
|
27
|
+
if (found.length > 0)
|
|
28
|
+
return { ...base, passed: false, reason: `frames ${named}: ${found.join("; ")}` };
|
|
29
|
+
const crops = frames.map((address) => raster.crop(image, cellBox(grid, parseCellAddress(address, grid))));
|
|
30
|
+
const { seam, bound, closes } = qa.loopSeam(crops, threshold, profile);
|
|
31
|
+
const measure = `seam ${seam.toFixed(3)} against a bound of ${bound.toFixed(3)}`;
|
|
32
|
+
return closes
|
|
33
|
+
? {
|
|
34
|
+
...base,
|
|
35
|
+
passed: true,
|
|
36
|
+
reason: `frames ${named} are ${grid.cellWidth} × ${grid.cellHeight} px at ${durationMs} ms each, and the loop closes: ${measure}`,
|
|
37
|
+
}
|
|
38
|
+
: {
|
|
39
|
+
...base,
|
|
40
|
+
passed: false,
|
|
41
|
+
reason: `frames ${named}: the last frame jumps back to the first, ${measure}`,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The corner-16 layout: 16 tiles on a 4 × 4 grid, each tile encoding a label on each of
|
|
3
|
+
* its four corners, `L` (the lower terrain) or `U` (the upper). Tile `i` has corner bits
|
|
4
|
+
* NW = 1, NE = 2, SW = 4, SE = 8 (set for `U`) and sits at column `i % 4`, row `floor(i / 4)`,
|
|
5
|
+
* origin top-left. Pure arithmetic over RGBA bytes, so it needs nothing from core.
|
|
6
|
+
*/
|
|
7
|
+
import type { Pixels, SheetGrid } from "./sheet.ts";
|
|
8
|
+
/** A corner's label: the lower or the upper terrain. */
|
|
9
|
+
export type Label = "L" | "U";
|
|
10
|
+
export interface Corners {
|
|
11
|
+
nw: Label;
|
|
12
|
+
ne: Label;
|
|
13
|
+
sw: Label;
|
|
14
|
+
se: Label;
|
|
15
|
+
}
|
|
16
|
+
export type Side = "north" | "south" | "west" | "east";
|
|
17
|
+
export declare const SIDES: readonly Side[];
|
|
18
|
+
export interface Cell {
|
|
19
|
+
index: number;
|
|
20
|
+
column: number;
|
|
21
|
+
row: number;
|
|
22
|
+
address: string;
|
|
23
|
+
corners: Corners;
|
|
24
|
+
}
|
|
25
|
+
/** The corner labels of tile `index` (0..15). */
|
|
26
|
+
export declare function cornersOf(index: number): Corners;
|
|
27
|
+
/** The fixed cell table, in index order. */
|
|
28
|
+
export declare const CORNER16_TABLE: readonly Cell[];
|
|
29
|
+
/** The corner-16 grid of `tileSize` square tiles, no margin and no spacing. */
|
|
30
|
+
export declare const corner16Grid: (tileSize: number) => SheetGrid;
|
|
31
|
+
/** A side's corner-label pair, read along the side: north NW NE, south SW SE, west NW SW, east NE SE. */
|
|
32
|
+
export declare function sidePair(corners: Corners, side: Side): string;
|
|
33
|
+
/** The outermost 1-px row or column of `cell` on `side`, as RGBA bytes along the side. */
|
|
34
|
+
export declare function strip(image: Pixels, grid: SheetGrid, cell: Cell, side: Side): Uint8Array;
|
|
35
|
+
/** A tile whose strip on `side` differs from its class's strip. */
|
|
36
|
+
export interface StripMismatch {
|
|
37
|
+
index: number;
|
|
38
|
+
address: string;
|
|
39
|
+
side: Side;
|
|
40
|
+
/** The side's corner-label pair, which with the side names the class. */
|
|
41
|
+
pair: string;
|
|
42
|
+
/** How many of the strip's pixels differ from the class's strip. */
|
|
43
|
+
pixels: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Within each (side, corner-label pair) class, the tiles whose outermost strip on that side is not
|
|
47
|
+
* the class's strip. The class's strip is the one most of its tiles share (on a tie, the one the
|
|
48
|
+
* lowest index holds), so one wrong strip names its own tile. In index order, then side order.
|
|
49
|
+
*/
|
|
50
|
+
export declare function classMismatches(image: Pixels, grid: SheetGrid): StripMismatch[];
|
|
51
|
+
/**
|
|
52
|
+
* The template-built set: each tile's four quadrants copied from the lower or the upper terrain
|
|
53
|
+
* texture by its corner labels, split at `floor(tileSize / 2)`. Both textures are `tileSize` square.
|
|
54
|
+
*/
|
|
55
|
+
export declare function templateAtlas(lower: Pixels, upper: Pixels): Pixels;
|
package/dist/corner16.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The corner-16 layout: 16 tiles on a 4 × 4 grid, each tile encoding a label on each of
|
|
3
|
+
* its four corners, `L` (the lower terrain) or `U` (the upper). Tile `i` has corner bits
|
|
4
|
+
* NW = 1, NE = 2, SW = 4, SE = 8 (set for `U`) and sits at column `i % 4`, row `floor(i / 4)`,
|
|
5
|
+
* origin top-left. Pure arithmetic over RGBA bytes, so it needs nothing from core.
|
|
6
|
+
*/
|
|
7
|
+
import { cellAddress, cellBox, sheetSize } from "./sheet.js";
|
|
8
|
+
const COLUMNS = 4;
|
|
9
|
+
export const SIDES = ["north", "south", "west", "east"];
|
|
10
|
+
/** The corner labels of tile `index` (0..15). */
|
|
11
|
+
export function cornersOf(index) {
|
|
12
|
+
const at = (bit) => ((index & bit) !== 0 ? "U" : "L");
|
|
13
|
+
return { nw: at(1), ne: at(2), sw: at(4), se: at(8) };
|
|
14
|
+
}
|
|
15
|
+
/** The fixed cell table, in index order. */
|
|
16
|
+
export const CORNER16_TABLE = Array.from({ length: 16 }, (_, index) => {
|
|
17
|
+
const column = index % COLUMNS;
|
|
18
|
+
const row = Math.floor(index / COLUMNS);
|
|
19
|
+
return { index, column, row, address: cellAddress({ column, row }), corners: cornersOf(index) };
|
|
20
|
+
});
|
|
21
|
+
/** The corner-16 grid of `tileSize` square tiles, no margin and no spacing. */
|
|
22
|
+
export const corner16Grid = (tileSize) => ({
|
|
23
|
+
cellWidth: tileSize,
|
|
24
|
+
cellHeight: tileSize,
|
|
25
|
+
columns: COLUMNS,
|
|
26
|
+
rows: COLUMNS,
|
|
27
|
+
margin: 0,
|
|
28
|
+
spacing: 0,
|
|
29
|
+
});
|
|
30
|
+
/** A side's corner-label pair, read along the side: north NW NE, south SW SE, west NW SW, east NE SE. */
|
|
31
|
+
export function sidePair(corners, side) {
|
|
32
|
+
switch (side) {
|
|
33
|
+
case "north":
|
|
34
|
+
return corners.nw + corners.ne;
|
|
35
|
+
case "south":
|
|
36
|
+
return corners.sw + corners.se;
|
|
37
|
+
case "west":
|
|
38
|
+
return corners.nw + corners.sw;
|
|
39
|
+
case "east":
|
|
40
|
+
return corners.ne + corners.se;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The outermost 1-px row or column of `cell` on `side`, as RGBA bytes along the side. */
|
|
44
|
+
export function strip(image, grid, cell, side) {
|
|
45
|
+
const { x, y, width, height } = cellBox(grid, cell);
|
|
46
|
+
const length = side === "north" || side === "south" ? width : height;
|
|
47
|
+
const out = new Uint8Array(length * 4);
|
|
48
|
+
for (let i = 0; i < length; i++) {
|
|
49
|
+
const [px, py] = side === "north"
|
|
50
|
+
? [x + i, y]
|
|
51
|
+
: side === "south"
|
|
52
|
+
? [x + i, y + height - 1]
|
|
53
|
+
: side === "west"
|
|
54
|
+
? [x, y + i]
|
|
55
|
+
: [x + width - 1, y + i];
|
|
56
|
+
const from = (py * image.width + px) * 4;
|
|
57
|
+
out.set(image.data.subarray(from, from + 4), i * 4);
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Within each (side, corner-label pair) class, the tiles whose outermost strip on that side is not
|
|
63
|
+
* the class's strip. The class's strip is the one most of its tiles share (on a tie, the one the
|
|
64
|
+
* lowest index holds), so one wrong strip names its own tile. In index order, then side order.
|
|
65
|
+
*/
|
|
66
|
+
export function classMismatches(image, grid) {
|
|
67
|
+
const mismatches = [];
|
|
68
|
+
for (const side of SIDES) {
|
|
69
|
+
const classes = new Map();
|
|
70
|
+
for (const { index, corners } of CORNER16_TABLE) {
|
|
71
|
+
const pair = sidePair(corners, side);
|
|
72
|
+
classes.set(pair, [...(classes.get(pair) ?? []), index]);
|
|
73
|
+
}
|
|
74
|
+
for (const [pair, members] of classes) {
|
|
75
|
+
const strips = new Map(members.map((i) => [i, strip(image, grid, CORNER16_TABLE[i], side)]));
|
|
76
|
+
const groups = new Map();
|
|
77
|
+
for (const [i, bytes] of strips) {
|
|
78
|
+
const key = Buffer.from(bytes).toString("base64");
|
|
79
|
+
groups.set(key, [...(groups.get(key) ?? []), i]);
|
|
80
|
+
}
|
|
81
|
+
// Map order is first-seen, so on a tie the group holding the lowest index comes first.
|
|
82
|
+
const [kept] = [...groups.values()].sort((a, b) => b.length - a.length);
|
|
83
|
+
const reference = strips.get(kept[0]);
|
|
84
|
+
for (const i of members) {
|
|
85
|
+
if (kept.includes(i))
|
|
86
|
+
continue;
|
|
87
|
+
const bytes = strips.get(i);
|
|
88
|
+
let pixels = 0;
|
|
89
|
+
for (let p = 0; p < bytes.length / 4; p++)
|
|
90
|
+
if (bytes.subarray(p * 4, p * 4 + 4).some((b, c) => b !== reference[p * 4 + c]))
|
|
91
|
+
pixels++;
|
|
92
|
+
mismatches.push({ index: i, address: CORNER16_TABLE[i].address, side, pair, pixels });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return mismatches.sort((a, b) => a.index - b.index || SIDES.indexOf(a.side) - SIDES.indexOf(b.side));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The template-built set: each tile's four quadrants copied from the lower or the upper terrain
|
|
100
|
+
* texture by its corner labels, split at `floor(tileSize / 2)`. Both textures are `tileSize` square.
|
|
101
|
+
*/
|
|
102
|
+
export function templateAtlas(lower, upper) {
|
|
103
|
+
const tileSize = lower.width;
|
|
104
|
+
if (lower.height !== tileSize || upper.width !== tileSize || upper.height !== tileSize)
|
|
105
|
+
throw new Error(`the terrain textures must both be ${tileSize} × ${tileSize}, not ${lower.width} × ${lower.height} and ${upper.width} × ${upper.height}`);
|
|
106
|
+
const grid = corner16Grid(tileSize);
|
|
107
|
+
const { width, height } = sheetSize(grid);
|
|
108
|
+
const out = { width, height, data: new Uint8Array(width * height * 4) };
|
|
109
|
+
const half = Math.floor(tileSize / 2);
|
|
110
|
+
for (const cell of CORNER16_TABLE) {
|
|
111
|
+
const { corners } = cell;
|
|
112
|
+
const { x, y } = cellBox(grid, cell);
|
|
113
|
+
for (let ty = 0; ty < tileSize; ty++)
|
|
114
|
+
for (let tx = 0; tx < tileSize; tx++) {
|
|
115
|
+
const label = ty < half ? (tx < half ? corners.nw : corners.ne) : tx < half ? corners.sw : corners.se;
|
|
116
|
+
const texture = label === "U" ? upper : lower;
|
|
117
|
+
const from = (ty * tileSize + tx) * 4;
|
|
118
|
+
out.data.set(texture.data.subarray(from, from + 4), ((y + ty) * width + x + tx) * 4);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** The tiles pack's entry for core's extension API (api 3): the `tiles:terrain`, `tiles:sheet` and `tiles:objects` kinds. */
|
|
2
|
+
import type { Extension, ExtensionContext } from "@clockgrove/assetgrove/extension";
|
|
3
|
+
export default function tilesExtension(context: ExtensionContext): Extension;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { tilesSheetKind } from "./imported.js";
|
|
2
|
+
import { tilesTerrainKind } from "./kind.js";
|
|
3
|
+
import { tilesObjectsKind } from "./objects.js";
|
|
4
|
+
export default function tilesExtension(context) {
|
|
5
|
+
return {
|
|
6
|
+
api: context.api,
|
|
7
|
+
name: "tiles",
|
|
8
|
+
kinds: [tilesTerrainKind(context), tilesSheetKind(context), tilesObjectsKind(context)],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `tiles:sheet` kind: a tile sheet made elsewhere (bought or hand-drawn), imported by cell. Its
|
|
3
|
+
* bytes are kept as given; the kind records the layout and the grid and checks them exactly.
|
|
4
|
+
*/
|
|
5
|
+
import type { AssetKind, ExtensionContext } from "@clockgrove/assetgrove/extension";
|
|
6
|
+
export declare const SHEET_KIND = "tiles:sheet";
|
|
7
|
+
export declare function tilesSheetKind(context: ExtensionContext): AssetKind;
|