Let pixel art and vector art be nine-sliced and sorted (#308)
Nine-slice and the sort line hung on the texture frame alone. Drawing and sorting already read both off the TextureRef every picture hands out, but the generated pictures always said "no slice, no line". So the feature moves from the frame to the picture, without a second copy of any rule. - PictureCut (border, fill, sortLine) is one type. TextureFrame extends it, PixelArtAsset and VectorArtAsset carry it as a whole. The texture file format does not change, and no migration is needed. - The rules in texture.ts take a cut and a size: cutSortLine, setCutSlice, rawCutSlice and the rest replace the frame* versions. serialize.ts reads all three through one readCut. - cutTarget.ts resolves a target to cut and size: a texture frame, a pixel frame's size or the vector canvas. It lives apart from texture.ts because vectorart.ts reaches texture.ts itself. - SetSliceCommand and SetSortLineCommand take that target instead of (assetId, frameId). They refuse an asset that draws no picture. - generatedRef fills slice and sortLine from the drawing. The whole strip of a pixel art asset with several frames gets none, it is no picture of that size. With one frame asset and frame are the same. - Nine-slice scale is one shared schema row, now also on pixel art and vector art. - cutSection.ts holds the NINE-SLICE and SORTING rows once. The frame inspector and the drawing inspector both build them. - SheetCanvas draws a drawing's lines that are set, dashed as in the Texture tab. They are not dragged there, the painting tools own the canvas (as proposed in the issue). - drawOrder falls back to the picture's height when a ref has no rect, or a sort line on vector art would have been ignored. Tests: - Gate: 232 files, 3542 tests (+8: drawing-cut.test.ts, and vector art in sort-by-y.test.ts). Three counter-proofs bite: no cut on a drawing, a cut on the whole strip, no height fallback. - e2e 48: 44 checks (+1, sum 1732). 48l-ii reads red and blue where 12-pixel borders at scale 2 put them. Without borders both spots read green. - Looked at: the Pixel art tab with the lines, and the sliced sprite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9c6bbfa4d
commit
3e05cbbed5
20 files changed
+666
-300
No files matched your search
@@ -444,6 +444,16 @@ function filterRow(smoothByDefault: boolean): PropertyDef {
|
||||
};
|
||||
}
|
||||
|
||||
/** How big the borders of a sliced picture are drawn: 2 makes a 16 px border 32 units wide (#96). */
|
||||
const SLICE_SCALE_ROW: PropertyDef = {
|
||||
key: SLICE_SCALE_KEY,
|
||||
label: 'Nine-slice scale',
|
||||
kind: 'number',
|
||||
default: 1,
|
||||
min: 0.01,
|
||||
step: 0.1,
|
||||
};
|
||||
|
||||
/** Position is deliberately absent: it belongs to scene objects, not to asset types. */
|
||||
const ASSET_SCHEMAS: Record<AssetType, PropertySchema> = {
|
||||
scene: [
|
||||
@@ -481,11 +491,7 @@ const ASSET_SCHEMAS: Record<AssetType, PropertySchema> = {
|
||||
{ key: SHADER_KEY, label: 'Shader', kind: 'asset', default: '', assetTypes: ['shader'] },
|
||||
],
|
||||
// The picture itself is intrinsic data on the asset (see TextureAsset), not a property.
|
||||
texture: [
|
||||
filterRow(true),
|
||||
// How big the borders of every sliced frame are drawn: 2 makes a 16 px border 32 units wide (#96).
|
||||
{ key: SLICE_SCALE_KEY, label: 'Nine-slice scale', kind: 'number', default: 1, min: 0.01, step: 0.1 },
|
||||
],
|
||||
texture: [filterRow(true), SLICE_SCALE_ROW],
|
||||
// The shapes are intrinsic data on the asset (see VectorArtAsset); these three say how big the
|
||||
// picture they are drawn onto is and how it is sampled – the same `filter` row a texture has,
|
||||
// because a generated picture goes through the same path (#185).
|
||||
@@ -511,12 +517,14 @@ const ASSET_SCHEMAS: Record<AssetType, PropertySchema> = {
|
||||
decimals: 0,
|
||||
},
|
||||
filterRow(true),
|
||||
SLICE_SCALE_ROW,
|
||||
],
|
||||
// Layers, frames and the canvas size are intrinsic data on the asset (see PixelArtAsset). A palette
|
||||
// is shared, so the asset names one; the filter is the texture's row, sharp by default for pixels.
|
||||
pixelart: [
|
||||
{ key: PALETTE_KEY, label: 'Palette', kind: 'asset', default: '', assetTypes: ['palette'] },
|
||||
filterRow(false),
|
||||
SLICE_SCALE_ROW,
|
||||
],
|
||||
// The colours are intrinsic data on the asset (see PaletteAsset).
|
||||
palette: [],
|
||||
|
||||
Reference in new issue
Block a user