@rig-c/parts 1.9.1 → 1.10.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 +2 -1
- package/cli.ts +128 -15
- package/docs/AUTHORING.md +121 -20
- package/docs/STABILITY.md +16 -7
- package/package.json +1 -1
- package/src/assemble.ts +100 -22
- package/src/build.ts +62 -9
- package/src/check.ts +150 -32
- package/src/config.ts +52 -6
- package/src/contour.ts +40 -2
- package/src/layers.ts +12 -7
- package/src/meshdraft.ts +887 -0
- package/src/parts.ts +41 -10
- package/src/propose.ts +137 -25
- package/src/requirements.ts +21 -6
- package/src/rig.ts +4 -3
- package/src/tags.ts +86 -0
- package/src/turn.ts +31 -0
package/src/layers.ts
CHANGED
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
* and for a PSD it is the stacking order itself, with `depth` null because a
|
|
26
26
|
* PSD carries none. Every refusal is collected and thrown once, so one run
|
|
27
27
|
* names every missing file.
|
|
28
|
+
*
|
|
29
|
+
* A layer is named by a See-through v3 tag or, for a layer the author made
|
|
30
|
+
* by hand and added to the run (issue #256), by `author:<label>`
|
|
31
|
+
* (`src/tags.ts`, `AUTHOR_PREFIX`): read with `group` "author", it has no
|
|
32
|
+
* role, and its place in the draw order is read like any other layer's.
|
|
28
33
|
*/
|
|
29
34
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
30
35
|
import { basename, dirname, join } from 'node:path';
|
|
@@ -32,7 +37,7 @@ import { initializeCanvas, type Layer as PsdLayer, readPsd } from 'ag-psd';
|
|
|
32
37
|
import { type Problem, refuseIfAny } from './errors.ts';
|
|
33
38
|
import { decodePngBytes } from './raster/png.ts';
|
|
34
39
|
import type { Raster } from './raster/types.ts';
|
|
35
|
-
import {
|
|
40
|
+
import { type LayerTagReading, layerTagRequirement, readLayerTag } from './tags.ts';
|
|
36
41
|
|
|
37
42
|
/** Alpha strictly above this counts as painted. The reference uses the same cut for its ghost clean-up and its sheets. */
|
|
38
43
|
export const OPAQUE_ALPHA_ABOVE = 8;
|
|
@@ -45,9 +50,9 @@ export const OPAQUE_ALPHA_ABOVE = 8;
|
|
|
45
50
|
export const NEAR_WHITE_MIN = 235;
|
|
46
51
|
|
|
47
52
|
export interface Layer {
|
|
48
|
-
/** As the input names it
|
|
53
|
+
/** As the input names it: a v3 tag, possibly with a `-r`/`-l` side, or an author-made layer's `author:<label>`. */
|
|
49
54
|
name: string;
|
|
50
|
-
tag:
|
|
55
|
+
tag: LayerTagReading;
|
|
51
56
|
/** The file the pixels came from, or null for a PSD layer. */
|
|
52
57
|
file: string | null;
|
|
53
58
|
/** The layer's own pixels, `(right-left)x(bottom-top)`, straight alpha. */
|
|
@@ -197,9 +202,9 @@ export function readWrapperLayers(path: string): LayerSet {
|
|
|
197
202
|
return;
|
|
198
203
|
}
|
|
199
204
|
const name = e.name;
|
|
200
|
-
const tag =
|
|
205
|
+
const tag = readLayerTag(name);
|
|
201
206
|
if (tag === null) {
|
|
202
|
-
refuse('LAYERS_TAG_KNOWN', `layer "${name}"`,
|
|
207
|
+
refuse('LAYERS_TAG_KNOWN', `layer "${name}"`, layerTagRequirement(name));
|
|
203
208
|
ok = false;
|
|
204
209
|
}
|
|
205
210
|
for (const key of ['left', 'top', 'right', 'bottom'] as const) {
|
|
@@ -369,9 +374,9 @@ export function readPsdLayers(path: string): LayerSet {
|
|
|
369
374
|
const layers: Layer[] = [];
|
|
370
375
|
leaves.forEach((layer) => {
|
|
371
376
|
const name = layer.name ?? '';
|
|
372
|
-
const tag =
|
|
377
|
+
const tag = readLayerTag(name);
|
|
373
378
|
if (tag === null) {
|
|
374
|
-
refuse('LAYERS_TAG_KNOWN', `PSD layer "${name}"`,
|
|
379
|
+
refuse('LAYERS_TAG_KNOWN', `PSD layer "${name}"`, layerTagRequirement(name));
|
|
375
380
|
return;
|
|
376
381
|
}
|
|
377
382
|
if (seen.has(name)) {
|