@pixerate/editor 0.214.0 → 0.216.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/dist/{chunk-UOGKSVRQ.cjs → chunk-B46UQUDC.cjs} +770 -733
- package/dist/{chunk-W3TOZTL7.js → chunk-F7Z2MKY2.js} +115 -4
- package/dist/{chunk-YBJXCQTR.js → chunk-QXY4YTRI.js} +738 -701
- package/dist/{chunk-H65IBXFI.cjs → chunk-S55JFWDA.cjs} +350 -239
- package/dist/{chunk-QYLWG22N.cjs → chunk-SS53NNZO.cjs} +304 -1
- package/dist/{chunk-LQ5SALHK.js → chunk-U7C655AM.js} +5 -311
- package/dist/{chunk-L52VMQZS.cjs → chunk-UC3PWFM3.cjs} +68 -374
- package/dist/{chunk-L3G23N5Y.js → chunk-ZNA3IQZF.js} +304 -1
- package/dist/image-editor/controller.d.cts +41 -0
- package/dist/image-editor/controller.d.ts +41 -0
- package/dist/image-editor/index.cjs +1461 -1125
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +384 -48
- package/dist/image-editor/layers/edge-color.d.cts +27 -0
- package/dist/image-editor/layers/edge-color.d.ts +27 -0
- package/dist/image-editor/layers/serialize.d.cts +13 -0
- package/dist/image-editor/layers/serialize.d.ts +13 -0
- package/dist/image-editor/selection/index.d.cts +1 -0
- package/dist/image-editor/selection/index.d.ts +1 -0
- package/dist/image-editor/selection/inspect.d.cts +9 -0
- package/dist/image-editor/selection/inspect.d.ts +9 -0
- package/dist/image-editor/selection/uncertainty.d.cts +40 -0
- package/dist/image-editor/selection/uncertainty.d.ts +40 -0
- package/dist/image-editor/selection-worker.cjs +4 -4
- package/dist/image-editor/selection-worker.js +2 -2
- package/dist/paint-editor/index.cjs +79 -79
- package/dist/paint-editor/index.js +3 -3
- package/dist/raster/compositor.d.cts +10 -1
- package/dist/raster/compositor.d.ts +10 -1
- package/dist/raster/deep-compositor.d.cts +1 -1
- package/dist/raster/deep-compositor.d.ts +1 -1
- package/dist/raster/index.cjs +4 -2
- package/dist/raster/index.js +3 -1
- package/dist/raster/layers.d.cts +16 -0
- package/dist/raster/layers.d.ts +16 -0
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +9 -7
- package/skills/pixerate-image-editor/references/paths.md +12 -0
- package/skills/pixerate-image-selection-masking/SKILL.md +11 -11
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge colour on a layer's soft edge (`LayerEdgeColor`): decontamination and despill, run over the
|
|
3
|
+
* canvas by the compositor from the layer's own pixels and its mask, so nothing is baked. The live
|
|
4
|
+
* edge cast (`ambient`) needs what is behind the layer and runs in the compositor's blend step.
|
|
5
|
+
*/
|
|
6
|
+
import type { LayerEdgeColor, RasterMask } from '../../raster/layers.cjs';
|
|
7
|
+
/** How far (px) the old background's colour is looked for around the edge. */
|
|
8
|
+
export declare const EDGE_COLOR_RADIUS = 8;
|
|
9
|
+
/** True when decontamination or despill is on (they need the layer's mask). */
|
|
10
|
+
export declare function hasEdgeUnmix(edge: LayerEdgeColor | undefined): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A mask's coverage (0..255) over the canvas, `width × height`, for a layer at `offset`: the
|
|
13
|
+
* painted mask with its feather (density only changes how much shows, not the matte).
|
|
14
|
+
*/
|
|
15
|
+
export declare function maskCoverageOverCanvas(mask: RasterMask, ox: number, oy: number, width: number, height: number): Uint8ClampedArray;
|
|
16
|
+
/** True when a coverage has a soft band (some pixels partly covered). */
|
|
17
|
+
export declare function hasSoftBand(coverage: ArrayLike<number>): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Despill: along a soft edge, takes out (by `amount`, 0..1) the part of each pixel's colour that
|
|
20
|
+
* points the way of the old background's hue (its local mean, from what is fully outside within
|
|
21
|
+
* `radius`). Luminance is kept, pixels fully in or out are unchanged, and the outer edge (more
|
|
22
|
+
* background) gets the most. It does not remove light that bounced onto the subject itself.
|
|
23
|
+
* Works in place on RGBA `rgba` with `coverage` (0..255) over the same `w × h`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function despillEdge(rgba: Uint8ClampedArray, coverage: ArrayLike<number>, w: number, h: number, amount: number, radius?: number): void;
|
|
26
|
+
/** Decontamination, then despill, of canvas RGBA `rgba` (`w × h`) in place, given the mask's coverage. */
|
|
27
|
+
export declare function applyEdgeUnmix(rgba: Uint8ClampedArray, coverage: ArrayLike<number>, w: number, h: number, edge: LayerEdgeColor): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge colour on a layer's soft edge (`LayerEdgeColor`): decontamination and despill, run over the
|
|
3
|
+
* canvas by the compositor from the layer's own pixels and its mask, so nothing is baked. The live
|
|
4
|
+
* edge cast (`ambient`) needs what is behind the layer and runs in the compositor's blend step.
|
|
5
|
+
*/
|
|
6
|
+
import type { LayerEdgeColor, RasterMask } from '../../raster/layers.js';
|
|
7
|
+
/** How far (px) the old background's colour is looked for around the edge. */
|
|
8
|
+
export declare const EDGE_COLOR_RADIUS = 8;
|
|
9
|
+
/** True when decontamination or despill is on (they need the layer's mask). */
|
|
10
|
+
export declare function hasEdgeUnmix(edge: LayerEdgeColor | undefined): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A mask's coverage (0..255) over the canvas, `width × height`, for a layer at `offset`: the
|
|
13
|
+
* painted mask with its feather (density only changes how much shows, not the matte).
|
|
14
|
+
*/
|
|
15
|
+
export declare function maskCoverageOverCanvas(mask: RasterMask, ox: number, oy: number, width: number, height: number): Uint8ClampedArray;
|
|
16
|
+
/** True when a coverage has a soft band (some pixels partly covered). */
|
|
17
|
+
export declare function hasSoftBand(coverage: ArrayLike<number>): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Despill: along a soft edge, takes out (by `amount`, 0..1) the part of each pixel's colour that
|
|
20
|
+
* points the way of the old background's hue (its local mean, from what is fully outside within
|
|
21
|
+
* `radius`). Luminance is kept, pixels fully in or out are unchanged, and the outer edge (more
|
|
22
|
+
* background) gets the most. It does not remove light that bounced onto the subject itself.
|
|
23
|
+
* Works in place on RGBA `rgba` with `coverage` (0..255) over the same `w × h`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function despillEdge(rgba: Uint8ClampedArray, coverage: ArrayLike<number>, w: number, h: number, amount: number, radius?: number): void;
|
|
26
|
+
/** Decontamination, then despill, of canvas RGBA `rgba` (`w × h`) in place, given the mask's coverage. */
|
|
27
|
+
export declare function applyEdgeUnmix(rgba: Uint8ClampedArray, coverage: ArrayLike<number>, w: number, h: number, edge: LayerEdgeColor): void;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema version 3 of the image editor document: the layer tree, with pixel layers and painted
|
|
3
|
+
* masks stored as PNG assets (cropped to their content and placed by position), plus the
|
|
4
|
+
* document-level crop, transform, output opacity, migrated blur and selection.
|
|
5
|
+
*
|
|
6
|
+
* Encoding is synchronous and exact (see `png.ts`). Each surface's encoding is memoised, so
|
|
7
|
+
* saving an unchanged layer again costs nothing.
|
|
8
|
+
*/
|
|
9
|
+
import type { LayerEdgeColor } from '../../raster/layers.cjs';
|
|
1
10
|
import type { SerializedDocumentPath } from '../paths.cjs';
|
|
2
11
|
import type { Annotation, CropBox, DepthMaskOptions, ImageTransform } from '../types.cjs';
|
|
3
12
|
import type { SerializedSelection } from '../selection/mask.cjs';
|
|
@@ -36,6 +45,8 @@ interface SerializedLayerBase {
|
|
|
36
45
|
vectorMask?: SerializedVectorMask;
|
|
37
46
|
locks?: LayerLocks;
|
|
38
47
|
effects?: SerializedLayerEffects;
|
|
48
|
+
/** Edge colour amounts 0..1 and the cast colour (see `LayerEdgeColor`). */
|
|
49
|
+
edge?: LayerEdgeColor;
|
|
39
50
|
}
|
|
40
51
|
/** A stored vector mask: its components as JSON (document pixels) and its properties. */
|
|
41
52
|
export interface SerializedVectorMask {
|
|
@@ -271,6 +282,8 @@ export interface SerializeContext {
|
|
|
271
282
|
/** Stores a smart object's contents (once per id). Without it, smart objects cannot be written. */
|
|
272
283
|
addContents?(contents: SmartContents): void;
|
|
273
284
|
}
|
|
285
|
+
/** Stored edge colour, with amounts clamped to 0..1 (none when nothing is on). */
|
|
286
|
+
export declare function readEdgeColor(raw: unknown): LayerEdgeColor | undefined;
|
|
274
287
|
export declare function serializeEffects(effects: LayerEffects): SerializedLayerEffects;
|
|
275
288
|
/** Reads stored effects (leniently: broken effects are dropped), or `undefined`. */
|
|
276
289
|
export declare function deserializeEffects(raw: unknown): LayerEffects | undefined;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema version 3 of the image editor document: the layer tree, with pixel layers and painted
|
|
3
|
+
* masks stored as PNG assets (cropped to their content and placed by position), plus the
|
|
4
|
+
* document-level crop, transform, output opacity, migrated blur and selection.
|
|
5
|
+
*
|
|
6
|
+
* Encoding is synchronous and exact (see `png.ts`). Each surface's encoding is memoised, so
|
|
7
|
+
* saving an unchanged layer again costs nothing.
|
|
8
|
+
*/
|
|
9
|
+
import type { LayerEdgeColor } from '../../raster/layers.js';
|
|
1
10
|
import type { SerializedDocumentPath } from '../paths.js';
|
|
2
11
|
import type { Annotation, CropBox, DepthMaskOptions, ImageTransform } from '../types.js';
|
|
3
12
|
import type { SerializedSelection } from '../selection/mask.js';
|
|
@@ -36,6 +45,8 @@ interface SerializedLayerBase {
|
|
|
36
45
|
vectorMask?: SerializedVectorMask;
|
|
37
46
|
locks?: LayerLocks;
|
|
38
47
|
effects?: SerializedLayerEffects;
|
|
48
|
+
/** Edge colour amounts 0..1 and the cast colour (see `LayerEdgeColor`). */
|
|
49
|
+
edge?: LayerEdgeColor;
|
|
39
50
|
}
|
|
40
51
|
/** A stored vector mask: its components as JSON (document pixels) and its properties. */
|
|
41
52
|
export interface SerializedVectorMask {
|
|
@@ -271,6 +282,8 @@ export interface SerializeContext {
|
|
|
271
282
|
/** Stores a smart object's contents (once per id). Without it, smart objects cannot be written. */
|
|
272
283
|
addContents?(contents: SmartContents): void;
|
|
273
284
|
}
|
|
285
|
+
/** Stored edge colour, with amounts clamped to 0..1 (none when nothing is on). */
|
|
286
|
+
export declare function readEdgeColor(raw: unknown): LayerEdgeColor | undefined;
|
|
274
287
|
export declare function serializeEffects(effects: LayerEffects): SerializedLayerEffects;
|
|
275
288
|
/** Reads stored effects (leniently: broken effects are dropped), or `undefined`. */
|
|
276
289
|
export declare function deserializeEffects(raw: unknown): LayerEffects | undefined;
|
|
@@ -68,3 +68,12 @@ export declare function inspectMaskEdge(mask: SelectionMask, image: PixelBuffer
|
|
|
68
68
|
x: number;
|
|
69
69
|
y: number;
|
|
70
70
|
}, options?: InspectMaskEdgeOptions): MaskEdgeReport;
|
|
71
|
+
/**
|
|
72
|
+
* A cached sampler of the image's edge strength at document pixels: the Sobel magnitude of
|
|
73
|
+
* alpha-weighted R, G and B, the largest of the three, as a fraction of a full 0–255 step.
|
|
74
|
+
* Reads clamp at the image's edges. `W` is the canvas width (for the cache key).
|
|
75
|
+
*/
|
|
76
|
+
export declare function createGradientSampler(image: PixelBuffer & {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
}, W: number): (x: number, y: number) => number;
|
|
@@ -68,3 +68,12 @@ export declare function inspectMaskEdge(mask: SelectionMask, image: PixelBuffer
|
|
|
68
68
|
x: number;
|
|
69
69
|
y: number;
|
|
70
70
|
}, options?: InspectMaskEdgeOptions): MaskEdgeReport;
|
|
71
|
+
/**
|
|
72
|
+
* A cached sampler of the image's edge strength at document pixels: the Sobel magnitude of
|
|
73
|
+
* alpha-weighted R, G and B, the largest of the three, as a fraction of a full 0–255 step.
|
|
74
|
+
* Reads clamp at the image's edges. `W` is the canvas width (for the cache key).
|
|
75
|
+
*/
|
|
76
|
+
export declare function createGradientSampler(image: PixelBuffer & {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
}, W: number): (x: number, y: number) => number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a selection is unsure of itself (a trimap's unknown band): the stretches of its edge that
|
|
3
|
+
* run where the image shows no edge, widened into a band. The smart selection tools report these
|
|
4
|
+
* as `uncertainRegions`, so an agent looks at and refines only them (`refine_selection` `regions`).
|
|
5
|
+
*/
|
|
6
|
+
import type { CropBox } from '../types.cjs';
|
|
7
|
+
import { type PixelBuffer, type SelectionMask } from './mask.cjs';
|
|
8
|
+
export interface UncertainRegion {
|
|
9
|
+
bounds: CropBox;
|
|
10
|
+
/** Pixels in the unknown band. */
|
|
11
|
+
area: number;
|
|
12
|
+
/** 0–1: how strongly the image backs the edge here (low = unsure). */
|
|
13
|
+
confidence: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SelectionUncertainty {
|
|
16
|
+
/** The unknown band over the canvas (255 = unsure). */
|
|
17
|
+
unknown: SelectionMask;
|
|
18
|
+
/** The least confident regions first (at most `maxRegions`). */
|
|
19
|
+
regions: UncertainRegion[];
|
|
20
|
+
/** How many regions there are in all. */
|
|
21
|
+
count: number;
|
|
22
|
+
/** 0–1 over the whole edge. */
|
|
23
|
+
confidence: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SelectionUncertaintyOptions {
|
|
26
|
+
/** Half-width of the unknown band in px (default 1/200 of the shorter side, at least 2). */
|
|
27
|
+
band?: number;
|
|
28
|
+
/** Regions smaller than this many pixels are left out (default 16). */
|
|
29
|
+
minArea?: number;
|
|
30
|
+
/** At most this many regions are listed (default 20). */
|
|
31
|
+
maxRegions?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The unknown band of `mask` against `image` (RGBA, straight alpha, at `image.x`, `image.y` in
|
|
35
|
+
* document pixels). An empty selection has no band.
|
|
36
|
+
*/
|
|
37
|
+
export declare function selectionUncertainty(mask: SelectionMask, image: PixelBuffer & {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}, options?: SelectionUncertaintyOptions): SelectionUncertainty;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a selection is unsure of itself (a trimap's unknown band): the stretches of its edge that
|
|
3
|
+
* run where the image shows no edge, widened into a band. The smart selection tools report these
|
|
4
|
+
* as `uncertainRegions`, so an agent looks at and refines only them (`refine_selection` `regions`).
|
|
5
|
+
*/
|
|
6
|
+
import type { CropBox } from '../types.js';
|
|
7
|
+
import { type PixelBuffer, type SelectionMask } from './mask.js';
|
|
8
|
+
export interface UncertainRegion {
|
|
9
|
+
bounds: CropBox;
|
|
10
|
+
/** Pixels in the unknown band. */
|
|
11
|
+
area: number;
|
|
12
|
+
/** 0–1: how strongly the image backs the edge here (low = unsure). */
|
|
13
|
+
confidence: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SelectionUncertainty {
|
|
16
|
+
/** The unknown band over the canvas (255 = unsure). */
|
|
17
|
+
unknown: SelectionMask;
|
|
18
|
+
/** The least confident regions first (at most `maxRegions`). */
|
|
19
|
+
regions: UncertainRegion[];
|
|
20
|
+
/** How many regions there are in all. */
|
|
21
|
+
count: number;
|
|
22
|
+
/** 0–1 over the whole edge. */
|
|
23
|
+
confidence: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SelectionUncertaintyOptions {
|
|
26
|
+
/** Half-width of the unknown band in px (default 1/200 of the shorter side, at least 2). */
|
|
27
|
+
band?: number;
|
|
28
|
+
/** Regions smaller than this many pixels are left out (default 16). */
|
|
29
|
+
minArea?: number;
|
|
30
|
+
/** At most this many regions are listed (default 20). */
|
|
31
|
+
maxRegions?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The unknown band of `mask` against `image` (RGBA, straight alpha, at `image.x`, `image.y` in
|
|
35
|
+
* document pixels). An empty selection has no band.
|
|
36
|
+
*/
|
|
37
|
+
export declare function selectionUncertainty(mask: SelectionMask, image: PixelBuffer & {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}, options?: SelectionUncertaintyOptions): SelectionUncertainty;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var _chunkUC3PWFM3cjs = require('../chunk-UC3PWFM3.cjs');
|
|
4
|
+
require('../chunk-SS53NNZO.cjs');
|
|
5
5
|
require('../chunk-K6PXS6DO.cjs');
|
|
6
6
|
require('../chunk-MQDIP4CF.cjs');
|
|
7
7
|
require('../chunk-474IQG74.cjs');
|
|
8
8
|
|
|
9
9
|
// src/image-editor/selection-worker.ts
|
|
10
10
|
if (typeof self !== "undefined" && typeof window === "undefined" && typeof self.postMessage === "function") {
|
|
11
|
-
|
|
11
|
+
_chunkUC3PWFM3cjs.startSelectionWorker.call(void 0, self);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.startSelectionWorker =
|
|
15
|
+
exports.startSelectionWorker = _chunkUC3PWFM3cjs.startSelectionWorker;
|