@pixerate/editor 0.183.0 → 0.185.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-UHMSMUHK.cjs → chunk-C6TRAAG4.cjs} +3 -1
- package/dist/{chunk-Y46OMERN.js → chunk-GYYSPMVU.js} +3 -1
- package/dist/image-editor/controller.d.cts +152 -8
- package/dist/image-editor/controller.d.ts +152 -8
- package/dist/image-editor/index.cjs +1986 -832
- package/dist/image-editor/index.js +1209 -55
- package/dist/image-editor/layers/panel.d.cts +23 -1
- package/dist/image-editor/layers/panel.d.ts +23 -1
- package/dist/image-editor/selection/gesture.d.cts +40 -2
- package/dist/image-editor/selection/gesture.d.ts +40 -2
- 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/modify.d.cts +3 -2
- package/dist/image-editor/selection/modify.d.ts +3 -2
- package/dist/image-editor/selection/stroke.d.cts +8 -0
- package/dist/image-editor/selection/stroke.d.ts +8 -0
- package/dist/image-editor/selection/tool-options.d.cts +12 -2
- package/dist/image-editor/selection/tool-options.d.ts +12 -2
- package/dist/image-editor/selection/wand.d.cts +37 -0
- package/dist/image-editor/selection/wand.d.ts +37 -0
- package/dist/image-editor/selection-tools.d.cts +8 -3
- package/dist/image-editor/selection-tools.d.ts +8 -3
- package/dist/image-editor/tools.d.cts +8 -2
- package/dist/image-editor/tools.d.ts +8 -2
- package/dist/image-editor/types.d.cts +2 -0
- package/dist/image-editor/types.d.ts +2 -0
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.js +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +12 -21
- package/skills/pixerate-image-editor/references/free-transform.md +22 -0
- package/skills/pixerate-image-selection-masking/SKILL.md +23 -2
|
@@ -1192,7 +1192,7 @@ function shiftCoverage(src, w, h, amount) {
|
|
|
1192
1192
|
for (let i = 0; i < lo.length; i++) lo[i] += (hi[i] - lo[i]) * frac;
|
|
1193
1193
|
return lo;
|
|
1194
1194
|
}
|
|
1195
|
-
var SELECTION_MODIFY_OPS = ["
|
|
1195
|
+
var SELECTION_MODIFY_OPS = ["expand", "contract", "feather", "border", "smooth", "grow", "shrink"];
|
|
1196
1196
|
function wrap(mask, coverage) {
|
|
1197
1197
|
const out = new Uint8Array(coverage.length);
|
|
1198
1198
|
for (let i = 0; i < out.length; i++) out[i] = coverageToByte(coverage[i]);
|
|
@@ -1204,8 +1204,10 @@ function modifySelection(mask, op, radius) {
|
|
|
1204
1204
|
const m = selectionToCoverage(mask);
|
|
1205
1205
|
const { width: w, height: h } = mask;
|
|
1206
1206
|
switch (op) {
|
|
1207
|
+
case "expand":
|
|
1207
1208
|
case "grow":
|
|
1208
1209
|
return wrap(mask, expandCoverage(m, w, h, r));
|
|
1210
|
+
case "contract":
|
|
1209
1211
|
case "shrink":
|
|
1210
1212
|
return wrap(mask, contractCoverage(m, w, h, r));
|
|
1211
1213
|
case "feather":
|
|
@@ -1192,7 +1192,7 @@ function shiftCoverage(src, w, h, amount) {
|
|
|
1192
1192
|
for (let i = 0; i < lo.length; i++) lo[i] += (hi[i] - lo[i]) * frac;
|
|
1193
1193
|
return lo;
|
|
1194
1194
|
}
|
|
1195
|
-
var SELECTION_MODIFY_OPS = ["
|
|
1195
|
+
var SELECTION_MODIFY_OPS = ["expand", "contract", "feather", "border", "smooth", "grow", "shrink"];
|
|
1196
1196
|
function wrap(mask, coverage) {
|
|
1197
1197
|
const out = new Uint8Array(coverage.length);
|
|
1198
1198
|
for (let i = 0; i < out.length; i++) out[i] = coverageToByte(coverage[i]);
|
|
@@ -1204,8 +1204,10 @@ function modifySelection(mask, op, radius) {
|
|
|
1204
1204
|
const m = selectionToCoverage(mask);
|
|
1205
1205
|
const { width: w, height: h } = mask;
|
|
1206
1206
|
switch (op) {
|
|
1207
|
+
case "expand":
|
|
1207
1208
|
case "grow":
|
|
1208
1209
|
return wrap(mask, expandCoverage(m, w, h, r));
|
|
1210
|
+
case "contract":
|
|
1209
1211
|
case "shrink":
|
|
1210
1212
|
return wrap(mask, contractCoverage(m, w, h, r));
|
|
1211
1213
|
case "feather":
|
|
@@ -4,11 +4,11 @@ import { type BlendMode } from './blend.cjs';
|
|
|
4
4
|
import type { ImageHistogram } from './histogram.cjs';
|
|
5
5
|
import { type PixelBuffer, type SelectionChannel, type SelectionMask, type SelectionMode } from './selection/mask.cjs';
|
|
6
6
|
import { type ShapeSelectionOptions } from './selection/shapes.cjs';
|
|
7
|
-
import { type ColorRangeOptions, type ColorRangeSample, type MagicWandOptions } from './selection/wand.cjs';
|
|
7
|
+
import { type GrowSimilarOptions, type ColorRangeOptions, type ColorRangePreset, type ColorRangeSample, type MagicWandOptions } from './selection/wand.cjs';
|
|
8
8
|
import { type SelectionModifyOp } from './selection/modify.cjs';
|
|
9
9
|
import { type SegmentationProvider } from './selection/segmentation.cjs';
|
|
10
10
|
import { type RefineEdgeParams } from './selection/refine.cjs';
|
|
11
|
-
import type
|
|
11
|
+
import { type LayerMaskProps } from './selection/layer-mask.cjs';
|
|
12
12
|
import type { AdjustmentLayerMask } from './types.cjs';
|
|
13
13
|
import { type LayerBlendMode, type ImageLayer, type LayerFilter, type LayerTarget, type PixelLayer, type RasterMask, type SmartContents, type SmartFilter, type SmartPlacement, type LiveShape, type ShapeFillRule, type ShapeOperation, type ShapePaint, type ShapeStroke, type ParagraphStyle, type TextStyle, type TypeLayer, type ImageEffectAnimation } from './layers/model.cjs';
|
|
14
14
|
import { type TextLayout, type TextShaper } from './layers/text.cjs';
|
|
@@ -107,7 +107,11 @@ export interface SelectionCommandOptions {
|
|
|
107
107
|
mode?: SelectionMode;
|
|
108
108
|
/** Feather the new shape by this many pixels before combining (default 0). */
|
|
109
109
|
feather?: number;
|
|
110
|
+
/** Invert the new shape before combining (Color Range › Invert; default false). */
|
|
111
|
+
invert?: boolean;
|
|
110
112
|
}
|
|
113
|
+
/** How the canvas shows the selection: marching ants, a Quick Mask tint, or not at all. */
|
|
114
|
+
export type SelectionDisplay = 'ants' | 'quickMask' | 'none';
|
|
111
115
|
/** Where an AI result goes (see `applyInpaintedImage`, `applyBackgroundRemovedImage`). */
|
|
112
116
|
export interface AIResultOptions {
|
|
113
117
|
/** `new-layer`: a new layer (inpainting) or a mask (background removal); `replace`: the Background's pixels. Default: by `isMultiLayer`. */
|
|
@@ -133,6 +137,11 @@ export interface AdjustmentLayerInit<K extends AdjustmentKind = AdjustmentKind>
|
|
|
133
137
|
aboveId?: string;
|
|
134
138
|
/** Put the new layer at the top of this group. */
|
|
135
139
|
parentId?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Mask the new layer with the selection when there is one and no `mask` is given (Photoshop's
|
|
142
|
+
* behaviour). Default false here, for compatibility; the agent tool and the panels pass true.
|
|
143
|
+
*/
|
|
144
|
+
useSelection?: boolean;
|
|
136
145
|
}
|
|
137
146
|
/** A new pixel layer: empty, a solid colour over the canvas, or given pixels, plus its properties and position. */
|
|
138
147
|
export interface PixelLayerInit extends LayerPlacement {
|
|
@@ -345,6 +354,31 @@ export interface FillOptions {
|
|
|
345
354
|
/** Limit to the selection when there is one (default true). */
|
|
346
355
|
useSelection?: boolean;
|
|
347
356
|
}
|
|
357
|
+
/** Edit › Stroke (see `strokeSelection`). */
|
|
358
|
+
export interface StrokeSelectionOptions extends Omit<FillOptions, 'useSelection'> {
|
|
359
|
+
/** Width of the band in pixels (0 < width ≤ 250). */
|
|
360
|
+
width: number;
|
|
361
|
+
/** Where the band lies against the selection edge (default `outside`). */
|
|
362
|
+
location?: 'inside' | 'center' | 'outside';
|
|
363
|
+
}
|
|
364
|
+
/** Edit › Content-Aware Fill (see `contentAwareFill`). */
|
|
365
|
+
export interface ContentAwareFillOptions {
|
|
366
|
+
/** The pixel layer to sample and fill (default the active layer). */
|
|
367
|
+
layerId?: string;
|
|
368
|
+
/** `current` (default) paints into the layer; `new-layer` puts the fill on a new layer above it. */
|
|
369
|
+
output?: 'current' | 'new-layer';
|
|
370
|
+
/** How far around the selection to sample, in pixels (default its larger side, at least 32). */
|
|
371
|
+
sampleRadius?: number;
|
|
372
|
+
/** Random seed: the same seed gives the same fill (default 0). */
|
|
373
|
+
seed?: number;
|
|
374
|
+
}
|
|
375
|
+
/** Pixels on the editor's clipboard: RGBA, and where they were copied from (document pixels). */
|
|
376
|
+
export interface ClipboardImage extends PixelBuffer {
|
|
377
|
+
x?: number;
|
|
378
|
+
y?: number;
|
|
379
|
+
}
|
|
380
|
+
export type PasteMode = 'new-layer' | 'in-place' | 'into' | 'outside';
|
|
381
|
+
export declare const PASTE_MODES: readonly PasteMode[];
|
|
348
382
|
/** What a stroke, fill or clear changed. */
|
|
349
383
|
export interface PaintStrokeResult {
|
|
350
384
|
layerId: string;
|
|
@@ -595,10 +629,13 @@ export declare class ImageEditorController {
|
|
|
595
629
|
enabled?: boolean;
|
|
596
630
|
blend?: string;
|
|
597
631
|
opacity?: number;
|
|
632
|
+
/** Limit the filter to the selection (sets the filter mask from it, same undo step). Default false. */
|
|
633
|
+
useSelection?: boolean;
|
|
598
634
|
}): Promise<{
|
|
599
635
|
layerId: string;
|
|
600
636
|
filter: SmartFilter;
|
|
601
637
|
converted: boolean;
|
|
638
|
+
masked: boolean;
|
|
602
639
|
}>;
|
|
603
640
|
/**
|
|
604
641
|
* Changes an effect smart filter: `values` merged over its own (`null` resets a control to the
|
|
@@ -668,6 +705,14 @@ export declare class ImageEditorController {
|
|
|
668
705
|
private stack;
|
|
669
706
|
private captureHistoryEntry;
|
|
670
707
|
private restoreHistoryEntry;
|
|
708
|
+
/** Set while `asOneStep` runs: the step is already recorded, so nested commands add none. */
|
|
709
|
+
private historyGrouped;
|
|
710
|
+
/**
|
|
711
|
+
* Runs `fn` as one undo step: history is recorded once, before it, and the commands it calls
|
|
712
|
+
* record none. If `fn` throws, the step is dropped and the state goes back to before it, so a
|
|
713
|
+
* failure never leaves half a change.
|
|
714
|
+
*/
|
|
715
|
+
private asOneStep;
|
|
671
716
|
private recordHistory;
|
|
672
717
|
/**
|
|
673
718
|
* Bytes of pixel tiles held only by undo / redo steps (not by the current state). The oldest
|
|
@@ -824,11 +869,12 @@ export declare class ImageEditorController {
|
|
|
824
869
|
bounds: CropBox | null;
|
|
825
870
|
};
|
|
826
871
|
/**
|
|
827
|
-
* Adds a mask to a layer (one undo step): `reveal-all` (white), `hide-all` (black)
|
|
828
|
-
* `selection` (the selection's coverage)
|
|
872
|
+
* Adds a mask to a layer (one undo step): `reveal-all` (white), `hide-all` (black),
|
|
873
|
+
* `selection` (the selection's coverage), `hide-selection` (its inverse) or `transparency`
|
|
874
|
+
* (the layer's own alpha, so the pixels can then be made opaque and edited). Replaces an existing mask. Makes the mask the paint
|
|
829
875
|
* target when the layer is active.
|
|
830
876
|
*/
|
|
831
|
-
addLayerMask(id: string, from?: 'reveal-all' | 'hide-all' | 'selection', props?: LayerMaskProps): RasterMask;
|
|
877
|
+
addLayerMask(id: string, from?: 'reveal-all' | 'hide-all' | 'selection' | 'hide-selection' | 'transparency', props?: LayerMaskProps): RasterMask;
|
|
832
878
|
/** Removes a layer's mask (one undo step). */
|
|
833
879
|
removeLayerMask(id: string): void;
|
|
834
880
|
/** Changes any layer mask's density, feather, enabled or linked flag (pixels kept). Returns the mask. */
|
|
@@ -978,7 +1024,14 @@ export declare class ImageEditorController {
|
|
|
978
1024
|
/** Adds a smart filter (`develop` or `blur`, with `blend` and `opacity`) at `index` (default the top), as one undo step. */
|
|
979
1025
|
addSmartFilter(id: string, filter: Record<string, unknown> & {
|
|
980
1026
|
kind: string;
|
|
981
|
-
}, index?: number
|
|
1027
|
+
}, index?: number, options?: {
|
|
1028
|
+
useSelection?: boolean;
|
|
1029
|
+
}): SmartFilter;
|
|
1030
|
+
/**
|
|
1031
|
+
* After adding a smart filter: with `useSelection` and a selection, sets the filter mask from
|
|
1032
|
+
* it in the same undo step (Photoshop limits a filter to the selection). Returns whether it did.
|
|
1033
|
+
*/
|
|
1034
|
+
private maskFiltersWithSelection;
|
|
982
1035
|
/** Changes one smart filter (one undo step, or none with `commitToHistory = false` during a drag). */
|
|
983
1036
|
updateSmartFilter(id: string, filterId: string, changes: Record<string, unknown>, commitToHistory?: boolean): SmartFilter;
|
|
984
1037
|
/** Removes one smart filter (one undo step). Returns the remaining filters. */
|
|
@@ -1182,6 +1235,59 @@ export declare class ImageEditorController {
|
|
|
1182
1235
|
* whole canvas. One undo step. Returns the changed bounds.
|
|
1183
1236
|
*/
|
|
1184
1237
|
clearPixels(options?: Omit<FillOptions, 'color' | 'blend'>): PaintStrokeResult;
|
|
1238
|
+
/**
|
|
1239
|
+
* Edit › Stroke: paints a band `width` px wide along the selection's edge, `inside` it, on the
|
|
1240
|
+
* `center` of the edge or `outside` it (default), with `color` (default the foreground),
|
|
1241
|
+
* `opacity` and `blend`, on a layer's pixels or mask. One undo step. Returns the changed bounds.
|
|
1242
|
+
*/
|
|
1243
|
+
strokeSelection(options: StrokeSelectionOptions): PaintStrokeResult;
|
|
1244
|
+
/**
|
|
1245
|
+
* Image › Crop to the selection's bounds (one undo step). Returns the crop box (natural
|
|
1246
|
+
* pixels). Throws without a selection.
|
|
1247
|
+
*/
|
|
1248
|
+
cropToSelection(): CropBox;
|
|
1249
|
+
/**
|
|
1250
|
+
* Edit › Content-Aware Fill: fills the selection with texture synthesised from around it
|
|
1251
|
+
* (PatchMatch, as the Spot Healing Brush's content-aware mode), blended by the selection's
|
|
1252
|
+
* coverage. `output` `current` paints into the layer; `new-layer` puts the fill on a new layer
|
|
1253
|
+
* above it. Samples within `sampleRadius` px of the selection (default its larger side, at
|
|
1254
|
+
* least 32). Deterministic for a `seed`. One undo step. 8-bit documents only for now.
|
|
1255
|
+
*/
|
|
1256
|
+
contentAwareFill(options?: ContentAwareFillOptions): {
|
|
1257
|
+
layerId: string;
|
|
1258
|
+
bounds: CropBox;
|
|
1259
|
+
output: 'current' | 'new-layer';
|
|
1260
|
+
};
|
|
1261
|
+
/** The pixel clipboard (Copy / Cut), or null. */
|
|
1262
|
+
private clipboard;
|
|
1263
|
+
/** What Copy or Cut last put on the editor's clipboard, or null. */
|
|
1264
|
+
getClipboard(): ClipboardImage | null;
|
|
1265
|
+
/** Puts pixels on the editor's clipboard (e.g. an image pasted from the system clipboard). */
|
|
1266
|
+
setClipboard(image: ClipboardImage | null): void;
|
|
1267
|
+
/**
|
|
1268
|
+
* Edit › Copy (or Copy Merged with `merged`): the selected pixels of a pixel layer (default the
|
|
1269
|
+
* active one) or of the whole visible image, cropped to the selection's bounds, with the
|
|
1270
|
+
* selection's soft edge in their alpha. Without a selection, the whole canvas. Not an undo step.
|
|
1271
|
+
*/
|
|
1272
|
+
copyPixels(options?: {
|
|
1273
|
+
layerId?: string;
|
|
1274
|
+
merged?: boolean;
|
|
1275
|
+
}): ClipboardImage;
|
|
1276
|
+
/** Edit › Cut: Copy, then clear the selected pixels, as one undo step. */
|
|
1277
|
+
cutPixels(options?: {
|
|
1278
|
+
layerId?: string;
|
|
1279
|
+
}): ClipboardImage;
|
|
1280
|
+
/**
|
|
1281
|
+
* Edit › Paste as a new pixel layer above the active one (one undo step): `new-layer` centred
|
|
1282
|
+
* on the selection (or the canvas), `in-place` where it was copied, `into` centred in the
|
|
1283
|
+
* selection with the selection as its mask (Paste Into), or `outside` with the inverse
|
|
1284
|
+
* (Paste Outside). Returns the new layer id and where it went.
|
|
1285
|
+
*/
|
|
1286
|
+
pastePixels(mode?: PasteMode, image?: ClipboardImage | null): {
|
|
1287
|
+
layerId: string;
|
|
1288
|
+
bounds: CropBox;
|
|
1289
|
+
masked: boolean;
|
|
1290
|
+
};
|
|
1185
1291
|
private fillOrClear;
|
|
1186
1292
|
/** The pixel layer the base sliders edit: the active pixel layer, else the Background. */
|
|
1187
1293
|
private developLayer;
|
|
@@ -1265,6 +1371,27 @@ export declare class ImageEditorController {
|
|
|
1265
1371
|
selectAll(): boolean;
|
|
1266
1372
|
/** Select › Deselect. */
|
|
1267
1373
|
deselect(): boolean;
|
|
1374
|
+
/** The selection a Deselect cleared, for `reselect` (not saved, not part of history). */
|
|
1375
|
+
private lastSelection;
|
|
1376
|
+
/** Whether `reselect` has a selection to bring back. */
|
|
1377
|
+
canReselect(): boolean;
|
|
1378
|
+
/** Select › Reselect: brings back the last selection a Deselect cleared, as one undo step. */
|
|
1379
|
+
reselect(): boolean;
|
|
1380
|
+
/**
|
|
1381
|
+
* Single Row / Single Column Marquee: a 1 px line across the whole image at `position`
|
|
1382
|
+
* (natural pixels; y for a row, x for a column).
|
|
1383
|
+
*/
|
|
1384
|
+
selectLine(orientation: 'row' | 'column', position: number, options?: SelectionCommandOptions): boolean;
|
|
1385
|
+
/** Select › Grow: adds connected pixels within `tolerance` of a selected colour (one undo step). */
|
|
1386
|
+
growSelection(options?: GrowSimilarOptions & SampleOptions): Promise<boolean>;
|
|
1387
|
+
/** Select › Similar: adds every pixel within `tolerance` of a selected colour (one undo step). */
|
|
1388
|
+
selectSimilar(options?: GrowSimilarOptions & SampleOptions): Promise<boolean>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Load Selection from a layer's transparency (Ctrl/⌘-click its thumbnail): its alpha in
|
|
1391
|
+
* document space, combined by `mode`. Works on pixel, shape, type and smart object layers.
|
|
1392
|
+
*/
|
|
1393
|
+
selectLayerTransparency(id: string, options?: SelectionCommandOptions): boolean;
|
|
1394
|
+
private layerTransparency;
|
|
1268
1395
|
/** Select › Inverse (with nothing selected, selects everything). */
|
|
1269
1396
|
invertSelection(): boolean;
|
|
1270
1397
|
private shapeCommand;
|
|
@@ -1294,6 +1421,13 @@ export declare class ImageEditorController {
|
|
|
1294
1421
|
magicWand(point: ImagePoint, options?: MagicWandOptions & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
1295
1422
|
/** Select › Color Range with colour samples (`#rrggbb` or `[r, g, b]`, optionally where they were picked). */
|
|
1296
1423
|
selectColorRange(samples: ColorRangeSample[], options?: ColorRangeOptions & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Select › Color Range with a preset: `reds` … `magentas`, `highlights` / `midtones` /
|
|
1426
|
+
* `shadows` (with `falloff` levels, default 20) or `skinTones`. One undo step.
|
|
1427
|
+
*/
|
|
1428
|
+
selectColorRangePreset(preset: ColorRangePreset, options?: {
|
|
1429
|
+
falloff?: number;
|
|
1430
|
+
} & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
1297
1431
|
/** Select › Modify: grow, shrink, feather, border or smooth by `radius` pixels (one undo step). */
|
|
1298
1432
|
modifySelection(op: SelectionModifyOp, radius: number): boolean;
|
|
1299
1433
|
/**
|
|
@@ -1333,6 +1467,13 @@ export declare class ImageEditorController {
|
|
|
1333
1467
|
}>;
|
|
1334
1468
|
/** Quick Mask view (tints the unselected area). View state: no undo step. */
|
|
1335
1469
|
setQuickMask(on: boolean): void;
|
|
1470
|
+
/** How the canvas shows the selection (`state.selectionDisplay`). */
|
|
1471
|
+
getSelectionDisplay(): SelectionDisplay;
|
|
1472
|
+
/**
|
|
1473
|
+
* Shows the selection as marching ants, as a Quick Mask tint over the unselected area, or hides
|
|
1474
|
+
* it (the selection still applies). View state: no undo step, not saved.
|
|
1475
|
+
*/
|
|
1476
|
+
setSelectionDisplay(display: SelectionDisplay): void;
|
|
1336
1477
|
private maskFromSelection;
|
|
1337
1478
|
/**
|
|
1338
1479
|
* Adds the selection as the layer's mask (Reveal Selection), replacing any mask, as one undo
|
|
@@ -1344,8 +1485,11 @@ export declare class ImageEditorController {
|
|
|
1344
1485
|
setAdjustmentLayerMask(layerId: string, mask: SelectionMask | null, props?: LayerMaskProps): boolean;
|
|
1345
1486
|
/** Changes a layer mask's density (0..1), feather (px) or enabled flag; the mask pixels are kept. */
|
|
1346
1487
|
setAdjustmentLayerMaskProps(layerId: string, props: LayerMaskProps, commitToHistory?: boolean): boolean;
|
|
1347
|
-
/**
|
|
1348
|
-
|
|
1488
|
+
/**
|
|
1489
|
+
* Load Selection from a layer mask (its pixels; density and feather are not applied), inverted
|
|
1490
|
+
* with `invert`. False without a painted mask (a depth mask is computed, not painted).
|
|
1491
|
+
*/
|
|
1492
|
+
selectionFromLayerMask(layerId: string, mode?: SelectionMode, invert?: boolean): boolean;
|
|
1349
1493
|
/**
|
|
1350
1494
|
* Histogram of the last rendered preview (after adjustments and layers, before annotations),
|
|
1351
1495
|
* or `null` before the first render or without canvas pixel access.
|
|
@@ -4,11 +4,11 @@ import { type BlendMode } from './blend.js';
|
|
|
4
4
|
import type { ImageHistogram } from './histogram.js';
|
|
5
5
|
import { type PixelBuffer, type SelectionChannel, type SelectionMask, type SelectionMode } from './selection/mask.js';
|
|
6
6
|
import { type ShapeSelectionOptions } from './selection/shapes.js';
|
|
7
|
-
import { type ColorRangeOptions, type ColorRangeSample, type MagicWandOptions } from './selection/wand.js';
|
|
7
|
+
import { type GrowSimilarOptions, type ColorRangeOptions, type ColorRangePreset, type ColorRangeSample, type MagicWandOptions } from './selection/wand.js';
|
|
8
8
|
import { type SelectionModifyOp } from './selection/modify.js';
|
|
9
9
|
import { type SegmentationProvider } from './selection/segmentation.js';
|
|
10
10
|
import { type RefineEdgeParams } from './selection/refine.js';
|
|
11
|
-
import type
|
|
11
|
+
import { type LayerMaskProps } from './selection/layer-mask.js';
|
|
12
12
|
import type { AdjustmentLayerMask } from './types.js';
|
|
13
13
|
import { type LayerBlendMode, type ImageLayer, type LayerFilter, type LayerTarget, type PixelLayer, type RasterMask, type SmartContents, type SmartFilter, type SmartPlacement, type LiveShape, type ShapeFillRule, type ShapeOperation, type ShapePaint, type ShapeStroke, type ParagraphStyle, type TextStyle, type TypeLayer, type ImageEffectAnimation } from './layers/model.js';
|
|
14
14
|
import { type TextLayout, type TextShaper } from './layers/text.js';
|
|
@@ -107,7 +107,11 @@ export interface SelectionCommandOptions {
|
|
|
107
107
|
mode?: SelectionMode;
|
|
108
108
|
/** Feather the new shape by this many pixels before combining (default 0). */
|
|
109
109
|
feather?: number;
|
|
110
|
+
/** Invert the new shape before combining (Color Range › Invert; default false). */
|
|
111
|
+
invert?: boolean;
|
|
110
112
|
}
|
|
113
|
+
/** How the canvas shows the selection: marching ants, a Quick Mask tint, or not at all. */
|
|
114
|
+
export type SelectionDisplay = 'ants' | 'quickMask' | 'none';
|
|
111
115
|
/** Where an AI result goes (see `applyInpaintedImage`, `applyBackgroundRemovedImage`). */
|
|
112
116
|
export interface AIResultOptions {
|
|
113
117
|
/** `new-layer`: a new layer (inpainting) or a mask (background removal); `replace`: the Background's pixels. Default: by `isMultiLayer`. */
|
|
@@ -133,6 +137,11 @@ export interface AdjustmentLayerInit<K extends AdjustmentKind = AdjustmentKind>
|
|
|
133
137
|
aboveId?: string;
|
|
134
138
|
/** Put the new layer at the top of this group. */
|
|
135
139
|
parentId?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Mask the new layer with the selection when there is one and no `mask` is given (Photoshop's
|
|
142
|
+
* behaviour). Default false here, for compatibility; the agent tool and the panels pass true.
|
|
143
|
+
*/
|
|
144
|
+
useSelection?: boolean;
|
|
136
145
|
}
|
|
137
146
|
/** A new pixel layer: empty, a solid colour over the canvas, or given pixels, plus its properties and position. */
|
|
138
147
|
export interface PixelLayerInit extends LayerPlacement {
|
|
@@ -345,6 +354,31 @@ export interface FillOptions {
|
|
|
345
354
|
/** Limit to the selection when there is one (default true). */
|
|
346
355
|
useSelection?: boolean;
|
|
347
356
|
}
|
|
357
|
+
/** Edit › Stroke (see `strokeSelection`). */
|
|
358
|
+
export interface StrokeSelectionOptions extends Omit<FillOptions, 'useSelection'> {
|
|
359
|
+
/** Width of the band in pixels (0 < width ≤ 250). */
|
|
360
|
+
width: number;
|
|
361
|
+
/** Where the band lies against the selection edge (default `outside`). */
|
|
362
|
+
location?: 'inside' | 'center' | 'outside';
|
|
363
|
+
}
|
|
364
|
+
/** Edit › Content-Aware Fill (see `contentAwareFill`). */
|
|
365
|
+
export interface ContentAwareFillOptions {
|
|
366
|
+
/** The pixel layer to sample and fill (default the active layer). */
|
|
367
|
+
layerId?: string;
|
|
368
|
+
/** `current` (default) paints into the layer; `new-layer` puts the fill on a new layer above it. */
|
|
369
|
+
output?: 'current' | 'new-layer';
|
|
370
|
+
/** How far around the selection to sample, in pixels (default its larger side, at least 32). */
|
|
371
|
+
sampleRadius?: number;
|
|
372
|
+
/** Random seed: the same seed gives the same fill (default 0). */
|
|
373
|
+
seed?: number;
|
|
374
|
+
}
|
|
375
|
+
/** Pixels on the editor's clipboard: RGBA, and where they were copied from (document pixels). */
|
|
376
|
+
export interface ClipboardImage extends PixelBuffer {
|
|
377
|
+
x?: number;
|
|
378
|
+
y?: number;
|
|
379
|
+
}
|
|
380
|
+
export type PasteMode = 'new-layer' | 'in-place' | 'into' | 'outside';
|
|
381
|
+
export declare const PASTE_MODES: readonly PasteMode[];
|
|
348
382
|
/** What a stroke, fill or clear changed. */
|
|
349
383
|
export interface PaintStrokeResult {
|
|
350
384
|
layerId: string;
|
|
@@ -595,10 +629,13 @@ export declare class ImageEditorController {
|
|
|
595
629
|
enabled?: boolean;
|
|
596
630
|
blend?: string;
|
|
597
631
|
opacity?: number;
|
|
632
|
+
/** Limit the filter to the selection (sets the filter mask from it, same undo step). Default false. */
|
|
633
|
+
useSelection?: boolean;
|
|
598
634
|
}): Promise<{
|
|
599
635
|
layerId: string;
|
|
600
636
|
filter: SmartFilter;
|
|
601
637
|
converted: boolean;
|
|
638
|
+
masked: boolean;
|
|
602
639
|
}>;
|
|
603
640
|
/**
|
|
604
641
|
* Changes an effect smart filter: `values` merged over its own (`null` resets a control to the
|
|
@@ -668,6 +705,14 @@ export declare class ImageEditorController {
|
|
|
668
705
|
private stack;
|
|
669
706
|
private captureHistoryEntry;
|
|
670
707
|
private restoreHistoryEntry;
|
|
708
|
+
/** Set while `asOneStep` runs: the step is already recorded, so nested commands add none. */
|
|
709
|
+
private historyGrouped;
|
|
710
|
+
/**
|
|
711
|
+
* Runs `fn` as one undo step: history is recorded once, before it, and the commands it calls
|
|
712
|
+
* record none. If `fn` throws, the step is dropped and the state goes back to before it, so a
|
|
713
|
+
* failure never leaves half a change.
|
|
714
|
+
*/
|
|
715
|
+
private asOneStep;
|
|
671
716
|
private recordHistory;
|
|
672
717
|
/**
|
|
673
718
|
* Bytes of pixel tiles held only by undo / redo steps (not by the current state). The oldest
|
|
@@ -824,11 +869,12 @@ export declare class ImageEditorController {
|
|
|
824
869
|
bounds: CropBox | null;
|
|
825
870
|
};
|
|
826
871
|
/**
|
|
827
|
-
* Adds a mask to a layer (one undo step): `reveal-all` (white), `hide-all` (black)
|
|
828
|
-
* `selection` (the selection's coverage)
|
|
872
|
+
* Adds a mask to a layer (one undo step): `reveal-all` (white), `hide-all` (black),
|
|
873
|
+
* `selection` (the selection's coverage), `hide-selection` (its inverse) or `transparency`
|
|
874
|
+
* (the layer's own alpha, so the pixels can then be made opaque and edited). Replaces an existing mask. Makes the mask the paint
|
|
829
875
|
* target when the layer is active.
|
|
830
876
|
*/
|
|
831
|
-
addLayerMask(id: string, from?: 'reveal-all' | 'hide-all' | 'selection', props?: LayerMaskProps): RasterMask;
|
|
877
|
+
addLayerMask(id: string, from?: 'reveal-all' | 'hide-all' | 'selection' | 'hide-selection' | 'transparency', props?: LayerMaskProps): RasterMask;
|
|
832
878
|
/** Removes a layer's mask (one undo step). */
|
|
833
879
|
removeLayerMask(id: string): void;
|
|
834
880
|
/** Changes any layer mask's density, feather, enabled or linked flag (pixels kept). Returns the mask. */
|
|
@@ -978,7 +1024,14 @@ export declare class ImageEditorController {
|
|
|
978
1024
|
/** Adds a smart filter (`develop` or `blur`, with `blend` and `opacity`) at `index` (default the top), as one undo step. */
|
|
979
1025
|
addSmartFilter(id: string, filter: Record<string, unknown> & {
|
|
980
1026
|
kind: string;
|
|
981
|
-
}, index?: number
|
|
1027
|
+
}, index?: number, options?: {
|
|
1028
|
+
useSelection?: boolean;
|
|
1029
|
+
}): SmartFilter;
|
|
1030
|
+
/**
|
|
1031
|
+
* After adding a smart filter: with `useSelection` and a selection, sets the filter mask from
|
|
1032
|
+
* it in the same undo step (Photoshop limits a filter to the selection). Returns whether it did.
|
|
1033
|
+
*/
|
|
1034
|
+
private maskFiltersWithSelection;
|
|
982
1035
|
/** Changes one smart filter (one undo step, or none with `commitToHistory = false` during a drag). */
|
|
983
1036
|
updateSmartFilter(id: string, filterId: string, changes: Record<string, unknown>, commitToHistory?: boolean): SmartFilter;
|
|
984
1037
|
/** Removes one smart filter (one undo step). Returns the remaining filters. */
|
|
@@ -1182,6 +1235,59 @@ export declare class ImageEditorController {
|
|
|
1182
1235
|
* whole canvas. One undo step. Returns the changed bounds.
|
|
1183
1236
|
*/
|
|
1184
1237
|
clearPixels(options?: Omit<FillOptions, 'color' | 'blend'>): PaintStrokeResult;
|
|
1238
|
+
/**
|
|
1239
|
+
* Edit › Stroke: paints a band `width` px wide along the selection's edge, `inside` it, on the
|
|
1240
|
+
* `center` of the edge or `outside` it (default), with `color` (default the foreground),
|
|
1241
|
+
* `opacity` and `blend`, on a layer's pixels or mask. One undo step. Returns the changed bounds.
|
|
1242
|
+
*/
|
|
1243
|
+
strokeSelection(options: StrokeSelectionOptions): PaintStrokeResult;
|
|
1244
|
+
/**
|
|
1245
|
+
* Image › Crop to the selection's bounds (one undo step). Returns the crop box (natural
|
|
1246
|
+
* pixels). Throws without a selection.
|
|
1247
|
+
*/
|
|
1248
|
+
cropToSelection(): CropBox;
|
|
1249
|
+
/**
|
|
1250
|
+
* Edit › Content-Aware Fill: fills the selection with texture synthesised from around it
|
|
1251
|
+
* (PatchMatch, as the Spot Healing Brush's content-aware mode), blended by the selection's
|
|
1252
|
+
* coverage. `output` `current` paints into the layer; `new-layer` puts the fill on a new layer
|
|
1253
|
+
* above it. Samples within `sampleRadius` px of the selection (default its larger side, at
|
|
1254
|
+
* least 32). Deterministic for a `seed`. One undo step. 8-bit documents only for now.
|
|
1255
|
+
*/
|
|
1256
|
+
contentAwareFill(options?: ContentAwareFillOptions): {
|
|
1257
|
+
layerId: string;
|
|
1258
|
+
bounds: CropBox;
|
|
1259
|
+
output: 'current' | 'new-layer';
|
|
1260
|
+
};
|
|
1261
|
+
/** The pixel clipboard (Copy / Cut), or null. */
|
|
1262
|
+
private clipboard;
|
|
1263
|
+
/** What Copy or Cut last put on the editor's clipboard, or null. */
|
|
1264
|
+
getClipboard(): ClipboardImage | null;
|
|
1265
|
+
/** Puts pixels on the editor's clipboard (e.g. an image pasted from the system clipboard). */
|
|
1266
|
+
setClipboard(image: ClipboardImage | null): void;
|
|
1267
|
+
/**
|
|
1268
|
+
* Edit › Copy (or Copy Merged with `merged`): the selected pixels of a pixel layer (default the
|
|
1269
|
+
* active one) or of the whole visible image, cropped to the selection's bounds, with the
|
|
1270
|
+
* selection's soft edge in their alpha. Without a selection, the whole canvas. Not an undo step.
|
|
1271
|
+
*/
|
|
1272
|
+
copyPixels(options?: {
|
|
1273
|
+
layerId?: string;
|
|
1274
|
+
merged?: boolean;
|
|
1275
|
+
}): ClipboardImage;
|
|
1276
|
+
/** Edit › Cut: Copy, then clear the selected pixels, as one undo step. */
|
|
1277
|
+
cutPixels(options?: {
|
|
1278
|
+
layerId?: string;
|
|
1279
|
+
}): ClipboardImage;
|
|
1280
|
+
/**
|
|
1281
|
+
* Edit › Paste as a new pixel layer above the active one (one undo step): `new-layer` centred
|
|
1282
|
+
* on the selection (or the canvas), `in-place` where it was copied, `into` centred in the
|
|
1283
|
+
* selection with the selection as its mask (Paste Into), or `outside` with the inverse
|
|
1284
|
+
* (Paste Outside). Returns the new layer id and where it went.
|
|
1285
|
+
*/
|
|
1286
|
+
pastePixels(mode?: PasteMode, image?: ClipboardImage | null): {
|
|
1287
|
+
layerId: string;
|
|
1288
|
+
bounds: CropBox;
|
|
1289
|
+
masked: boolean;
|
|
1290
|
+
};
|
|
1185
1291
|
private fillOrClear;
|
|
1186
1292
|
/** The pixel layer the base sliders edit: the active pixel layer, else the Background. */
|
|
1187
1293
|
private developLayer;
|
|
@@ -1265,6 +1371,27 @@ export declare class ImageEditorController {
|
|
|
1265
1371
|
selectAll(): boolean;
|
|
1266
1372
|
/** Select › Deselect. */
|
|
1267
1373
|
deselect(): boolean;
|
|
1374
|
+
/** The selection a Deselect cleared, for `reselect` (not saved, not part of history). */
|
|
1375
|
+
private lastSelection;
|
|
1376
|
+
/** Whether `reselect` has a selection to bring back. */
|
|
1377
|
+
canReselect(): boolean;
|
|
1378
|
+
/** Select › Reselect: brings back the last selection a Deselect cleared, as one undo step. */
|
|
1379
|
+
reselect(): boolean;
|
|
1380
|
+
/**
|
|
1381
|
+
* Single Row / Single Column Marquee: a 1 px line across the whole image at `position`
|
|
1382
|
+
* (natural pixels; y for a row, x for a column).
|
|
1383
|
+
*/
|
|
1384
|
+
selectLine(orientation: 'row' | 'column', position: number, options?: SelectionCommandOptions): boolean;
|
|
1385
|
+
/** Select › Grow: adds connected pixels within `tolerance` of a selected colour (one undo step). */
|
|
1386
|
+
growSelection(options?: GrowSimilarOptions & SampleOptions): Promise<boolean>;
|
|
1387
|
+
/** Select › Similar: adds every pixel within `tolerance` of a selected colour (one undo step). */
|
|
1388
|
+
selectSimilar(options?: GrowSimilarOptions & SampleOptions): Promise<boolean>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Load Selection from a layer's transparency (Ctrl/⌘-click its thumbnail): its alpha in
|
|
1391
|
+
* document space, combined by `mode`. Works on pixel, shape, type and smart object layers.
|
|
1392
|
+
*/
|
|
1393
|
+
selectLayerTransparency(id: string, options?: SelectionCommandOptions): boolean;
|
|
1394
|
+
private layerTransparency;
|
|
1268
1395
|
/** Select › Inverse (with nothing selected, selects everything). */
|
|
1269
1396
|
invertSelection(): boolean;
|
|
1270
1397
|
private shapeCommand;
|
|
@@ -1294,6 +1421,13 @@ export declare class ImageEditorController {
|
|
|
1294
1421
|
magicWand(point: ImagePoint, options?: MagicWandOptions & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
1295
1422
|
/** Select › Color Range with colour samples (`#rrggbb` or `[r, g, b]`, optionally where they were picked). */
|
|
1296
1423
|
selectColorRange(samples: ColorRangeSample[], options?: ColorRangeOptions & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Select › Color Range with a preset: `reds` … `magentas`, `highlights` / `midtones` /
|
|
1426
|
+
* `shadows` (with `falloff` levels, default 20) or `skinTones`. One undo step.
|
|
1427
|
+
*/
|
|
1428
|
+
selectColorRangePreset(preset: ColorRangePreset, options?: {
|
|
1429
|
+
falloff?: number;
|
|
1430
|
+
} & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
1297
1431
|
/** Select › Modify: grow, shrink, feather, border or smooth by `radius` pixels (one undo step). */
|
|
1298
1432
|
modifySelection(op: SelectionModifyOp, radius: number): boolean;
|
|
1299
1433
|
/**
|
|
@@ -1333,6 +1467,13 @@ export declare class ImageEditorController {
|
|
|
1333
1467
|
}>;
|
|
1334
1468
|
/** Quick Mask view (tints the unselected area). View state: no undo step. */
|
|
1335
1469
|
setQuickMask(on: boolean): void;
|
|
1470
|
+
/** How the canvas shows the selection (`state.selectionDisplay`). */
|
|
1471
|
+
getSelectionDisplay(): SelectionDisplay;
|
|
1472
|
+
/**
|
|
1473
|
+
* Shows the selection as marching ants, as a Quick Mask tint over the unselected area, or hides
|
|
1474
|
+
* it (the selection still applies). View state: no undo step, not saved.
|
|
1475
|
+
*/
|
|
1476
|
+
setSelectionDisplay(display: SelectionDisplay): void;
|
|
1336
1477
|
private maskFromSelection;
|
|
1337
1478
|
/**
|
|
1338
1479
|
* Adds the selection as the layer's mask (Reveal Selection), replacing any mask, as one undo
|
|
@@ -1344,8 +1485,11 @@ export declare class ImageEditorController {
|
|
|
1344
1485
|
setAdjustmentLayerMask(layerId: string, mask: SelectionMask | null, props?: LayerMaskProps): boolean;
|
|
1345
1486
|
/** Changes a layer mask's density (0..1), feather (px) or enabled flag; the mask pixels are kept. */
|
|
1346
1487
|
setAdjustmentLayerMaskProps(layerId: string, props: LayerMaskProps, commitToHistory?: boolean): boolean;
|
|
1347
|
-
/**
|
|
1348
|
-
|
|
1488
|
+
/**
|
|
1489
|
+
* Load Selection from a layer mask (its pixels; density and feather are not applied), inverted
|
|
1490
|
+
* with `invert`. False without a painted mask (a depth mask is computed, not painted).
|
|
1491
|
+
*/
|
|
1492
|
+
selectionFromLayerMask(layerId: string, mode?: SelectionMode, invert?: boolean): boolean;
|
|
1349
1493
|
/**
|
|
1350
1494
|
* Histogram of the last rendered preview (after adjustments and layers, before annotations),
|
|
1351
1495
|
* or `null` before the first render or without canvas pixel access.
|