spine-parts 2.11.0 → 2.12.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/docs/AUTHORING.md +45 -1
- package/docs/STABILITY.md +8 -1
- package/package.json +1 -1
- package/src/assemble.ts +23 -2
- package/src/coincideio.ts +3 -20
- package/src/paintingedges.ts +27 -2
- package/src/takeregion.ts +6 -4
package/docs/AUTHORING.md
CHANGED
|
@@ -851,7 +851,9 @@ shipped `source: true` semantics and prints one
|
|
|
851
851
|
stage painting for the predicate. A declared but unreadable reference, or a
|
|
852
852
|
hash or painting-dimension mismatch, is refused by name. Only an explicitly
|
|
853
853
|
declared painting reference keeps the selected mask fixed when `--source`
|
|
854
|
-
changes for projection.
|
|
854
|
+
changes for projection. The reference governs colour only and geometry follows `--source`.
|
|
855
|
+
A region take requires an opaque `--source` because its donor must match the run input and `inputs` refuses see-through paintings, so flatten the plate first.
|
|
856
|
+
Its input is derived as for whole-layer take above.
|
|
855
857
|
Both run canvases must agree, and the supplied original donor input
|
|
856
858
|
must match the entire target input in RGBA and dimensions, establishing the same
|
|
857
859
|
crop. Different crops await #973. Painting samples use the existing Lanczos3
|
|
@@ -7161,6 +7163,48 @@ the load moves the same build by (the pre-change reference-demo build alone took
|
|
|
7161
7163
|
45.8 s there). Since issue #123 that build and render are gone again — the still regions read the
|
|
7162
7164
|
idle's geometry — and the `build` row was not re-measured for it either.
|
|
7163
7165
|
|
|
7166
|
+
### Private worker measurements (issue #1045)
|
|
7167
|
+
|
|
7168
|
+
Each shard unit carries an additive `measurement` record with spec
|
|
7169
|
+
`rig-parts-selftest-unit/1`. Its suite, unit, sorted case-ID set and execution
|
|
7170
|
+
profile identify the measured work. The profile records Bun, platform,
|
|
7171
|
+
architecture, available cores, configured worker count and sampling interval.
|
|
7172
|
+
The existing stdout replay and tally remain the source of case verdicts.
|
|
7173
|
+
Shard records now use `rig-parts-selftest-shard/2`, which requires a measurement
|
|
7174
|
+
on every unit. A dropped attachment is refused by unit name. Version `/1`
|
|
7175
|
+
remains readable, with absent measurements explicitly `UNMEASURED`.
|
|
7176
|
+
|
|
7177
|
+
On Linux, an independent process samples the worker's descendant family through
|
|
7178
|
+
`/proc` at a requested 200 ms interval. PID and kernel start time identify each
|
|
7179
|
+
holder, including observed descendants subsequently reparented. `family.bytes`
|
|
7180
|
+
is the largest sampled sum of per-process RSS, with the simultaneous `holders`,
|
|
7181
|
+
sample count and unreadable-entry count retained. Shared pages count per PID.
|
|
7182
|
+
Short-lived children and allocations between samples can be missed. An absent
|
|
7183
|
+
observation has `status: "UNMEASURED"` and `bytes: null`.
|
|
7184
|
+
The supervising shard excludes registered observer PID/start-time identities
|
|
7185
|
+
from its family peak and RT20 verdict. The exclusion control fixes its noise
|
|
7186
|
+
band at 16 MiB before measurement and compares against an observer-free run.
|
|
7187
|
+
If observer finalization or unit measurement construction throws, the launcher
|
|
7188
|
+
settles with `UNMEASURED` coverage and the named `measurement.error`. A failed
|
|
7189
|
+
stop-file write terminates and waits for that observer before settling.
|
|
7190
|
+
|
|
7191
|
+
Worker-result `phases` retain labelled monotonic spans and elapsed milliseconds.
|
|
7192
|
+
The hooks cover input readers `readPartSet` and `readFrom`, fixture writers
|
|
7193
|
+
`writeWrapperFixture`, `writePsdFixture`, `writeRigFixture`, `writeCheckRig` and
|
|
7194
|
+
`writeProposeFixture`, producer calls `build`, `buildRig` and `runCli`, and the
|
|
7195
|
+
case reporter. The assertion span measures reporting, while evaluating assertion
|
|
7196
|
+
arguments remains outside that hook. Unhooked work stays `unclassified`.
|
|
7197
|
+
These are observed boundaries, with no claim of exhaustive phase attribution.
|
|
7198
|
+
The requested command owns a `runCli` span, including any subprocess startup.
|
|
7199
|
+
|
|
7200
|
+
For overlapping spans, the latest starting span owns the overlap, with later
|
|
7201
|
+
registration breaking equal-start ties. Exclusive totals plus `unclassified`
|
|
7202
|
+
equal the worker's recorded elapsed time. The phase window excludes module
|
|
7203
|
+
loading and parent launch/collection, which the existing unit clocks include.
|
|
7204
|
+
A phase with no observed span is `UNMEASURED`. Old shard records remain readable
|
|
7205
|
+
and their absent measurements are represented as `UNMEASURED` when parsed.
|
|
7206
|
+
Measurements are private records, with no product output or new console line.
|
|
7207
|
+
|
|
7164
7208
|
### Machine-readable selftest summary (`--summary-json`, issue #725)
|
|
7165
7209
|
|
|
7166
7210
|
`bun run selftest -- --summary-json <file>` writes a JSON summary beside the normal console output
|
package/docs/STABILITY.md
CHANGED
|
@@ -158,7 +158,7 @@ part name, `[i]` an entry of a list):
|
|
|
158
158
|
- **assemble.extend_painting[i]** — required: `part`, `band`, `max_distance`; optional: `min_held_alpha`, `order` (issues #848, #854, #855; explicit final layer-derived part, half-open rig band and positive four-neighbour path bound; base painting only). The optional integer floor 1–255 admits exact original alpha-over coverage strictly below it; absent or 1 blocks every nonzero holder. Only selected target samples below the floor may take painting RGBA; target samples at/above the floor and every non-target holder remain exact. By default overlapping reachable claims refuse. With `order` on every entry (unique nonnegative safe integers), lower values claim first and their gains block later candidates and paths; array order never breaks ties or supplies missing precedence
|
|
159
159
|
- **assemble.take[i]** — required: `run`, `run_dir`, `st_input`; optional: `tags`, `part`, `seed`, `reference`, `crop` (issues #866, #973, #1000, #1031). Whole-layer entries require `tags`; region entries require `part` and `seed`. An absent `reference` preserves the shipped `source: true` predicate and emits one named implicit-reference warning; only an explicitly declared painting reference makes the mask invariant to changes in `--source`
|
|
160
160
|
- **assemble.take[i].crop** — required when present: `box`, `resample` (issue #973, additive, whole-layer entries only). `box` is an inside nonempty integer source-painting `[left, top, right, bottom]` with exclusive right/bottom. `resample: "bilinear"` is required explicitly. Donor input must match the square-padded crop under taken support plus its margin. Unit scale and integer translation copy RGBA exactly; other maps use the declared premultiplied float32 affine filter. Absent, the shipped geometry predicate and refusal message remain unchanged. Region entries reject this field
|
|
161
|
-
- **assemble.take[i].reference** — required: `sha256`; optional: `source`, `painting` (issue #1031). Exactly one of `source: true` or a config-relative `painting` PNG is required
|
|
161
|
+
- **assemble.take[i].reference** — required: `sha256`; optional: `source`, `painting` (issue #1031). Exactly one of `source: true` or a config-relative `painting` PNG is required. The reference governs colour only and geometry follows `--source`. A region take requires an opaque `--source` because its donor must match the run input and the inputs command refuses see-through paintings, so flatten the plate first.
|
|
162
162
|
- **assemble.editor_receipts** — required: `receipts`; optional: `required` (issue #946, additive), `trace_parts` (issue #947, additive)
|
|
163
163
|
- **assemble.editor_receipts.receipts[i]** — required: `file`, `sha256`, `from_sha256`, `editor` (issue #946)
|
|
164
164
|
- **assemble.patches[i]** — required: `name`, `box`, `alpha`, `draw`
|
|
@@ -692,3 +692,10 @@ Other maps carry `"bilinear"`. The strict reader refuses incomplete or malformed
|
|
|
692
692
|
transport records. Absent, the existing receipt fields and bytes are unchanged.
|
|
693
693
|
The output hash describes transport before downstream assembly, independently of
|
|
694
694
|
final part geometry. Existing no-take inputs emit no transport metadata.
|
|
695
|
+
|
|
696
|
+
### Region take source compatibility (issue #1054)
|
|
697
|
+
|
|
698
|
+
A see-through `--source` with an opaque explicit painting reference was accepted
|
|
699
|
+
when donor geometry followed the reference and is now refused with
|
|
700
|
+
`INPUTS_PAINTING_OPAQUE` before the donor is read. The reference remains a colour
|
|
701
|
+
binding. The donor continues to be bound to the opaque PNG accepted by `inputs`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spine-parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/assemble.ts
CHANGED
|
@@ -2572,6 +2572,25 @@ export function visibilityCounts(object: string, part: Raster, visible: Mask, pr
|
|
|
2572
2572
|
return { visible_px: vis, occluded_px: occ, visible_not_projected_px: vis - proj, projected: proj };
|
|
2573
2573
|
}
|
|
2574
2574
|
|
|
2575
|
+
/** Reuse assembly's rig-sized painting only when its alpha is fully opaque.
|
|
2576
|
+
* Transparent inputs retain source-over-white before the Lanczos resize. */
|
|
2577
|
+
export function sourceSupportFigure(source: Raster, width: number, height: number, opaquePainting?: Raster): Mask {
|
|
2578
|
+
let painting = opaquePainting;
|
|
2579
|
+
for (let p = 3; painting !== undefined && p < source.data.length; p += 4) if (source.data[p] !== 255) painting = undefined;
|
|
2580
|
+
if (painting === undefined) {
|
|
2581
|
+
const white = newRaster(source.width, source.height);
|
|
2582
|
+
for (let p = 0; p < source.width * source.height; p++) {
|
|
2583
|
+
const alpha = source.data[p * 4 + 3] / 255;
|
|
2584
|
+
for (let c = 0; c < 3; c++) white.data[p * 4 + c] = Math.round(source.data[p * 4 + c] * alpha + 255 * (1 - alpha));
|
|
2585
|
+
white.data[p * 4 + 3] = 255;
|
|
2586
|
+
}
|
|
2587
|
+
painting = sourceInRig(white, width, height);
|
|
2588
|
+
}
|
|
2589
|
+
const painted = paintedFigure(painting), figure = figureSilhouette(painting, painted);
|
|
2590
|
+
for (let p = 0; p < painted.length; p++) figure.data[p] &= painted[p];
|
|
2591
|
+
return figure;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2575
2594
|
// ---------------------------------------------------------------------------
|
|
2576
2595
|
// step 5 — seam override
|
|
2577
2596
|
// ---------------------------------------------------------------------------
|
|
@@ -5691,6 +5710,7 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5691
5710
|
}
|
|
5692
5711
|
});
|
|
5693
5712
|
// Issue #953: under `visible`, the parts' visible edges are the painting's (`paintingEdges`); See-through keeps the hidden surface.
|
|
5713
|
+
const visibleFigure = projectRule === 'visible' ? sourceSupportFigure(source, W, H, srcr) : undefined;
|
|
5694
5714
|
const edged = new Map<string, Mask>();
|
|
5695
5715
|
let edgeReading: PaintingEdgeReading | null = null;
|
|
5696
5716
|
if (projectRule === 'visible') {
|
|
@@ -5714,6 +5734,7 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5714
5734
|
};
|
|
5715
5735
|
const e = paintingEdges(stack.map(onRig), srcr, {
|
|
5716
5736
|
painted: supportPainted,
|
|
5737
|
+
figure: visibleFigure,
|
|
5717
5738
|
...(input.ground === undefined ? {} : { ground: input.ground }),
|
|
5718
5739
|
editable: order.map((d) => !('patch' in d)),
|
|
5719
5740
|
keep: keepInOrder,
|
|
@@ -5912,8 +5933,8 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5912
5933
|
// read for ground coverage without changing the assembly silhouette.
|
|
5913
5934
|
let opaqueSource = true;
|
|
5914
5935
|
for (let p = 3; p < source.data.length; p += 4) if (source.data[p] !== 255) { opaqueSource = false; break; }
|
|
5915
|
-
const supportSilhouette = opaqueSource ? silhouette ?? figureSilhouette(srcr, supportPainted) : null;
|
|
5916
|
-
const supportFigure = supportSilhouette === null ? undefined : newMask(W, H);
|
|
5936
|
+
const supportSilhouette = opaqueSource && visibleFigure === undefined ? silhouette ?? figureSilhouette(srcr, supportPainted) : null;
|
|
5937
|
+
const supportFigure = visibleFigure ?? (supportSilhouette === null ? undefined : newMask(W, H));
|
|
5917
5938
|
if (supportFigure !== undefined && supportSilhouette !== null) for (let p = 0; p < supportPainted.length; p++) supportFigure.data[p] = supportSilhouette.data[p] & supportPainted[p];
|
|
5918
5939
|
return {
|
|
5919
5940
|
...(softOcclusion.length === 0 ? {} : { softOcclusion }),
|
package/src/coincideio.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** Pre-rig pair domains and actual textured setup observations (#998). */
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { sourceSupportFigure as supportFigure } from './assemble.ts';
|
|
5
5
|
import { officialRenderer, sourceSizeProblem, type CheckInputs } from './check.ts';
|
|
6
6
|
import { supportReport, unownedSupport, SUPPORT_GRID_CODE, type SupportPart, type SupportReport } from './coincide.ts';
|
|
7
7
|
import { refuseIfAny } from './errors.ts';
|
|
8
8
|
import { readPng } from './raster/png.ts';
|
|
9
|
-
import { assertBinary,
|
|
9
|
+
import { assertBinary, type Mask } from './raster/types.ts';
|
|
10
10
|
import { readSupportDomains } from './supportdomains.ts';
|
|
11
11
|
|
|
12
12
|
/** The setup candidate is already built by check. Only alpha callbacks are
|
|
@@ -59,21 +59,4 @@ export function observeSupport(build: string, input: CheckInputs, supportSource?
|
|
|
59
59
|
return report;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
* Transparent inputs retain source-over-white before the Lanczos resize. */
|
|
64
|
-
export function supportFigure(source: Raster, width: number, height: number, opaquePainting?: Raster): Mask {
|
|
65
|
-
let painting = opaquePainting;
|
|
66
|
-
for (let p = 3; painting !== undefined && p < source.data.length; p += 4) if (source.data[p] !== 255) painting = undefined;
|
|
67
|
-
if (painting === undefined) {
|
|
68
|
-
const white = newRaster(source.width, source.height);
|
|
69
|
-
for (let p = 0; p < source.width * source.height; p++) {
|
|
70
|
-
const alpha = source.data[p * 4 + 3] / 255;
|
|
71
|
-
for (let c = 0; c < 3; c++) white.data[p * 4 + c] = Math.round(source.data[p * 4 + c] * alpha + 255 * (1 - alpha));
|
|
72
|
-
white.data[p * 4 + 3] = 255;
|
|
73
|
-
}
|
|
74
|
-
painting = sourceInRig(white, width, height);
|
|
75
|
-
}
|
|
76
|
-
const painted = paintedFigure(painting), figure = figureSilhouette(painting, painted);
|
|
77
|
-
for (let p = 0; p < painted.length; p++) figure.data[p] &= painted[p];
|
|
78
|
-
return figure;
|
|
79
|
-
}
|
|
62
|
+
export { sourceSupportFigure as supportFigure } from './assemble.ts';
|
package/src/paintingedges.ts
CHANGED
|
@@ -173,6 +173,8 @@ export interface PaintingEdgeOptions {
|
|
|
173
173
|
* figure there, and taking the behind colour from it would take a painted line.
|
|
174
174
|
*/
|
|
175
175
|
painted: Uint8Array;
|
|
176
|
+
/** Canonical painted figure domain for completing allocated zero-alpha gaps. */
|
|
177
|
+
figure?: Mask;
|
|
176
178
|
/** Per part: whether the step may write it (false for a painting patch). */
|
|
177
179
|
editable: readonly boolean[];
|
|
178
180
|
keep?: ReadonlyArray<Mask | null>;
|
|
@@ -266,6 +268,7 @@ export function paintingEdges(parts: Raster[], srcr: Raster, options: PaintingEd
|
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
270
|
}
|
|
271
|
+
const fill: Array<[number, number]> = [];
|
|
269
272
|
// A painted pixel no part covers goes to the nearest part (ties to the one drawn in front); farther than the cap, it stays background.
|
|
270
273
|
{
|
|
271
274
|
const near: Uint8Array[] = [];
|
|
@@ -274,7 +277,6 @@ export function paintingEdges(parts: Raster[], srcr: Raster, options: PaintingEd
|
|
|
274
277
|
for (let p = 0; p < W * H; p++) if (owner[p] === k) set[p] = 1;
|
|
275
278
|
near.push(chebyshev(set, W, H, cap));
|
|
276
279
|
}
|
|
277
|
-
const fill: Array<[number, number]> = [];
|
|
278
280
|
for (let p = 0; p < W * H; p++) {
|
|
279
281
|
if (owner[p] !== -1 || options.painted[p] !== 1) continue;
|
|
280
282
|
// Busy ground: only where two parts' supports meet, and only to a part whose support holds the pixel.
|
|
@@ -307,6 +309,7 @@ export function paintingEdges(parts: Raster[], srcr: Raster, options: PaintingEd
|
|
|
307
309
|
const distOf = (label: number): Uint8Array => dist[label < 0 ? n : label];
|
|
308
310
|
const skipped: PaintingEdgeSkips = { cover: 0, contrast: 0, locked: 0, noBehind: 0, pieces: 0, mix: 0, support: 0 };
|
|
309
311
|
const decisions: Decision[] = [];
|
|
312
|
+
const locked = new Uint8Array(W * H);
|
|
310
313
|
let resolved = 0;
|
|
311
314
|
let unseparated = 0;
|
|
312
315
|
for (let y = 0; y < H; y++) {
|
|
@@ -346,6 +349,7 @@ export function paintingEdges(parts: Raster[], srcr: Raster, options: PaintingEd
|
|
|
346
349
|
(behind >= 0 && options.feathered?.[behind]?.data[p] === 1) ||
|
|
347
350
|
(behind >= 0 && options.movingPair?.(front, behind) === true)
|
|
348
351
|
) {
|
|
352
|
+
locked[p] = 1;
|
|
349
353
|
skipped.locked++;
|
|
350
354
|
continue;
|
|
351
355
|
}
|
|
@@ -610,8 +614,29 @@ export function paintingEdges(parts: Raster[], srcr: Raster, options: PaintingEd
|
|
|
610
614
|
for (const [p, v] of writes) {
|
|
611
615
|
d.set(v, p * 4);
|
|
612
616
|
changed[i].data[p] = 1;
|
|
613
|
-
options.written?.(i, p);
|
|
614
617
|
}
|
|
615
618
|
});
|
|
619
|
+
// Complete the existing allocation only where the final stack draws nothing.
|
|
620
|
+
// Read every candidate before writes, retaining a four-connected witness in
|
|
621
|
+
// the receiver's existing art and all authored soft/locked boundaries.
|
|
622
|
+
const restore = fill.filter(([p, front]) => {
|
|
623
|
+
if (options.figure?.data[p] !== 1 || !options.editable[front] || locked[p] === 1 ||
|
|
624
|
+
options.keep?.some(m => m?.data[p] === 1) || options.feathered?.some(m => m?.data[p] === 1) ||
|
|
625
|
+
(busy && !supports(front, p)) || parts.some(r => r.data[p * 4 + 3] > 0)) return false;
|
|
626
|
+
const d = parts[front].data, x = p % W;
|
|
627
|
+
return (x > 0 && d[(p - 1) * 4 + 3] > OPAQUE_ALPHA_ABOVE) ||
|
|
628
|
+
(x + 1 < W && d[(p + 1) * 4 + 3] > OPAQUE_ALPHA_ABOVE) ||
|
|
629
|
+
(p >= W && d[(p - W) * 4 + 3] > OPAQUE_ALPHA_ABOVE) ||
|
|
630
|
+
(p + W < W * H && d[(p + W) * 4 + 3] > OPAQUE_ALPHA_ABOVE);
|
|
631
|
+
});
|
|
632
|
+
for (const [p, front] of restore) {
|
|
633
|
+
const s = p * 4;
|
|
634
|
+
parts[front].data.set([srcr.data[s], srcr.data[s + 1], srcr.data[s + 2], 255], s);
|
|
635
|
+
changed[front].data[p] = 1;
|
|
636
|
+
}
|
|
637
|
+
planned.forEach((writes, i) => {
|
|
638
|
+
for (const p of writes.keys()) options.written?.(i, p);
|
|
639
|
+
});
|
|
640
|
+
for (const [p, front] of restore) if (!planned[front].has(p)) options.written?.(front, p);
|
|
616
641
|
return { changed, resolved, unseparated, skipped };
|
|
617
642
|
}
|
package/src/takeregion.ts
CHANGED
|
@@ -141,14 +141,14 @@ export function applyTakenRegions(runs: Runs, painting: Raster, cfg: AssembleCon
|
|
|
141
141
|
return refuse('ASSEMBLE_REGION_TAKE_REFERENCE_MATCH', at, `reference sha256 ${referenceHash}, expected ${reference.sha256}; reference ${referencePainting.width}x${referencePainting.height}, source ${painting.width}x${painting.height}; matching hash and painting dimensions are required`);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const inputs = makeInputs(
|
|
144
|
+
const inputs = makeInputs(painting, cfg, 'region take painting (--source must be opaque because geometry follows the run input and inputs refuses see-through paintings, flatten the plate first)');
|
|
145
145
|
const set = runs[declaration.run];
|
|
146
146
|
const donor = readLayers(resolve(dirname(resolve(configPath)), declaration.run_dir));
|
|
147
147
|
refuseIfAny(missingReceipts(receipts, editedRunImages(
|
|
148
148
|
{ full: donor, head: donor, single: true },
|
|
149
149
|
`region take "${declaration.run}:${declaration.part}" donor "${declaration.run_dir}" `,
|
|
150
150
|
)));
|
|
151
|
-
const target = declaration.run === 'head' ? inputs.head : runs.single && set.canvas.w !== set.canvas.h ?
|
|
151
|
+
const target = declaration.run === 'head' ? inputs.head : runs.single && set.canvas.w !== set.canvas.h ? painting : inputs.full;
|
|
152
152
|
let supplied: Raster;
|
|
153
153
|
try { supplied = readPng(resolve(dirname(resolve(configPath)), declaration.st_input)); }
|
|
154
154
|
catch { return refuse('ASSEMBLE_REGION_TAKE_GEOMETRY', at, `st_input "${declaration.st_input}" must name the original readable donor input PNG so its geometry can be checked`); }
|
|
@@ -161,11 +161,13 @@ export function applyTakenRegions(runs: Runs, painting: Raster, cfg: AssembleCon
|
|
|
161
161
|
if (base.depthSheet !== undefined || material.depthSheet !== undefined || [...set.hidden, ...donor.hidden].some(layer => layer.of === plan[2])) {
|
|
162
162
|
return refuse('ASSEMBLE_REGION_TAKE_BINDING', at, 'hidden companions or active depth sheets require independent region bindings; a part without those companions is required');
|
|
163
163
|
}
|
|
164
|
-
const
|
|
164
|
+
const colourInputs = reference === undefined ? inputs : makeInputs(referencePainting, cfg, 'region take reference');
|
|
165
|
+
const colourTarget = declaration.run === 'head' ? colourInputs.head! : target === painting ? referencePainting : colourInputs.full;
|
|
166
|
+
const source = resize(colourTarget, set.canvas.w, set.canvas.h, 'lanczos3');
|
|
165
167
|
const derived = deriveTakenRegion(base, material, source, declaration.seed, tolerance, at);
|
|
166
168
|
lists[declaration.run] = lists[declaration.run].map(layer => layer === base ? derived.layer : layer);
|
|
167
169
|
const reading: RegionReading = { part: declaration.part, run: declaration.run, run_dir: declaration.run_dir, ...derived.reading };
|
|
168
|
-
const pad = target ===
|
|
170
|
+
const pad = target === painting ? [0, 0] : declaration.run === 'head' ? inputs.headBox! : [-inputs.padLeft, -inputs.padTop];
|
|
169
171
|
const transform = { scale: [set.canvas.w / target.width, set.canvas.h / target.height], origin: [pad[0], pad[1]], filter: 'lanczos3' };
|
|
170
172
|
if (reference !== undefined) notes.push(`region reference ${reading.run}:${reading.part}: sha256 ${referenceHash}; binding ${'source' in reference ? 'source' : 'painting'}; painting-to-run ${JSON.stringify(transform)}`);
|
|
171
173
|
notes.push(`region take ${reading.run}:${reading.part} from ${reading.run_dir}: ${reading.pixels} run px; box [${reading.box.join(', ')}] (left, top, width, height); painting-match share ${reading.painting_match_share}; RGB tolerance ${reading.rgb_tolerance}; seed [${declaration.seed.join(', ')}], 8-connected`);
|