pixel-data-js 0.25.0 → 0.26.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/index.prod.cjs +1832 -1606
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +458 -324
- package/dist/index.prod.js +1811 -1600
- package/dist/index.prod.js.map +1 -1
- package/package.json +8 -9
- package/src/Algorithm/floodFillSelection.ts +49 -80
- package/src/Canvas/PixelCanvas.ts +1 -1
- package/src/Canvas/ReusableCanvas.ts +1 -1
- package/src/History/HistoryAction.ts +6 -5
- package/src/History/PixelMutator/mutatorApplyAlphaMask.ts +8 -10
- package/src/History/PixelMutator/mutatorApplyBinaryMask.ts +8 -10
- package/src/History/PixelMutator/mutatorApplyMask.ts +39 -0
- package/src/History/PixelMutator/{mutatorBlendPixelDataAlphaMask.ts → mutatorBlendAlphaMask.ts} +9 -9
- package/src/History/PixelMutator/{mutatorBlendPixelDataBinaryMask.ts → mutatorBlendBinaryMask.ts} +9 -9
- package/src/History/PixelMutator/mutatorBlendColor.ts +8 -9
- package/src/History/PixelMutator/mutatorBlendColorPaintAlphaMask.ts +51 -0
- package/src/History/PixelMutator/mutatorBlendColorPaintBinaryMask.ts +51 -0
- package/src/History/PixelMutator/mutatorBlendColorPaintMask.ts +60 -0
- package/src/History/PixelMutator/mutatorBlendMask.ts +43 -0
- package/src/History/PixelMutator/mutatorBlendPaintRect.ts +55 -0
- package/src/History/PixelMutator/mutatorBlendPixel.ts +2 -2
- package/src/History/PixelMutator/mutatorBlendPixelData.ts +8 -9
- package/src/History/PixelMutator/mutatorClear.ts +13 -11
- package/src/History/PixelMutator/mutatorFill.ts +2 -2
- package/src/History/PixelMutator/mutatorFillBinaryMask.ts +3 -4
- package/src/History/PixelMutator/mutatorInvert.ts +8 -9
- package/src/History/PixelMutator.ts +20 -4
- package/src/History/PixelWriter.ts +11 -13
- package/src/Input/fileToImageData.ts +1 -1
- package/src/Internal/helpers.ts +4 -1
- package/src/Mask/applyBinaryMaskToAlphaMask.ts +8 -10
- package/src/Paint/PaintBuffer.ts +3 -3
- package/src/Paint/PaintBufferCanvasRenderer.ts +1 -1
- package/src/Paint/makePaintMask.ts +5 -5
- package/src/Paint/makeRectFalloffPaintAlphaMask.ts +3 -3
- package/src/PixelData/applyAlphaMaskToPixelData.ts +14 -16
- package/src/PixelData/applyBinaryMaskToPixelData.ts +14 -16
- package/src/PixelData/applyMaskToPixelData.ts +22 -0
- package/src/PixelData/blendColorPixelData.ts +12 -15
- package/src/PixelData/blendColorPixelDataAlphaMask.ts +16 -16
- package/src/PixelData/blendColorPixelDataBinaryMask.ts +16 -16
- package/src/PixelData/blendColorPixelDataMask.ts +16 -0
- package/src/PixelData/blendColorPixelDataPaintAlphaMask.ts +30 -0
- package/src/PixelData/blendColorPixelDataPaintBinaryMask.ts +30 -0
- package/src/PixelData/blendColorPixelDataPaintMask.ts +35 -0
- package/src/PixelData/blendPixelData.ts +14 -16
- package/src/PixelData/blendPixelDataAlphaMask.ts +17 -19
- package/src/PixelData/blendPixelDataBinaryMask.ts +17 -19
- package/src/PixelData/blendPixelDataMask.ts +16 -0
- package/src/PixelData/blendPixelDataPaintBuffer.ts +1 -1
- package/src/PixelData/{clearPixelData.ts → clearPixelDataFast.ts} +2 -2
- package/src/PixelData/fillPixelDataBinaryMask.ts +8 -22
- package/src/PixelData/fillPixelDataFast.ts +2 -2
- package/src/PixelData/invertPixelData.ts +13 -16
- package/src/_types.ts +8 -7
- package/src/index.ts +41 -29
- package/dist/index.dev.cjs +0 -5363
- package/dist/index.dev.cjs.map +0 -1
- package/dist/index.dev.js +0 -5154
- package/dist/index.dev.js.map +0 -1
- package/src/Canvas/_constants.ts +0 -2
- package/src/PixelData/PixelBuffer32.ts +0 -28
package/dist/index.prod.d.ts
CHANGED
|
@@ -57,18 +57,19 @@ declare enum MaskType {
|
|
|
57
57
|
*/
|
|
58
58
|
BINARY = 1
|
|
59
59
|
}
|
|
60
|
-
interface
|
|
60
|
+
interface BaseMask {
|
|
61
61
|
readonly type: MaskType;
|
|
62
62
|
readonly data: Uint8Array;
|
|
63
63
|
readonly w: number;
|
|
64
64
|
readonly h: number;
|
|
65
65
|
}
|
|
66
|
+
type Mask = BinaryMask | AlphaMask;
|
|
66
67
|
/** Strictly 0 or 1 */
|
|
67
|
-
interface BinaryMask extends
|
|
68
|
+
interface BinaryMask extends BaseMask {
|
|
68
69
|
readonly type: MaskType.BINARY;
|
|
69
70
|
}
|
|
70
71
|
/** Strictly 0-255 */
|
|
71
|
-
interface AlphaMask extends
|
|
72
|
+
interface AlphaMask extends BaseMask {
|
|
72
73
|
readonly type: MaskType.ALPHA;
|
|
73
74
|
}
|
|
74
75
|
interface BasePaintMask {
|
|
@@ -176,6 +177,8 @@ interface ColorBlendOptions extends PixelRect, Alpha {
|
|
|
176
177
|
}
|
|
177
178
|
interface ColorBlendMaskOptions extends ColorBlendOptions, MaskOffset, InvertMask {
|
|
178
179
|
}
|
|
180
|
+
interface ColorBlendPaintMaskOptions extends Omit<ColorBlendOptions, 'w' | 'h'> {
|
|
181
|
+
}
|
|
179
182
|
type MaskRect<T extends MaskType> = Rect & {
|
|
180
183
|
type: T;
|
|
181
184
|
data: Uint8Array;
|
|
@@ -196,7 +199,6 @@ type NullableMaskRect = Rect & ({
|
|
|
196
199
|
type?: null;
|
|
197
200
|
data?: null;
|
|
198
201
|
});
|
|
199
|
-
type HistoryMutator<T extends {}, D extends {}> = (writer: PixelWriter<any>, deps?: Partial<D>) => T;
|
|
200
202
|
interface IPixelData32 {
|
|
201
203
|
readonly data32: Uint32Array;
|
|
202
204
|
readonly width: number;
|
|
@@ -206,47 +208,6 @@ interface IPixelData<T extends ImageDataLike = ImageData> extends IPixelData32 {
|
|
|
206
208
|
readonly imageData: T;
|
|
207
209
|
}
|
|
208
210
|
|
|
209
|
-
/**
|
|
210
|
-
* Packs RGBA into a 32-bit integer compatible with
|
|
211
|
-
* Little-Endian Uint32Array views on ImageData.
|
|
212
|
-
*/
|
|
213
|
-
declare function packColor(r: number, g: number, b: number, a: number): Color32;
|
|
214
|
-
declare function packRGBA({ r, g, b, a }: RGBA): Color32;
|
|
215
|
-
declare const unpackRed: (packed: Color32) => number;
|
|
216
|
-
declare const unpackGreen: (packed: Color32) => number;
|
|
217
|
-
declare const unpackBlue: (packed: Color32) => number;
|
|
218
|
-
declare const unpackAlpha: (packed: Color32) => number;
|
|
219
|
-
declare function unpackColor(packed: Color32): RGBA;
|
|
220
|
-
declare function unpackColorTo(packed: Color32, scratch?: RGBA): RGBA;
|
|
221
|
-
declare function colorDistance(a: Color32, b: Color32): number;
|
|
222
|
-
/**
|
|
223
|
-
* Linearly interpolates between two 32-bit colors using a floating-point weight.
|
|
224
|
-
* * This is the preferred method for UI animations or scenarios where high
|
|
225
|
-
* precision is required. It uses the standard `a + t * (b - a)` formula
|
|
226
|
-
* for each channel.
|
|
227
|
-
* @param a - The starting color as a 32-bit integer (AABBGGRR).
|
|
228
|
-
* @param b - The target color as a 32-bit integer (AABBGGRR).
|
|
229
|
-
* @param t - The interpolation factor between 0.0 and 1.0.
|
|
230
|
-
* @returns The interpolated 32-bit color.
|
|
231
|
-
*/
|
|
232
|
-
declare function lerpColor32(a: Color32, b: Color32, t: number): Color32;
|
|
233
|
-
/**
|
|
234
|
-
* Linearly interpolates between two 32-bit colors using integer fixed-point math.
|
|
235
|
-
* Highly optimized for image processing and real-time blitting. It processes
|
|
236
|
-
* channels in parallel using bitmasks (RB and GA pairs).
|
|
237
|
-
* **Note:** Subject to a 1-bit drift (rounding down) due to fast bit-shift division.
|
|
238
|
-
* @param src - The source (foreground) color as a 32-bit integer.
|
|
239
|
-
* @param dst - The destination (background) color as a 32-bit integer.
|
|
240
|
-
* @param w - The blend weight as a byte value from 0 to 255. Where 0 is 100% dst and 255 is 100% src
|
|
241
|
-
* @returns The blended 32-bit color.
|
|
242
|
-
*/ declare function lerpColor32Fast(src: Color32, dst: Color32, w: number): Color32;
|
|
243
|
-
declare function color32ToHex(color: Color32): string;
|
|
244
|
-
/**
|
|
245
|
-
* Converts a 32-bit integer (0xAABBGGRR) to a CSS rgba() string.
|
|
246
|
-
* Example: 0xFF0000FF -> "rgba(255,0,0,1)"
|
|
247
|
-
*/
|
|
248
|
-
declare function color32ToCssRGBA(color: Color32): string;
|
|
249
|
-
|
|
250
211
|
declare class PixelData<T extends ImageDataLike = ImageData> implements IPixelData<T> {
|
|
251
212
|
readonly data32: Uint32Array;
|
|
252
213
|
readonly imageData: T;
|
|
@@ -256,15 +217,9 @@ declare class PixelData<T extends ImageDataLike = ImageData> implements IPixelDa
|
|
|
256
217
|
set(imageData: T): void;
|
|
257
218
|
}
|
|
258
219
|
|
|
259
|
-
type
|
|
260
|
-
contiguous?: boolean;
|
|
261
|
-
tolerance?: number;
|
|
262
|
-
bounds?: Rect;
|
|
263
|
-
};
|
|
264
|
-
type FloodFillResult = {
|
|
220
|
+
type FloodFillResult = BinaryMaskRect & {
|
|
265
221
|
startX: number;
|
|
266
222
|
startY: number;
|
|
267
|
-
selectionRect: BinaryMaskRect;
|
|
268
223
|
pixels: Uint8ClampedArray;
|
|
269
224
|
};
|
|
270
225
|
/**
|
|
@@ -273,16 +228,15 @@ type FloodFillResult = {
|
|
|
273
228
|
* color tolerance. It can operate in "contiguous" mode (classic bucket fill) or
|
|
274
229
|
* "non-contiguous" mode (selects all matching pixels in the buffer).
|
|
275
230
|
*
|
|
276
|
-
* @param
|
|
231
|
+
* @param target - The source image data to process.
|
|
277
232
|
* @param startX - The starting horizontal coordinate.
|
|
278
233
|
* @param startY - The starting vertical coordinate.
|
|
279
|
-
* @param
|
|
280
|
-
* @param options.contiguous - If true, only connected pixels are
|
|
234
|
+
* @param contiguous - If true, only connected pixels are
|
|
281
235
|
* selected. If false, all pixels within tolerance are selected regardless of position.
|
|
282
|
-
* @param
|
|
236
|
+
* @param tolerance - The maximum allowed difference in color
|
|
283
237
|
* distance (0-255) for a pixel to be included.
|
|
284
|
-
* @param
|
|
285
|
-
*
|
|
238
|
+
* @param bounds - Optional bounding box to restrict the search area.
|
|
239
|
+
* @param out output object
|
|
286
240
|
* @returns A {@link FloodFillResult} containing the mask and bounds of the selection,
|
|
287
241
|
* or `null` if the starting coordinates are out of bounds.
|
|
288
242
|
*
|
|
@@ -299,7 +253,7 @@ type FloodFillResult = {
|
|
|
299
253
|
* );
|
|
300
254
|
* ```
|
|
301
255
|
*/
|
|
302
|
-
declare function floodFillSelection(
|
|
256
|
+
declare function floodFillSelection(target: PixelData, startX: number, startY: number, contiguous?: boolean, tolerance?: number, bounds?: Rect, out?: FloodFillResult): FloodFillResult | null;
|
|
303
257
|
|
|
304
258
|
/**
|
|
305
259
|
* Iterates through a line with sub-pixel precision.
|
|
@@ -307,6 +261,50 @@ declare function floodFillSelection(img: ImageDataLike | PixelData, startX: numb
|
|
|
307
261
|
*/
|
|
308
262
|
declare function forEachLinePoint(x0: number, y0: number, x1: number, y1: number, callback: (x: number, y: number) => void): void;
|
|
309
263
|
|
|
264
|
+
declare const BaseBlendMode: {
|
|
265
|
+
readonly overwrite: 0;
|
|
266
|
+
readonly sourceOver: 1;
|
|
267
|
+
readonly darken: 2;
|
|
268
|
+
readonly multiply: 3;
|
|
269
|
+
readonly colorBurn: 4;
|
|
270
|
+
readonly linearBurn: 5;
|
|
271
|
+
readonly darkerColor: 6;
|
|
272
|
+
readonly lighten: 7;
|
|
273
|
+
readonly screen: 8;
|
|
274
|
+
readonly colorDodge: 9;
|
|
275
|
+
readonly linearDodge: 10;
|
|
276
|
+
readonly lighterColor: 11;
|
|
277
|
+
readonly overlay: 12;
|
|
278
|
+
readonly softLight: 13;
|
|
279
|
+
readonly hardLight: 14;
|
|
280
|
+
readonly vividLight: 15;
|
|
281
|
+
readonly linearLight: 16;
|
|
282
|
+
readonly pinLight: 17;
|
|
283
|
+
readonly hardMix: 18;
|
|
284
|
+
readonly difference: 19;
|
|
285
|
+
readonly exclusion: 20;
|
|
286
|
+
readonly subtract: 21;
|
|
287
|
+
readonly divide: 22;
|
|
288
|
+
};
|
|
289
|
+
interface RequiredBlendModes {
|
|
290
|
+
overwrite: 0;
|
|
291
|
+
}
|
|
292
|
+
type BaseBlendModes = RequiredBlendModes & Record<string, number>;
|
|
293
|
+
declare const overwriteBase: BlendColor32;
|
|
294
|
+
|
|
295
|
+
type BlendModeRegistry<BlendModes extends BaseBlendModes = BaseBlendModes, Name extends keyof BlendModes = keyof BlendModes, Index extends BlendModes[Name] = BlendModes[Name]> = ReturnType<typeof makeBlendModeRegistry<BlendModes, Name, Index>>;
|
|
296
|
+
declare function makeBlendModeRegistry<BlendModes extends BaseBlendModes, Name extends keyof BlendModes = keyof BlendModes, Index extends BlendModes[Name] = BlendModes[Name]>(blendModes: BlendModes, initialEntries: Record<Index, BlendColor32>, registryName?: string): {
|
|
297
|
+
registryName: string;
|
|
298
|
+
nameToBlend: { [K in keyof BlendModes]: BlendColor32; };
|
|
299
|
+
nameToIndex: Record<Name, Index>;
|
|
300
|
+
blendToIndex: Map<BlendColor32, Index>;
|
|
301
|
+
blendToName: Map<BlendColor32, Name>;
|
|
302
|
+
indexToBlend: BlendColor32[];
|
|
303
|
+
indexToName: Name[];
|
|
304
|
+
indexType: Index;
|
|
305
|
+
nameType: Name;
|
|
306
|
+
};
|
|
307
|
+
|
|
310
308
|
declare const overwriteFast: BlendColor32;
|
|
311
309
|
declare const sourceOverFast: BlendColor32;
|
|
312
310
|
declare const darkenFast: BlendColor32;
|
|
@@ -473,58 +471,11 @@ declare function makePerfectBlendModeRegistry(name?: string): {
|
|
|
473
471
|
nameType: "overwrite" | "sourceOver" | "darken" | "multiply" | "colorBurn" | "linearBurn" | "darkerColor" | "lighten" | "screen" | "colorDodge" | "linearDodge" | "lighterColor" | "overlay" | "softLight" | "hardLight" | "vividLight" | "linearLight" | "pinLight" | "hardMix" | "difference" | "exclusion" | "subtract" | "divide";
|
|
474
472
|
};
|
|
475
473
|
|
|
476
|
-
declare const BaseBlendMode: {
|
|
477
|
-
readonly overwrite: 0;
|
|
478
|
-
readonly sourceOver: 1;
|
|
479
|
-
readonly darken: 2;
|
|
480
|
-
readonly multiply: 3;
|
|
481
|
-
readonly colorBurn: 4;
|
|
482
|
-
readonly linearBurn: 5;
|
|
483
|
-
readonly darkerColor: 6;
|
|
484
|
-
readonly lighten: 7;
|
|
485
|
-
readonly screen: 8;
|
|
486
|
-
readonly colorDodge: 9;
|
|
487
|
-
readonly linearDodge: 10;
|
|
488
|
-
readonly lighterColor: 11;
|
|
489
|
-
readonly overlay: 12;
|
|
490
|
-
readonly softLight: 13;
|
|
491
|
-
readonly hardLight: 14;
|
|
492
|
-
readonly vividLight: 15;
|
|
493
|
-
readonly linearLight: 16;
|
|
494
|
-
readonly pinLight: 17;
|
|
495
|
-
readonly hardMix: 18;
|
|
496
|
-
readonly difference: 19;
|
|
497
|
-
readonly exclusion: 20;
|
|
498
|
-
readonly subtract: 21;
|
|
499
|
-
readonly divide: 22;
|
|
500
|
-
};
|
|
501
|
-
interface RequiredBlendModes {
|
|
502
|
-
overwrite: 0;
|
|
503
|
-
}
|
|
504
|
-
type BaseBlendModes = RequiredBlendModes & Record<string, number>;
|
|
505
|
-
declare const overwriteBase: BlendColor32;
|
|
506
|
-
|
|
507
|
-
type BlendModeRegistry<BlendModes extends BaseBlendModes = BaseBlendModes, Name extends keyof BlendModes = keyof BlendModes, Index extends BlendModes[Name] = BlendModes[Name]> = ReturnType<typeof makeBlendModeRegistry<BlendModes, Name, Index>>;
|
|
508
|
-
declare function makeBlendModeRegistry<BlendModes extends BaseBlendModes, Name extends keyof BlendModes = keyof BlendModes, Index extends BlendModes[Name] = BlendModes[Name]>(blendModes: BlendModes, initialEntries: Record<Index, BlendColor32>, registryName?: string): {
|
|
509
|
-
registryName: string;
|
|
510
|
-
nameToBlend: { [K in keyof BlendModes]: BlendColor32; };
|
|
511
|
-
nameToIndex: Record<Name, Index>;
|
|
512
|
-
blendToIndex: Map<BlendColor32, Index>;
|
|
513
|
-
blendToName: Map<BlendColor32, Name>;
|
|
514
|
-
indexToBlend: BlendColor32[];
|
|
515
|
-
indexToName: Name[];
|
|
516
|
-
indexType: Index;
|
|
517
|
-
nameType: Name;
|
|
518
|
-
};
|
|
519
|
-
|
|
520
474
|
declare function toBlendModeIndexAndName(input: string | number): {
|
|
521
475
|
blendIndex: number;
|
|
522
476
|
blendName: string;
|
|
523
477
|
};
|
|
524
478
|
|
|
525
|
-
declare const OFFSCREEN_CANVAS_CTX_FAILED = "Failed to create OffscreenCanvas context";
|
|
526
|
-
declare const CANVAS_CTX_FAILED = "Failed to create Canvas context";
|
|
527
|
-
|
|
528
479
|
type PixelCanvas = {
|
|
529
480
|
readonly canvas: HTMLCanvasElement;
|
|
530
481
|
readonly ctx: CanvasRenderingContext2D;
|
|
@@ -567,14 +518,33 @@ declare function makeReusableOffscreenCanvas(): {
|
|
|
567
518
|
type DrawPixelLayer = (ctx: CanvasRenderingContext2D) => void;
|
|
568
519
|
type DrawScreenLayer = (ctx: CanvasRenderingContext2D, scale: number) => void;
|
|
569
520
|
type CanvasFrameRenderer = ReturnType<typeof makeCanvasFrameRenderer>;
|
|
570
|
-
declare const defaults$
|
|
521
|
+
declare const defaults$h: {
|
|
571
522
|
makeReusableCanvas: typeof makeReusableCanvas;
|
|
572
523
|
};
|
|
573
|
-
type Deps$
|
|
524
|
+
type Deps$h = Partial<typeof defaults$h>;
|
|
574
525
|
/**
|
|
575
526
|
* @param deps - @hidden
|
|
576
527
|
*/
|
|
577
|
-
declare function makeCanvasFrameRenderer(deps?: Deps$
|
|
528
|
+
declare function makeCanvasFrameRenderer(deps?: Deps$h): (pixelCanvas: PixelCanvas, scale: number, getImageData: () => ImageData | undefined | null, drawPixelLayer?: DrawPixelLayer, drawScreenLayer?: DrawScreenLayer) => void;
|
|
529
|
+
|
|
530
|
+
declare const CANVAS_COMPOSITE_MAP: {
|
|
531
|
+
readonly 0: "copy";
|
|
532
|
+
readonly 1: "source-over";
|
|
533
|
+
readonly 2: "darken";
|
|
534
|
+
readonly 3: "multiply";
|
|
535
|
+
readonly 4: "color-burn";
|
|
536
|
+
readonly 7: "lighten";
|
|
537
|
+
readonly 8: "screen";
|
|
538
|
+
readonly 9: "color-dodge";
|
|
539
|
+
readonly 10: "lighter";
|
|
540
|
+
readonly 12: "overlay";
|
|
541
|
+
readonly 13: "soft-light";
|
|
542
|
+
readonly 14: "hard-light";
|
|
543
|
+
readonly 19: "difference";
|
|
544
|
+
readonly 20: "exclusion";
|
|
545
|
+
};
|
|
546
|
+
type CanvasBlendModeIndex = keyof typeof CANVAS_COMPOSITE_MAP;
|
|
547
|
+
type CanvasCompositeOperation = typeof CANVAS_COMPOSITE_MAP[CanvasBlendModeIndex];
|
|
578
548
|
|
|
579
549
|
/**
|
|
580
550
|
* Extracts {@link ImageData} from a clipboard event if an image is present.
|
|
@@ -637,12 +607,83 @@ declare class PixelTile implements IPixelData {
|
|
|
637
607
|
constructor(id: number, tx: number, ty: number, tileSize: number, tileArea: number);
|
|
638
608
|
}
|
|
639
609
|
|
|
610
|
+
declare class PixelEngineConfig {
|
|
611
|
+
readonly tileSize: number;
|
|
612
|
+
readonly tileShift: number;
|
|
613
|
+
readonly tileMask: number;
|
|
614
|
+
readonly tileArea: number;
|
|
615
|
+
readonly target: PixelData;
|
|
616
|
+
readonly targetColumns: number;
|
|
617
|
+
readonly targetRows: number;
|
|
618
|
+
constructor(tileSize: number, target: PixelData);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
declare class PixelTilePool {
|
|
622
|
+
pool: PixelTile[];
|
|
623
|
+
private tileSize;
|
|
624
|
+
private tileArea;
|
|
625
|
+
constructor(config: PixelEngineConfig);
|
|
626
|
+
getTile(id: number, tx: number, ty: number): PixelTile;
|
|
627
|
+
releaseTile(tile: PixelTile): void;
|
|
628
|
+
releaseTiles(tiles: (PixelTile | undefined)[]): void;
|
|
629
|
+
}
|
|
630
|
+
|
|
640
631
|
type PixelPatchTiles = {
|
|
641
632
|
beforeTiles: PixelTile[];
|
|
642
633
|
afterTiles: PixelTile[];
|
|
643
634
|
};
|
|
644
635
|
declare function applyPatchTiles(target: IPixelData32, tiles: PixelTile[], tileSize: number): void;
|
|
645
636
|
|
|
637
|
+
type DidChangeFn = (didChange: boolean) => boolean;
|
|
638
|
+
declare class PixelAccumulator {
|
|
639
|
+
readonly config: PixelEngineConfig;
|
|
640
|
+
readonly tilePool: PixelTilePool;
|
|
641
|
+
lookup: (PixelTile | undefined)[];
|
|
642
|
+
beforeTiles: PixelTile[];
|
|
643
|
+
constructor(config: PixelEngineConfig, tilePool: PixelTilePool);
|
|
644
|
+
recyclePatch(patch: PixelPatchTiles): void;
|
|
645
|
+
/**
|
|
646
|
+
* @param x pixel x coordinate
|
|
647
|
+
* @param y pixel y coordinate
|
|
648
|
+
*/
|
|
649
|
+
storePixelBeforeState(x: number, y: number): DidChangeFn;
|
|
650
|
+
/**
|
|
651
|
+
* @param x pixel x coordinate
|
|
652
|
+
* @param y pixel y coordinate
|
|
653
|
+
* @param w pixel width
|
|
654
|
+
* @param h pixel height
|
|
655
|
+
*/
|
|
656
|
+
storeRegionBeforeState(x: number, y: number, w: number, h: number): DidChangeFn;
|
|
657
|
+
storeTileBeforeState(id: number, tx: number, ty: number): DidChangeFn;
|
|
658
|
+
extractState(tile: PixelTile): void;
|
|
659
|
+
extractPatch(): PixelPatchTiles;
|
|
660
|
+
rollbackAfterError(): void;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
interface HistoryAction {
|
|
664
|
+
undo: () => void;
|
|
665
|
+
redo: () => void;
|
|
666
|
+
dispose?: () => void;
|
|
667
|
+
}
|
|
668
|
+
type HistoryActionFactory = typeof makeHistoryAction;
|
|
669
|
+
declare function makeHistoryAction(config: PixelEngineConfig, accumulator: PixelAccumulator, patch: PixelPatchTiles, after?: () => void, afterUndo?: () => void, afterRedo?: () => void, applyPatchTilesFn?: typeof applyPatchTiles): HistoryAction;
|
|
670
|
+
|
|
671
|
+
declare class HistoryManager {
|
|
672
|
+
maxSteps: number;
|
|
673
|
+
readonly undoStack: HistoryAction[];
|
|
674
|
+
readonly redoStack: HistoryAction[];
|
|
675
|
+
readonly listeners: Set<() => void>;
|
|
676
|
+
constructor(maxSteps?: number);
|
|
677
|
+
get canUndo(): boolean;
|
|
678
|
+
get canRedo(): boolean;
|
|
679
|
+
subscribe(fn: () => void): () => boolean;
|
|
680
|
+
notify(): void;
|
|
681
|
+
commit(action: HistoryAction): void;
|
|
682
|
+
undo(): void;
|
|
683
|
+
redo(): void;
|
|
684
|
+
clearRedoStack(): void;
|
|
685
|
+
}
|
|
686
|
+
|
|
646
687
|
/**
|
|
647
688
|
* Non destructively resizes the {@link ImageData} buffer to new dimensions, optionally
|
|
648
689
|
* offsetting the original content.
|
|
@@ -674,27 +715,6 @@ declare function applyPatchTiles(target: IPixelData32, tiles: PixelTile[], tileS
|
|
|
674
715
|
*/
|
|
675
716
|
declare function resizeImageData(target: ImageDataLike, newWidth: number, newHeight: number, offsetX?: number, offsetY?: number): ImageData;
|
|
676
717
|
|
|
677
|
-
declare class PixelEngineConfig {
|
|
678
|
-
readonly tileSize: number;
|
|
679
|
-
readonly tileShift: number;
|
|
680
|
-
readonly tileMask: number;
|
|
681
|
-
readonly tileArea: number;
|
|
682
|
-
readonly target: PixelData;
|
|
683
|
-
readonly targetColumns: number;
|
|
684
|
-
readonly targetRows: number;
|
|
685
|
-
constructor(tileSize: number, target: PixelData);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
declare class PixelTilePool {
|
|
689
|
-
pool: PixelTile[];
|
|
690
|
-
private tileSize;
|
|
691
|
-
private tileArea;
|
|
692
|
-
constructor(config: PixelEngineConfig);
|
|
693
|
-
getTile(id: number, tx: number, ty: number): PixelTile;
|
|
694
|
-
releaseTile(tile: PixelTile): void;
|
|
695
|
-
releaseTiles(tiles: (PixelTile | undefined)[]): void;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
718
|
declare class PaintBuffer {
|
|
699
719
|
readonly config: PixelEngineConfig;
|
|
700
720
|
readonly tilePool: PixelTilePool;
|
|
@@ -722,49 +742,7 @@ declare class PaintBuffer {
|
|
|
722
742
|
* maskType: MaskType.ALPHA
|
|
723
743
|
* });
|
|
724
744
|
*/
|
|
725
|
-
declare function blendPixelData(
|
|
726
|
-
|
|
727
|
-
declare class HistoryManager {
|
|
728
|
-
maxSteps: number;
|
|
729
|
-
readonly undoStack: HistoryAction[];
|
|
730
|
-
readonly redoStack: HistoryAction[];
|
|
731
|
-
readonly listeners: Set<() => void>;
|
|
732
|
-
constructor(maxSteps?: number);
|
|
733
|
-
get canUndo(): boolean;
|
|
734
|
-
get canRedo(): boolean;
|
|
735
|
-
subscribe(fn: () => void): () => boolean;
|
|
736
|
-
notify(): void;
|
|
737
|
-
commit(action: HistoryAction): void;
|
|
738
|
-
undo(): void;
|
|
739
|
-
redo(): void;
|
|
740
|
-
clearRedoStack(): void;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
type DidChangeFn = (didChange: boolean) => boolean;
|
|
744
|
-
declare class PixelAccumulator {
|
|
745
|
-
readonly config: PixelEngineConfig;
|
|
746
|
-
readonly tilePool: PixelTilePool;
|
|
747
|
-
lookup: (PixelTile | undefined)[];
|
|
748
|
-
beforeTiles: PixelTile[];
|
|
749
|
-
constructor(config: PixelEngineConfig, tilePool: PixelTilePool);
|
|
750
|
-
recyclePatch(patch: PixelPatchTiles): void;
|
|
751
|
-
/**
|
|
752
|
-
* @param x pixel x coordinate
|
|
753
|
-
* @param y pixel y coordinate
|
|
754
|
-
*/
|
|
755
|
-
storePixelBeforeState(x: number, y: number): DidChangeFn;
|
|
756
|
-
/**
|
|
757
|
-
* @param x pixel x coordinate
|
|
758
|
-
* @param y pixel y coordinate
|
|
759
|
-
* @param w pixel width
|
|
760
|
-
* @param h pixel height
|
|
761
|
-
*/
|
|
762
|
-
storeRegionBeforeState(x: number, y: number, w: number, h: number): DidChangeFn;
|
|
763
|
-
storeTileBeforeState(id: number, tx: number, ty: number): DidChangeFn;
|
|
764
|
-
extractState(tile: PixelTile): void;
|
|
765
|
-
extractPatch(): PixelPatchTiles;
|
|
766
|
-
rollbackAfterError(): void;
|
|
767
|
-
}
|
|
745
|
+
declare function blendPixelData(target: IPixelData32, src: IPixelData32, opts?: PixelBlendOptions): boolean;
|
|
768
746
|
|
|
769
747
|
interface PixelWriterOptions {
|
|
770
748
|
maxHistorySteps?: number;
|
|
@@ -805,7 +783,7 @@ declare class PixelWriter<M> {
|
|
|
805
783
|
readonly mutator: M;
|
|
806
784
|
private blendPixelDataOpts;
|
|
807
785
|
private _inProgress;
|
|
808
|
-
constructor(target: PixelData, mutatorFactory: (writer: PixelWriter<any>) => M,
|
|
786
|
+
constructor(target: PixelData, mutatorFactory: (writer: PixelWriter<any>) => M, options?: PixelWriterOptions);
|
|
809
787
|
/**
|
|
810
788
|
* Executes `transaction` and commits the resulting pixel changes as a single
|
|
811
789
|
* undoable history action.
|
|
@@ -825,142 +803,240 @@ declare class PixelWriter<M> {
|
|
|
825
803
|
resize(newWidth: number, newHeight: number, offsetX?: number, offsetY?: number, after?: (target: ImageData) => void, afterUndo?: (target: ImageData) => void, afterRedo?: (target: ImageData) => void, resizeImageDataFn?: typeof resizeImageData): void;
|
|
826
804
|
commitPaintBuffer(alpha?: number, blendFn?: BlendColor32, blendPixelDataFn?: typeof blendPixelData): void;
|
|
827
805
|
}
|
|
806
|
+
type HistoryMutator<T extends {}, D extends {}> = (writer: PixelWriter<any>, deps?: Partial<D>) => T;
|
|
828
807
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
808
|
+
declare function makeFullPixelMutator(writer: PixelWriter<any>): {
|
|
809
|
+
invert(opts?: PixelMutateOptions): boolean;
|
|
810
|
+
fillRect(color: Color32, rect: Rect): boolean;
|
|
811
|
+
fillBinaryMask(color: Color32, mask: BinaryMask, x?: number, y?: number): boolean;
|
|
812
|
+
fill(color: Color32, x?: number, y?: number, w?: number, h?: number): boolean;
|
|
813
|
+
clear(rect?: Partial<Rect>): boolean;
|
|
814
|
+
blendPixelData(src: IPixelData32, opts?: PixelBlendOptions): boolean;
|
|
815
|
+
blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
816
|
+
blendPaintRect(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
817
|
+
blendMask(src: IPixelData32, mask: Mask, opts?: PixelBlendMaskOptions): boolean;
|
|
818
|
+
blendColorPaintMask(color: Color32, mask: PaintMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
819
|
+
blendColorPaintBinaryMask(color: Color32, mask: PaintBinaryMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
820
|
+
blendColorPaintAlphaMask(color: Color32, mask: PaintAlphaMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
821
|
+
blendColor(color: Color32, opts?: ColorBlendOptions): boolean;
|
|
822
|
+
blendBinaryMask(src: IPixelData32, mask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
|
|
823
|
+
blendAlphaMask(src: IPixelData32, mask: AlphaMask, opts?: PixelBlendMaskOptions): boolean;
|
|
824
|
+
applyMask(mask: Mask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
825
|
+
applyBinaryMask(mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
826
|
+
applyAlphaMask(mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Directly applies a mask to a region of PixelData,
|
|
831
|
+
* modifying the destination's alpha channel in-place.
|
|
832
|
+
* @returns true if any pixels were actually modified.
|
|
833
|
+
*/
|
|
834
|
+
declare function applyAlphaMaskToPixelData(target: IPixelData32, mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
835
|
+
|
|
836
|
+
declare const defaults$g: {
|
|
837
|
+
applyAlphaMaskToPixelData: typeof applyAlphaMaskToPixelData;
|
|
838
|
+
};
|
|
839
|
+
type Deps$g = Partial<typeof defaults$g>;
|
|
840
|
+
/**
|
|
841
|
+
* @param deps - @hidden
|
|
842
|
+
*/
|
|
843
|
+
declare const mutatorApplyAlphaMask: (writer: PixelWriter<any>, deps?: Deps$g) => {
|
|
844
|
+
applyAlphaMask(mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Directly applies a mask to a region of PixelData,
|
|
849
|
+
* modifying the destination's alpha channel in-place.
|
|
850
|
+
* @returns true if any pixels were actually modified.
|
|
851
|
+
*/
|
|
852
|
+
declare function applyBinaryMaskToPixelData(target: IPixelData32, mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
853
|
+
|
|
854
|
+
declare const defaults$f: {
|
|
855
|
+
applyBinaryMaskToPixelData: typeof applyBinaryMaskToPixelData;
|
|
856
|
+
};
|
|
857
|
+
type Deps$f = Partial<typeof defaults$f>;
|
|
858
|
+
/**
|
|
859
|
+
* @param deps - @hidden
|
|
860
|
+
*/
|
|
861
|
+
declare const mutatorApplyBinaryMask: (writer: PixelWriter<any>, deps?: Deps$f) => {
|
|
862
|
+
applyBinaryMask(mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
declare const defaults$e: {
|
|
866
|
+
applyBinaryMaskToPixelData: typeof applyBinaryMaskToPixelData;
|
|
867
|
+
applyAlphaMaskToPixelData: typeof applyAlphaMaskToPixelData;
|
|
868
|
+
};
|
|
869
|
+
type Deps$e = Partial<typeof defaults$e>;
|
|
870
|
+
/**
|
|
871
|
+
* @param deps - @hidden
|
|
872
|
+
*/
|
|
873
|
+
declare const mutatorApplyMask: (writer: PixelWriter<any>, deps?: Deps$e) => {
|
|
874
|
+
applyMask(mask: Mask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
declare function blendPixelDataAlphaMask(target: IPixelData32, src: IPixelData32, alphaMask: AlphaMask, opts?: PixelBlendMaskOptions): boolean;
|
|
878
|
+
|
|
879
|
+
declare const defaults$d: {
|
|
880
|
+
blendPixelDataAlphaMask: typeof blendPixelDataAlphaMask;
|
|
881
|
+
};
|
|
882
|
+
type Deps$d = Partial<typeof defaults$d>;
|
|
883
|
+
/**
|
|
884
|
+
* @param deps - @hidden
|
|
885
|
+
*/
|
|
886
|
+
declare const mutatorBlendAlphaMask: (writer: PixelWriter<any>, deps?: Partial<Deps$d>) => {
|
|
887
|
+
blendAlphaMask(src: IPixelData32, mask: AlphaMask, opts?: PixelBlendMaskOptions): boolean;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
declare function blendPixelDataBinaryMask(target: IPixelData32, src: IPixelData32, binaryMask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
|
|
891
|
+
|
|
892
|
+
declare const defaults$c: {
|
|
893
|
+
blendPixelDataBinaryMask: typeof blendPixelDataBinaryMask;
|
|
894
|
+
};
|
|
895
|
+
type Deps$c = Partial<typeof defaults$c>;
|
|
896
|
+
/**
|
|
897
|
+
* @param deps - @hidden
|
|
898
|
+
*/
|
|
899
|
+
declare const mutatorBlendBinaryMask: (writer: PixelWriter<any>, deps?: Partial<Deps$c>) => {
|
|
900
|
+
blendBinaryMask(src: IPixelData32, mask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Blends a solid color into a target pixel buffer.
|
|
905
|
+
* @returns true if any pixels were actually modified.
|
|
906
|
+
*/
|
|
907
|
+
declare function blendColorPixelData(target: IPixelData32, color: Color32, opts?: ColorBlendOptions): boolean;
|
|
836
908
|
|
|
837
|
-
declare
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
blendPixelData(src: IPixelData32, opts?: PixelBlendOptions): boolean;
|
|
846
|
-
blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
909
|
+
declare const defaults$b: {
|
|
910
|
+
blendColorPixelData: typeof blendColorPixelData;
|
|
911
|
+
};
|
|
912
|
+
type Deps$b = Partial<typeof defaults$b>;
|
|
913
|
+
/**
|
|
914
|
+
* @param deps - @hidden
|
|
915
|
+
*/
|
|
916
|
+
declare const mutatorBlendColor: (writer: PixelWriter<any>, deps?: Deps$b) => {
|
|
847
917
|
blendColor(color: Color32, opts?: ColorBlendOptions): boolean;
|
|
848
918
|
};
|
|
849
919
|
|
|
850
920
|
/**
|
|
851
|
-
*
|
|
852
|
-
*
|
|
921
|
+
* Blends a solid color into a target pixel buffer using an alpha mask.
|
|
922
|
+
*
|
|
923
|
+
* @remarks
|
|
924
|
+
* If the width (`w`) or height (`h`) are omitted from the options, they will safely
|
|
925
|
+
* default to the dimensions of the provided mask to prevent out-of-bounds memory access.
|
|
926
|
+
*
|
|
927
|
+
* @param target - The destination {@link IPixelData32} buffer to modify.
|
|
928
|
+
* @param color - The solid color to apply.
|
|
929
|
+
* @param mask - The mask defining the per-pixel opacity of the target area.
|
|
930
|
+
* @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
|
|
853
931
|
* @returns true if any pixels were actually modified.
|
|
854
932
|
*/
|
|
855
|
-
declare function
|
|
933
|
+
declare function blendColorPixelDataAlphaMask(target: IPixelData32, color: Color32, mask: AlphaMask, opts?: ColorBlendMaskOptions): boolean;
|
|
856
934
|
|
|
857
935
|
declare const defaults$a: {
|
|
858
|
-
|
|
936
|
+
blendColorPixelDataAlphaMask: typeof blendColorPixelDataAlphaMask;
|
|
859
937
|
};
|
|
860
938
|
type Deps$a = Partial<typeof defaults$a>;
|
|
861
939
|
/**
|
|
862
940
|
* @param deps - @hidden
|
|
863
941
|
*/
|
|
864
|
-
declare const
|
|
865
|
-
|
|
942
|
+
declare const mutatorBlendColorPaintAlphaMask: (writer: PixelWriter<any>, deps?: Partial<Deps$a>) => {
|
|
943
|
+
blendColorPaintAlphaMask(color: Color32, mask: PaintAlphaMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
866
944
|
};
|
|
867
945
|
|
|
868
946
|
/**
|
|
869
|
-
*
|
|
870
|
-
*
|
|
947
|
+
* Blends a solid color into a target pixel buffer using a binary mask.
|
|
948
|
+
*
|
|
949
|
+
* @remarks
|
|
950
|
+
* If the width (`w`) or height (`h`) are omitted from the options, they will safely
|
|
951
|
+
* default to the dimensions of the provided mask to prevent out-of-bounds memory access.
|
|
952
|
+
*
|
|
953
|
+
* @param target - The destination {@link IPixelData32} buffer to modify.
|
|
954
|
+
* @param color - The solid color to apply.
|
|
955
|
+
* @param mask - The mask defining the per-pixel opacity of the target area.
|
|
956
|
+
* @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
|
|
871
957
|
* @returns true if any pixels were actually modified.
|
|
872
958
|
*/
|
|
873
|
-
declare function
|
|
959
|
+
declare function blendColorPixelDataBinaryMask(target: IPixelData32, color: Color32, mask: BinaryMask, opts?: ColorBlendMaskOptions): boolean;
|
|
874
960
|
|
|
875
961
|
declare const defaults$9: {
|
|
876
|
-
|
|
962
|
+
blendColorPixelDataBinaryMask: typeof blendColorPixelDataBinaryMask;
|
|
877
963
|
};
|
|
878
964
|
type Deps$9 = Partial<typeof defaults$9>;
|
|
879
965
|
/**
|
|
880
966
|
* @param deps - @hidden
|
|
881
967
|
*/
|
|
882
|
-
declare const
|
|
883
|
-
|
|
968
|
+
declare const mutatorBlendColorPaintBinaryMask: (writer: PixelWriter<any>, deps?: Partial<Deps$9>) => {
|
|
969
|
+
blendColorPaintBinaryMask(color: Color32, mask: PaintBinaryMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
884
970
|
};
|
|
885
971
|
|
|
886
|
-
/**
|
|
887
|
-
* Blends a solid color into a target pixel buffer.
|
|
888
|
-
* @returns true if any pixels were actually modified.
|
|
889
|
-
*/
|
|
890
|
-
declare function blendColorPixelData(dst: IPixelData32, color: Color32, opts?: ColorBlendOptions): boolean;
|
|
891
|
-
|
|
892
972
|
declare const defaults$8: {
|
|
893
|
-
|
|
973
|
+
blendColorPixelDataAlphaMask: typeof blendColorPixelDataAlphaMask;
|
|
974
|
+
blendColorPixelDataBinaryMask: typeof blendColorPixelDataBinaryMask;
|
|
894
975
|
};
|
|
895
976
|
type Deps$8 = Partial<typeof defaults$8>;
|
|
896
977
|
/**
|
|
897
978
|
* @param deps - @hidden
|
|
898
979
|
*/
|
|
899
|
-
declare const
|
|
900
|
-
|
|
980
|
+
declare const mutatorBlendColorPaintMask: (writer: PixelWriter<any>, deps?: Partial<Deps$8>) => {
|
|
981
|
+
blendColorPaintMask(color: Color32, mask: PaintMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
901
982
|
};
|
|
902
983
|
|
|
903
|
-
declare function blendPixel(target: IPixelData32, x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
904
|
-
|
|
905
984
|
declare const defaults$7: {
|
|
906
|
-
|
|
985
|
+
blendPixelDataAlphaMask: typeof blendPixelDataAlphaMask;
|
|
986
|
+
blendPixelDataBinaryMask: typeof blendPixelDataBinaryMask;
|
|
907
987
|
};
|
|
908
988
|
type Deps$7 = Partial<typeof defaults$7>;
|
|
909
989
|
/**
|
|
910
990
|
* @param deps - @hidden
|
|
911
991
|
*/
|
|
912
|
-
declare const
|
|
913
|
-
|
|
992
|
+
declare const mutatorBlendMask: (writer: PixelWriter<any>, deps?: Partial<Deps$7>) => {
|
|
993
|
+
blendMask(src: IPixelData32, mask: Mask, opts?: PixelBlendMaskOptions): boolean;
|
|
914
994
|
};
|
|
915
995
|
|
|
916
996
|
declare const defaults$6: {
|
|
917
|
-
|
|
997
|
+
blendColorPixelData: typeof blendColorPixelData;
|
|
918
998
|
};
|
|
919
999
|
type Deps$6 = Partial<typeof defaults$6>;
|
|
920
1000
|
/**
|
|
921
1001
|
* @param deps - @hidden
|
|
922
1002
|
*/
|
|
923
|
-
declare const
|
|
924
|
-
|
|
1003
|
+
declare const mutatorBlendPaintRect: (writer: PixelWriter<any>, deps?: Deps$6) => {
|
|
1004
|
+
blendPaintRect(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
925
1005
|
};
|
|
926
1006
|
|
|
927
|
-
declare function
|
|
1007
|
+
declare function blendPixel(target: IPixelData32, x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
928
1008
|
|
|
929
1009
|
declare const defaults$5: {
|
|
930
|
-
|
|
1010
|
+
blendPixel: typeof blendPixel;
|
|
931
1011
|
};
|
|
932
1012
|
type Deps$5 = Partial<typeof defaults$5>;
|
|
933
1013
|
/**
|
|
934
1014
|
* @param deps - @hidden
|
|
935
1015
|
*/
|
|
936
|
-
declare const
|
|
937
|
-
|
|
1016
|
+
declare const mutatorBlendPixel: (writer: PixelWriter<any>, deps?: Partial<Deps$5>) => {
|
|
1017
|
+
blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
938
1018
|
};
|
|
939
1019
|
|
|
940
|
-
declare function blendPixelDataBinaryMask(dst: IPixelData32, src: IPixelData32, binaryMask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
|
|
941
|
-
|
|
942
1020
|
declare const defaults$4: {
|
|
943
|
-
|
|
1021
|
+
blendPixelData: typeof blendPixelData;
|
|
944
1022
|
};
|
|
945
1023
|
type Deps$4 = Partial<typeof defaults$4>;
|
|
946
1024
|
/**
|
|
947
1025
|
* @param deps - @hidden
|
|
948
1026
|
*/
|
|
949
|
-
declare const
|
|
950
|
-
|
|
1027
|
+
declare const mutatorBlendPixelData: (writer: PixelWriter<any>, deps?: Partial<Deps$4>) => {
|
|
1028
|
+
blendPixelData(src: IPixelData32, opts?: PixelBlendOptions): boolean;
|
|
951
1029
|
};
|
|
952
1030
|
|
|
953
1031
|
/**
|
|
954
1032
|
* Fills a region or the {@link IPixelData32} buffer with a solid color.
|
|
955
|
-
* This function is faster than {@link fillPixelData} but does not
|
|
956
|
-
* return a boolean value indicating changes were made.
|
|
957
1033
|
*
|
|
958
1034
|
* @param dst - The target to modify.
|
|
959
1035
|
* @param color - The color to apply.
|
|
960
1036
|
* @param rect - Defines the area to fill. If omitted, the entire
|
|
961
|
-
*
|
|
1037
|
+
* @returns true if any pixels were actually modified.
|
|
962
1038
|
*/
|
|
963
|
-
declare function
|
|
1039
|
+
declare function fillPixelData(dst: IPixelData32, color: Color32, rect?: Partial<Rect>): boolean;
|
|
964
1040
|
/**
|
|
965
1041
|
* @param dst - The target to modify.
|
|
966
1042
|
* @param color - The color to apply.
|
|
@@ -969,38 +1045,19 @@ declare function fillPixelDataFast(dst: IPixelData32, color: Color32, rect?: Par
|
|
|
969
1045
|
* @param w - Width of the fill area.
|
|
970
1046
|
* @param h - Height of the fill area.
|
|
971
1047
|
*/
|
|
972
|
-
declare function
|
|
1048
|
+
declare function fillPixelData(dst: IPixelData32, color: Color32, x: number, y: number, w: number, h: number): boolean;
|
|
973
1049
|
|
|
974
1050
|
declare const defaults$3: {
|
|
975
|
-
fillPixelData: typeof
|
|
1051
|
+
fillPixelData: typeof fillPixelData;
|
|
976
1052
|
};
|
|
977
1053
|
type Deps$3 = Partial<typeof defaults$3>;
|
|
978
1054
|
/**
|
|
979
1055
|
* @param deps - @hidden
|
|
980
1056
|
*/
|
|
981
1057
|
declare const mutatorClear: (writer: PixelWriter<any>, deps?: Deps$3) => {
|
|
982
|
-
clear(rect?: Partial<Rect>):
|
|
1058
|
+
clear(rect?: Partial<Rect>): boolean;
|
|
983
1059
|
};
|
|
984
1060
|
|
|
985
|
-
/**
|
|
986
|
-
* Fills a region or the {@link IPixelData32} buffer with a solid color.
|
|
987
|
-
*
|
|
988
|
-
* @param dst - The target to modify.
|
|
989
|
-
* @param color - The color to apply.
|
|
990
|
-
* @param rect - Defines the area to fill. If omitted, the entire
|
|
991
|
-
* @returns true if any pixels were actually modified.
|
|
992
|
-
*/
|
|
993
|
-
declare function fillPixelData(dst: IPixelData32, color: Color32, rect?: Partial<Rect>): boolean;
|
|
994
|
-
/**
|
|
995
|
-
* @param dst - The target to modify.
|
|
996
|
-
* @param color - The color to apply.
|
|
997
|
-
* @param x - Starting horizontal coordinate.
|
|
998
|
-
* @param y - Starting vertical coordinate.
|
|
999
|
-
* @param w - Width of the fill area.
|
|
1000
|
-
* @param h - Height of the fill area.
|
|
1001
|
-
*/
|
|
1002
|
-
declare function fillPixelData(dst: IPixelData32, color: Color32, x: number, y: number, w: number, h: number): boolean;
|
|
1003
|
-
|
|
1004
1061
|
declare const defaults$2: {
|
|
1005
1062
|
fillPixelData: typeof fillPixelData;
|
|
1006
1063
|
};
|
|
@@ -1020,14 +1077,13 @@ declare const mutatorFillRect: (writer: PixelWriter<any>, deps?: Deps$2) => {
|
|
|
1020
1077
|
|
|
1021
1078
|
/**
|
|
1022
1079
|
* Fills a region of the {@link IPixelData32} buffer with a solid color using a mask.
|
|
1023
|
-
* @param
|
|
1080
|
+
* @param target - The target to modify.
|
|
1024
1081
|
* @param color - The color to apply.
|
|
1025
1082
|
* @param mask - The mask defining the area to fill.
|
|
1026
|
-
* @param alpha - The overall opacity of the fill (0-255).
|
|
1027
1083
|
* @param x - Starting horizontal coordinate for the mask placement.
|
|
1028
1084
|
* @param y - Starting vertical coordinate for the mask placement.
|
|
1029
1085
|
*/
|
|
1030
|
-
declare function fillPixelDataBinaryMask(
|
|
1086
|
+
declare function fillPixelDataBinaryMask(target: IPixelData32, color: Color32, mask: BinaryMask, x?: number, y?: number): boolean;
|
|
1031
1087
|
|
|
1032
1088
|
declare const defaults$1: {
|
|
1033
1089
|
fillPixelDataBinaryMask: typeof fillPixelDataBinaryMask;
|
|
@@ -1037,10 +1093,10 @@ type Deps$1 = Partial<typeof defaults$1>;
|
|
|
1037
1093
|
* @param deps - @hidden
|
|
1038
1094
|
*/
|
|
1039
1095
|
declare const mutatorFillBinaryMask: (writer: PixelWriter<any>, deps?: Deps$1) => {
|
|
1040
|
-
fillBinaryMask(color: Color32, mask: BinaryMask,
|
|
1096
|
+
fillBinaryMask(color: Color32, mask: BinaryMask, x?: number, y?: number): boolean;
|
|
1041
1097
|
};
|
|
1042
1098
|
|
|
1043
|
-
declare function invertPixelData(
|
|
1099
|
+
declare function invertPixelData(target: IPixelData32, opts?: PixelMutateOptions): boolean;
|
|
1044
1100
|
|
|
1045
1101
|
declare const defaults: {
|
|
1046
1102
|
invertPixelData: typeof invertPixelData;
|
|
@@ -1053,6 +1109,17 @@ declare const mutatorInvert: (writer: PixelWriter<any>, deps?: Deps) => {
|
|
|
1053
1109
|
invert(opts?: PixelMutateOptions): boolean;
|
|
1054
1110
|
};
|
|
1055
1111
|
|
|
1112
|
+
declare function makeImageDataLike(width: number, height: number, data?: Buffer): ImageDataLike;
|
|
1113
|
+
|
|
1114
|
+
type ReusableImageData = ReturnType<typeof makeReusableImageData>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Creates a factory function that manages a single, reusable ImageData instance.
|
|
1117
|
+
* This is used to minimize garbage collection overhead by recycling the
|
|
1118
|
+
* underlying pixel buffer across multiple operations.
|
|
1119
|
+
* @returns A function that takes width and height and returns a pooled ImageData instance.
|
|
1120
|
+
*/
|
|
1121
|
+
declare function makeReusableImageData(): (width: number, height: number) => ImageData;
|
|
1122
|
+
|
|
1056
1123
|
declare function copyImageData({ data, width, height }: ImageDataLike): ImageData;
|
|
1057
1124
|
declare function copyImageDataLike({ data, width, height }: ImageDataLike): ImageDataLike;
|
|
1058
1125
|
|
|
@@ -1077,8 +1144,6 @@ declare function extractImageDataBuffer(imageData: ImageDataLike, rect: Rect): U
|
|
|
1077
1144
|
*/
|
|
1078
1145
|
declare function extractImageDataBuffer(imageData: ImageDataLike, x: number, y: number, w: number, h: number): Uint8ClampedArray;
|
|
1079
1146
|
|
|
1080
|
-
declare function makeImageDataLike(width: number, height: number, data?: Buffer): ImageDataLike;
|
|
1081
|
-
|
|
1082
1147
|
/**
|
|
1083
1148
|
* Extracts the alpha channel from raw ImageData into an AlphaMask.
|
|
1084
1149
|
* When possible use {@link pixelDataToAlphaMask} instead.
|
|
@@ -1165,15 +1230,6 @@ declare function invertImageData(imageData: ImageData): ImageData;
|
|
|
1165
1230
|
*/
|
|
1166
1231
|
declare function resampleImageData(source: ImageData, factor: number): ImageData;
|
|
1167
1232
|
|
|
1168
|
-
type ReusableImageData = ReturnType<typeof makeReusableImageData>;
|
|
1169
|
-
/**
|
|
1170
|
-
* Creates a factory function that manages a single, reusable ImageData instance.
|
|
1171
|
-
* This is used to minimize garbage collection overhead by recycling the
|
|
1172
|
-
* underlying pixel buffer across multiple operations.
|
|
1173
|
-
* @returns A function that takes width and height and returns a pooled ImageData instance.
|
|
1174
|
-
*/
|
|
1175
|
-
declare function makeReusableImageData(): (width: number, height: number) => ImageData;
|
|
1176
|
-
|
|
1177
1233
|
declare function base64EncodeArrayBuffer(buffer: ArrayBufferLike): Base64EncodedUInt8Array;
|
|
1178
1234
|
declare function base64DecodeArrayBuffer(encoded: Base64EncodedUInt8Array): Uint8ClampedArray<ArrayBuffer>;
|
|
1179
1235
|
/**
|
|
@@ -1395,6 +1451,49 @@ declare function fileToImageData(file: File | null | undefined): Promise<ImageDa
|
|
|
1395
1451
|
*/
|
|
1396
1452
|
declare function getSupportedPixelFormats(rasterMimes?: string[]): Promise<string[]>;
|
|
1397
1453
|
|
|
1454
|
+
/**
|
|
1455
|
+
* @internal
|
|
1456
|
+
*/
|
|
1457
|
+
type Resample32Result = {
|
|
1458
|
+
data: Int32Array;
|
|
1459
|
+
width: number;
|
|
1460
|
+
height: number;
|
|
1461
|
+
};
|
|
1462
|
+
/**
|
|
1463
|
+
* @internal
|
|
1464
|
+
*/
|
|
1465
|
+
declare function resample32(srcData32: Uint32Array | Int32Array, srcW: number, srcH: number, factor: number): Resample32Result;
|
|
1466
|
+
|
|
1467
|
+
type ClippedRect = {
|
|
1468
|
+
x: number;
|
|
1469
|
+
y: number;
|
|
1470
|
+
w: number;
|
|
1471
|
+
h: number;
|
|
1472
|
+
inBounds: boolean;
|
|
1473
|
+
};
|
|
1474
|
+
type ClippedBlit = {
|
|
1475
|
+
x: number;
|
|
1476
|
+
y: number;
|
|
1477
|
+
sx: number;
|
|
1478
|
+
sy: number;
|
|
1479
|
+
w: number;
|
|
1480
|
+
h: number;
|
|
1481
|
+
inBounds: boolean;
|
|
1482
|
+
};
|
|
1483
|
+
declare const makeClippedRect: () => ClippedRect;
|
|
1484
|
+
declare const makeClippedBlit: () => ClippedBlit;
|
|
1485
|
+
/**
|
|
1486
|
+
* Calculates the intersection of a target rectangle and a bounding box (usually 0,0 -> width,height).
|
|
1487
|
+
* Handles negative offsets by shrinking dimensions.
|
|
1488
|
+
*/
|
|
1489
|
+
declare function resolveRectClipping(x: number, y: number, w: number, h: number, boundaryW: number, boundaryH: number, out: ClippedRect): ClippedRect;
|
|
1490
|
+
/**
|
|
1491
|
+
* Calculates the clipping for transferring data from a Source to a Destination.
|
|
1492
|
+
* Handles cases where the source is out of bounds (shifting the destination target)
|
|
1493
|
+
* AND cases where the destination is out of bounds (shifting the source target).
|
|
1494
|
+
*/
|
|
1495
|
+
declare function resolveBlitClipping(x: number, y: number, sx: number, sy: number, w: number, h: number, dstW: number, dstH: number, srcW: number, srcH: number, out: ClippedBlit): ClippedBlit;
|
|
1496
|
+
|
|
1398
1497
|
/**
|
|
1399
1498
|
* Creates an Alpha Mask
|
|
1400
1499
|
* @param w - width
|
|
@@ -1485,43 +1584,44 @@ declare function mergeBinaryMaskRects(current: NullableBinaryMaskRect[], adding:
|
|
|
1485
1584
|
|
|
1486
1585
|
declare function subtractBinaryMaskRects(current: NullableBinaryMaskRect[], subtracting: NullableBinaryMaskRect[]): NullableBinaryMaskRect[];
|
|
1487
1586
|
|
|
1587
|
+
type PaintBufferCanvasRenderer = ReturnType<typeof makePaintBufferCanvasRenderer>;
|
|
1488
1588
|
/**
|
|
1489
|
-
* Blends a solid color into a target pixel buffer using an alpha mask.
|
|
1490
|
-
*
|
|
1491
|
-
* @remarks
|
|
1492
|
-
* If the width (`w`) or height (`h`) are omitted from the options, they will safely
|
|
1493
|
-
* default to the dimensions of the provided mask to prevent out-of-bounds memory access.
|
|
1494
1589
|
*
|
|
1495
|
-
* @param
|
|
1496
|
-
* @param color - The solid color to apply.
|
|
1497
|
-
* @param mask - The mask defining the per-pixel opacity of the target area.
|
|
1498
|
-
* @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
|
|
1499
|
-
* @returns true if any pixels were actually modified.
|
|
1590
|
+
* @param offscreenCanvasClass - @internal
|
|
1500
1591
|
*/
|
|
1501
|
-
declare function
|
|
1592
|
+
declare function makePaintBufferCanvasRenderer(paintBuffer: PaintBuffer, offscreenCanvasClass?: {
|
|
1593
|
+
new (width: number, height: number): OffscreenCanvas;
|
|
1594
|
+
prototype: OffscreenCanvas;
|
|
1595
|
+
}): (targetCtx: CanvasRenderingContext2D, alpha?: number, compOperation?: GlobalCompositeOperation) => void;
|
|
1502
1596
|
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
*/
|
|
1516
|
-
declare function blendColorPixelDataBinaryMask(dst: IPixelData32, color: Color32, mask: BinaryMask, opts?: ColorBlendMaskOptions): boolean;
|
|
1597
|
+
declare function makeCirclePaintAlphaMask(size: number, fallOff?: (d: number) => number): PaintAlphaMask;
|
|
1598
|
+
|
|
1599
|
+
declare function makeCirclePaintBinaryMask(size: number): PaintBinaryMask;
|
|
1600
|
+
|
|
1601
|
+
declare function makePaintBinaryMask(mask: BinaryMask): PaintBinaryMask;
|
|
1602
|
+
declare function makePaintAlphaMask(mask: AlphaMask): PaintAlphaMask;
|
|
1603
|
+
|
|
1604
|
+
declare function makeRectFalloffPaintAlphaMask(width: number, height: number, fallOff?: (d: number) => number): PaintAlphaMask;
|
|
1605
|
+
|
|
1606
|
+
declare function applyMaskToPixelData(dst: IPixelData32, mask: Mask, opts?: ApplyMaskToPixelDataOptions): boolean;
|
|
1607
|
+
|
|
1608
|
+
declare function blendColorPixelDataMask(dst: IPixelData32, color: Color32, mask: Mask, opts?: ColorBlendMaskOptions): boolean;
|
|
1517
1609
|
|
|
1518
|
-
declare function
|
|
1610
|
+
declare function blendColorPixelDataPaintAlphaMask(dst: IPixelData32, color: Color32, mask: PaintAlphaMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
1611
|
+
|
|
1612
|
+
declare function blendColorPixelDataPaintBinaryMask(dst: IPixelData32, color: Color32, mask: PaintBinaryMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
1613
|
+
|
|
1614
|
+
declare function blendColorPixelDataPaintMask(dst: IPixelData32, color: Color32, mask: PaintMask, x: number, y: number, alpha?: number, blendFn?: BlendColor32): boolean;
|
|
1615
|
+
|
|
1616
|
+
declare function blendPixelDataMask(target: IPixelData32, src: IPixelData32, mask: Mask, opts?: PixelBlendMaskOptions): boolean;
|
|
1617
|
+
|
|
1618
|
+
declare function blendPixelDataPaintBuffer(target: IPixelData32, paintBuffer: PaintBuffer, alpha?: number, blendFn?: BlendColor32, blendPixelDataFn?: typeof blendPixelData): void;
|
|
1519
1619
|
|
|
1520
1620
|
/**
|
|
1521
1621
|
* Clears a region of the PixelData to transparent (0x00000000).
|
|
1522
|
-
* Internally uses the optimized
|
|
1622
|
+
* Internally uses the optimized fillPixelDataFast.
|
|
1523
1623
|
*/
|
|
1524
|
-
declare function
|
|
1624
|
+
declare function clearPixelDataFast(dst: IPixelData32, rect?: Partial<BinaryMaskRect>): void;
|
|
1525
1625
|
|
|
1526
1626
|
/**
|
|
1527
1627
|
* High-level extraction that returns a new PixelData instance.
|
|
@@ -1537,14 +1637,26 @@ declare function extractPixelData(source: IPixelData32, x: number, y: number, w:
|
|
|
1537
1637
|
declare function extractPixelDataBuffer(source: IPixelData32, rect: Rect): Uint32Array;
|
|
1538
1638
|
declare function extractPixelDataBuffer(source: IPixelData32, x: number, y: number, w: number, h: number): Uint32Array;
|
|
1539
1639
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1640
|
+
/**
|
|
1641
|
+
* Fills a region or the {@link IPixelData32} buffer with a solid color.
|
|
1642
|
+
* This function is faster than {@link fillPixelData} but does not
|
|
1643
|
+
* return a boolean value indicating changes were made.
|
|
1644
|
+
*
|
|
1645
|
+
* @param target - The target to modify.
|
|
1646
|
+
* @param color - The color to apply.
|
|
1647
|
+
* @param rect - Defines the area to fill. If omitted, the entire
|
|
1648
|
+
* buffer is filled.
|
|
1649
|
+
*/
|
|
1650
|
+
declare function fillPixelDataFast(target: IPixelData32, color: Color32, rect?: Partial<Rect>): void;
|
|
1651
|
+
/**
|
|
1652
|
+
* @param dst - The target to modify.
|
|
1653
|
+
* @param color - The color to apply.
|
|
1654
|
+
* @param x - Starting horizontal coordinate.
|
|
1655
|
+
* @param y - Starting vertical coordinate.
|
|
1656
|
+
* @param w - Width of the fill area.
|
|
1657
|
+
* @param h - Height of the fill area.
|
|
1658
|
+
*/
|
|
1659
|
+
declare function fillPixelDataFast(dst: IPixelData32, color: Color32, x: number, y: number, w: number, h: number): void;
|
|
1548
1660
|
|
|
1549
1661
|
/**
|
|
1550
1662
|
* Extracts the alpha channel from PixelData into a single-channel mask.
|
|
@@ -1602,23 +1714,45 @@ declare function trimMaskRectBounds<T extends NullableMaskRect>(target: T, bound
|
|
|
1602
1714
|
|
|
1603
1715
|
declare function trimRectBounds(x: number, y: number, w: number, h: number, targetWidth: number, targetHeight: number, out?: Rect): Rect;
|
|
1604
1716
|
|
|
1605
|
-
declare function makeCirclePaintAlphaMask(size: number, fallOff?: (d: number) => number): PaintAlphaMask;
|
|
1606
|
-
|
|
1607
|
-
declare function makeCirclePaintBinaryMask(size: number): PaintBinaryMask;
|
|
1608
|
-
|
|
1609
|
-
declare function makePaintBinaryMask(mask: BinaryMask): PaintBinaryMask;
|
|
1610
|
-
declare function makePaintAlphaMask(mask: AlphaMask): PaintAlphaMask;
|
|
1611
|
-
|
|
1612
|
-
declare function makeRectFalloffPaintAlphaMask(width: number, height: number, fallOff?: (d: number) => number): PaintAlphaMask;
|
|
1613
|
-
|
|
1614
|
-
type PaintBufferCanvasRenderer = ReturnType<typeof makePaintBufferCanvasRenderer>;
|
|
1615
1717
|
/**
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
1718
|
+
* Packs RGBA into a 32-bit integer compatible with
|
|
1719
|
+
* Little-Endian Uint32Array views on ImageData.
|
|
1618
1720
|
*/
|
|
1619
|
-
declare function
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1721
|
+
declare function packColor(r: number, g: number, b: number, a: number): Color32;
|
|
1722
|
+
declare function packRGBA({ r, g, b, a }: RGBA): Color32;
|
|
1723
|
+
declare const unpackRed: (packed: Color32) => number;
|
|
1724
|
+
declare const unpackGreen: (packed: Color32) => number;
|
|
1725
|
+
declare const unpackBlue: (packed: Color32) => number;
|
|
1726
|
+
declare const unpackAlpha: (packed: Color32) => number;
|
|
1727
|
+
declare function unpackColor(packed: Color32): RGBA;
|
|
1728
|
+
declare function unpackColorTo(packed: Color32, scratch?: RGBA): RGBA;
|
|
1729
|
+
declare function colorDistance(a: Color32, b: Color32): number;
|
|
1730
|
+
/**
|
|
1731
|
+
* Linearly interpolates between two 32-bit colors using a floating-point weight.
|
|
1732
|
+
* * This is the preferred method for UI animations or scenarios where high
|
|
1733
|
+
* precision is required. It uses the standard `a + t * (b - a)` formula
|
|
1734
|
+
* for each channel.
|
|
1735
|
+
* @param a - The starting color as a 32-bit integer (AABBGGRR).
|
|
1736
|
+
* @param b - The target color as a 32-bit integer (AABBGGRR).
|
|
1737
|
+
* @param t - The interpolation factor between 0.0 and 1.0.
|
|
1738
|
+
* @returns The interpolated 32-bit color.
|
|
1739
|
+
*/
|
|
1740
|
+
declare function lerpColor32(a: Color32, b: Color32, t: number): Color32;
|
|
1741
|
+
/**
|
|
1742
|
+
* Linearly interpolates between two 32-bit colors using integer fixed-point math.
|
|
1743
|
+
* Highly optimized for image processing and real-time blitting. It processes
|
|
1744
|
+
* channels in parallel using bitmasks (RB and GA pairs).
|
|
1745
|
+
* **Note:** Subject to a 1-bit drift (rounding down) due to fast bit-shift division.
|
|
1746
|
+
* @param src - The source (foreground) color as a 32-bit integer.
|
|
1747
|
+
* @param dst - The destination (background) color as a 32-bit integer.
|
|
1748
|
+
* @param w - The blend weight as a byte value from 0 to 255. Where 0 is 100% dst and 255 is 100% src
|
|
1749
|
+
* @returns The blended 32-bit color.
|
|
1750
|
+
*/ declare function lerpColor32Fast(src: Color32, dst: Color32, w: number): Color32;
|
|
1751
|
+
declare function color32ToHex(color: Color32): string;
|
|
1752
|
+
/**
|
|
1753
|
+
* Converts a 32-bit integer (0xAABBGGRR) to a CSS rgba() string.
|
|
1754
|
+
* Example: 0xFF0000FF -> "rgba(255,0,0,1)"
|
|
1755
|
+
*/
|
|
1756
|
+
declare function color32ToCssRGBA(color: Color32): string;
|
|
1623
1757
|
|
|
1624
|
-
export { type AlphaMask, type AlphaMaskRect, type ApplyMaskToPixelDataOptions, BASE_FAST_BLEND_MODE_FUNCTIONS, BASE_PERFECT_BLEND_MODE_FUNCTIONS, type Base64EncodedUInt8Array, BaseBlendMode, type BaseBlendModes, type BasePixelBlendOptions, type BinaryMask, type BinaryMaskRect, type BlendColor32, type BlendModeRegistry,
|
|
1758
|
+
export { type AlphaMask, type AlphaMaskRect, type ApplyMaskToPixelDataOptions, BASE_FAST_BLEND_MODE_FUNCTIONS, BASE_PERFECT_BLEND_MODE_FUNCTIONS, type Base64EncodedUInt8Array, BaseBlendMode, type BaseBlendModes, type BaseMask, type BasePixelBlendOptions, type BinaryMask, type BinaryMaskRect, type BlendColor32, type BlendModeRegistry, CANVAS_COMPOSITE_MAP, type CanvasBlendModeIndex, type CanvasCompositeOperation, type CanvasContext, type CanvasFrameRenderer, type ClippedBlit, type ClippedRect, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, type ColorBlendPaintMaskOptions, type DidChangeFn, type DrawPixelLayer, type DrawScreenLayer, type FloodFillResult, type HistoryAction, type HistoryActionFactory, HistoryManager, type HistoryMutator, type IPixelData, type IPixelData32, type ImageDataLike, type ImageDataLikeConstructor, IndexedImage, type InvertMask, type Mask, type MaskOffset, type MaskRect, MaskType, type MergeAlphaMasksOptions, type NullableBinaryMaskRect, type NullableMaskRect, type PaintAlphaMask, type PaintBinaryMask, PaintBuffer, type PaintBufferCanvasRenderer, type PaintMask, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, type PixelCanvas, PixelData, PixelEngineConfig, type PixelMutateOptions, type PixelPatchTiles, type PixelRect, PixelTile, PixelTilePool, PixelWriter, type PixelWriterOptions, type RGBA, type Rect, type RequiredBlendModes, type ReusableCanvas, type ReusableImageData, type SerializedImageData, UnsupportedFormatError, applyAlphaMaskToPixelData, applyBinaryMaskToAlphaMask, applyBinaryMaskToPixelData, applyMaskToPixelData, applyPatchTiles, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendColorPixelDataMask, blendColorPixelDataPaintAlphaMask, blendColorPixelDataPaintBinaryMask, blendColorPixelDataPaintMask, blendPixel, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, blendPixelDataMask, blendPixelDataPaintBuffer, clearPixelDataFast, color32ToCssRGBA, color32ToHex, colorBurnFast, colorBurnPerfect, colorDistance, colorDodgeFast, colorDodgePerfect, copyImageData, copyImageDataLike, copyMask, darkenFast, darkenPerfect, darkerFast, darkerPerfect, deserializeImageData, deserializeNullableImageData, deserializeRawImageData, differenceFast, differencePerfect, divideFast, dividePerfect, exclusionFast, exclusionPerfect, extractImageDataBuffer, extractMask, extractMaskBuffer, extractPixelData, extractPixelDataBuffer, fileInputChangeToImageData, fileToImageData, fillPixelData, fillPixelDataBinaryMask, fillPixelDataFast, floodFillSelection, forEachLinePoint, getImageDataFromClipboard, getIndexedImageColorCounts, getRectsBounds, getSupportedPixelFormats, hardLightFast, hardLightPerfect, hardMixFast, hardMixPerfect, imageDataToAlphaMaskBuffer, imageDataToDataUrl, imageDataToImgBlob, imageDataToUInt32Array, imgBlobToImageData, indexedImageToAverageColor, indexedImageToImageData, invertAlphaMask, invertBinaryMask, invertImageData, invertPixelData, lerpColor32, lerpColor32Fast, lightenFast, lightenPerfect, lighterFast, lighterPerfect, linearBurnFast, linearBurnPerfect, linearDodgeFast, linearDodgePerfect, linearLightFast, linearLightPerfect, makeAlphaMask, makeBinaryMask, makeBlendModeRegistry, makeCanvasFrameRenderer, makeCirclePaintAlphaMask, makeCirclePaintBinaryMask, makeClippedBlit, makeClippedRect, makeFastBlendModeRegistry, makeFullPixelMutator, makeHistoryAction, makeImageDataLike, makePaintAlphaMask, makePaintBinaryMask, makePaintBufferCanvasRenderer, makePerfectBlendModeRegistry, makePixelCanvas, makeRectFalloffPaintAlphaMask, makeReusableCanvas, makeReusableImageData, makeReusableOffscreenCanvas, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyMask, mutatorBlendAlphaMask, mutatorBlendBinaryMask, mutatorBlendColor, mutatorBlendColorPaintAlphaMask, mutatorBlendColorPaintBinaryMask, mutatorBlendColorPaintMask, mutatorBlendMask, mutatorBlendPaintRect, mutatorBlendPixel, mutatorBlendPixelData, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorFillRect, mutatorInvert, overlayFast, overlayPerfect, overwriteBase, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, reflectPixelDataHorizontal, reflectPixelDataVertical, resample32, resampleImageData, resampleIndexedImage, resamplePixelData, resizeImageData, resolveBlitClipping, resolveRectClipping, rotatePixelData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, setMaskData, softLightFast, softLightPerfect, sourceOverFast, sourceOverPerfect, subtractBinaryMaskRects, subtractFast, subtractPerfect, toBlendModeIndexAndName, trimMaskRectBounds, trimRectBounds, uInt32ArrayToImageData, uInt32ArrayToImageDataLike, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageData, writeImageDataBuffer, writeImageDataToClipboard, writeImgBlobToClipboard, writePaintBufferToPixelData, writePixelDataBuffer };
|