pixel-data-js 0.21.0 → 0.22.2
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.dev.cjs +725 -362
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +712 -361
- package/dist/index.dev.js.map +1 -1
- package/dist/index.prod.cjs +725 -362
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +282 -127
- package/dist/index.prod.js +712 -361
- package/dist/index.prod.js.map +1 -1
- package/package.json +1 -1
- package/src/Algorithm/floodFillSelection.ts +12 -14
- package/src/BlendModes/toBlendModeIndexAndName.ts +0 -7
- package/src/Clipboard/writeImgBlobToClipboard.ts +1 -1
- package/src/History/PixelMutator/mutatorApplyAlphaMask.ts +3 -0
- package/src/History/PixelMutator/mutatorApplyBinaryMask.ts +3 -0
- package/src/History/PixelMutator/mutatorApplyCircleBrush.ts +25 -6
- package/src/History/PixelMutator/mutatorApplyCircleBrushStroke.ts +89 -46
- package/src/History/PixelMutator/mutatorApplyCirclePencil.ts +7 -7
- package/src/History/PixelMutator/mutatorApplyCirclePencilStroke.ts +81 -41
- package/src/History/PixelMutator/mutatorApplyRectBrush.ts +3 -0
- package/src/History/PixelMutator/mutatorApplyRectBrushStroke.ts +18 -5
- package/src/History/PixelMutator/mutatorApplyRectPencil.ts +3 -0
- package/src/History/PixelMutator/mutatorApplyRectPencilStroke.ts +19 -4
- package/src/History/PixelMutator/mutatorBlendColor.ts +4 -0
- package/src/History/PixelMutator/mutatorBlendPixelData.ts +4 -0
- package/src/History/PixelMutator/mutatorClear.ts +10 -8
- package/src/History/PixelMutator/mutatorFill.ts +7 -4
- package/src/History/PixelMutator/mutatorFillBinaryMask.ts +28 -0
- package/src/History/PixelMutator/mutatorInvert.ts +3 -0
- package/src/ImageData/extractImageDataBuffer.ts +3 -3
- package/src/ImageData/{imageDataToAlphaMask.ts → imageDataToAlphaMaskBuffer.ts} +3 -4
- package/src/ImageData/resizeImageData.ts +3 -5
- package/src/ImageData/writeImageDataBuffer.ts +7 -7
- package/src/Mask/AlphaMask.ts +16 -0
- package/src/Mask/BinaryMask.ts +16 -0
- package/src/Mask/CircleBrushAlphaMask.ts +32 -0
- package/src/Mask/CircleBrushBinaryMask.ts +30 -0
- package/src/Mask/applyBinaryMaskToAlphaMask.ts +12 -9
- package/src/Mask/copyMask.ts +9 -3
- package/src/Mask/extractMask.ts +33 -31
- package/src/Mask/extractMaskBuffer.ts +87 -0
- package/src/Mask/invertMask.ts +6 -4
- package/src/Mask/mergeAlphaMasks.ts +11 -10
- package/src/Mask/mergeBinaryMasks.ts +10 -9
- package/src/Mask/setMaskData.ts +7 -0
- package/src/MaskRect/merge2BinaryMaskRects.ts +81 -0
- package/src/MaskRect/mergeBinaryMaskRects.ts +39 -0
- package/src/MaskRect/subtractBinaryMaskRects.ts +80 -0
- package/src/PixelData/applyAlphaMaskToPixelData.ts +8 -5
- package/src/PixelData/applyBinaryMaskToPixelData.ts +8 -9
- package/src/PixelData/applyCircleBrushToPixelData.ts +54 -62
- package/src/PixelData/blendColorPixelDataAlphaMask.ts +35 -25
- package/src/PixelData/blendColorPixelDataBinaryMask.ts +26 -19
- package/src/PixelData/blendPixelDataAlphaMask.ts +3 -3
- package/src/PixelData/blendPixelDataBinaryMask.ts +3 -3
- package/src/PixelData/fillPixelData.ts +15 -42
- package/src/PixelData/fillPixelDataBinaryMask.ts +79 -0
- package/src/PixelData/invertPixelData.ts +3 -3
- package/src/PixelData/pixelDataToAlphaMask.ts +4 -2
- package/src/PixelData/writePixelDataBuffer.ts +2 -3
- package/src/Rect/getRectsBounds.ts +22 -0
- package/src/Rect/trimRectBounds.ts +20 -17
- package/src/_types.ts +55 -29
- package/src/index.ts +16 -1
package/dist/index.prod.d.ts
CHANGED
|
@@ -42,13 +42,6 @@ type Rect = {
|
|
|
42
42
|
w: number;
|
|
43
43
|
h: number;
|
|
44
44
|
};
|
|
45
|
-
type BinaryMaskRect = {
|
|
46
|
-
x: number;
|
|
47
|
-
y: number;
|
|
48
|
-
w: number;
|
|
49
|
-
h: number;
|
|
50
|
-
mask: BinaryMask;
|
|
51
|
-
};
|
|
52
45
|
/**
|
|
53
46
|
* Defines how mask values should be interpreted during a draw operation.
|
|
54
47
|
*/
|
|
@@ -64,15 +57,30 @@ declare enum MaskType {
|
|
|
64
57
|
*/
|
|
65
58
|
BINARY = 1
|
|
66
59
|
}
|
|
60
|
+
interface Mask {
|
|
61
|
+
readonly type: MaskType;
|
|
62
|
+
readonly data: Uint8Array;
|
|
63
|
+
readonly w: number;
|
|
64
|
+
readonly h: number;
|
|
65
|
+
}
|
|
67
66
|
/** Strictly 0 or 1 */
|
|
68
|
-
|
|
69
|
-
readonly
|
|
70
|
-
}
|
|
67
|
+
interface BinaryMask extends Mask {
|
|
68
|
+
readonly type: MaskType.BINARY;
|
|
69
|
+
}
|
|
71
70
|
/** Strictly 0-255 */
|
|
72
|
-
|
|
73
|
-
readonly
|
|
74
|
-
}
|
|
75
|
-
|
|
71
|
+
interface AlphaMask extends Mask {
|
|
72
|
+
readonly type: MaskType.ALPHA;
|
|
73
|
+
}
|
|
74
|
+
interface CircleBrush {
|
|
75
|
+
readonly size: number;
|
|
76
|
+
readonly radius: number;
|
|
77
|
+
readonly minOffset: number;
|
|
78
|
+
}
|
|
79
|
+
interface CircleBrushAlphaMask extends CircleBrush, AlphaMask {
|
|
80
|
+
}
|
|
81
|
+
interface CircleBrushBinaryMask extends CircleBrush, BinaryMask {
|
|
82
|
+
}
|
|
83
|
+
type CircleBrushMask = CircleBrushAlphaMask | CircleBrushBinaryMask;
|
|
76
84
|
/**
|
|
77
85
|
* Configuration for pixel manipulation operations.
|
|
78
86
|
* Designed to be used by spreading a Rect object ({x, y, w, h}) directly.
|
|
@@ -111,13 +119,6 @@ interface MaskOffset {
|
|
|
111
119
|
*/
|
|
112
120
|
my?: number;
|
|
113
121
|
}
|
|
114
|
-
interface MaskOffsetWidth {
|
|
115
|
-
/**
|
|
116
|
-
* Mask width.
|
|
117
|
-
* @default value of `w`
|
|
118
|
-
*/
|
|
119
|
-
mw?: number;
|
|
120
|
-
}
|
|
121
122
|
interface InvertMask {
|
|
122
123
|
/**
|
|
123
124
|
* If true the inverse of the mask will be applied
|
|
@@ -132,11 +133,11 @@ interface Alpha {
|
|
|
132
133
|
*/
|
|
133
134
|
alpha?: number;
|
|
134
135
|
}
|
|
135
|
-
interface ApplyMaskToPixelDataOptions extends PixelRect, Alpha,
|
|
136
|
+
interface ApplyMaskToPixelDataOptions extends PixelRect, Alpha, MaskOffset, InvertMask {
|
|
136
137
|
}
|
|
137
138
|
interface MergeAlphaMasksOptions extends PixelRect, Alpha, MaskOffset, InvertMask {
|
|
138
139
|
}
|
|
139
|
-
interface PixelMutateOptions extends PixelRect, MaskOffset,
|
|
140
|
+
interface PixelMutateOptions extends PixelRect, MaskOffset, InvertMask {
|
|
140
141
|
/** An optional mask to restrict where pixels are mutated. */
|
|
141
142
|
mask?: BinaryMask | null;
|
|
142
143
|
}
|
|
@@ -162,7 +163,7 @@ interface BasePixelBlendOptions {
|
|
|
162
163
|
}
|
|
163
164
|
interface PixelBlendOptions extends PixelRect, Alpha, BasePixelBlendOptions {
|
|
164
165
|
}
|
|
165
|
-
interface PixelBlendMaskOptions extends PixelRect, Alpha,
|
|
166
|
+
interface PixelBlendMaskOptions extends PixelRect, Alpha, MaskOffset, InvertMask, BasePixelBlendOptions {
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
168
169
|
* Configuration for operations that require color blending.
|
|
@@ -174,15 +175,29 @@ interface ColorBlendOptions extends PixelRect, Alpha {
|
|
|
174
175
|
*/
|
|
175
176
|
blendFn?: BlendColor32;
|
|
176
177
|
}
|
|
177
|
-
interface ColorBlendMaskOptions extends ColorBlendOptions, MaskOffset,
|
|
178
|
+
interface ColorBlendMaskOptions extends ColorBlendOptions, MaskOffset, InvertMask {
|
|
178
179
|
}
|
|
179
|
-
type
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
type BinaryMaskRect = Rect & {
|
|
181
|
+
type: MaskType.BINARY;
|
|
182
|
+
data: Uint8Array;
|
|
183
|
+
};
|
|
184
|
+
type NullableBinaryMaskRect = Rect & ({
|
|
185
|
+
type: MaskType.BINARY;
|
|
186
|
+
data: Uint8Array;
|
|
187
|
+
} | {
|
|
188
|
+
type?: null;
|
|
189
|
+
data?: null;
|
|
190
|
+
});
|
|
191
|
+
type NullableMaskRect = Rect & ({
|
|
192
|
+
type: MaskType;
|
|
193
|
+
data: Uint8Array;
|
|
182
194
|
} | {
|
|
183
|
-
|
|
184
|
-
|
|
195
|
+
type?: null;
|
|
196
|
+
data?: null;
|
|
185
197
|
});
|
|
198
|
+
type AlphaMaskRect = Rect & {
|
|
199
|
+
mask: AlphaMask;
|
|
200
|
+
};
|
|
186
201
|
type HistoryMutator<T extends {}, D extends {}> = (writer: PixelWriter<any>, deps?: Partial<D>) => T;
|
|
187
202
|
interface IPixelData {
|
|
188
203
|
readonly data32: Uint32Array;
|
|
@@ -249,7 +264,7 @@ type FloodFillImageDataOptions = {
|
|
|
249
264
|
type FloodFillResult = {
|
|
250
265
|
startX: number;
|
|
251
266
|
startY: number;
|
|
252
|
-
selectionRect:
|
|
267
|
+
selectionRect: BinaryMaskRect;
|
|
253
268
|
pixels: Uint8ClampedArray;
|
|
254
269
|
};
|
|
255
270
|
/**
|
|
@@ -262,9 +277,9 @@ type FloodFillResult = {
|
|
|
262
277
|
* @param startX - The starting horizontal coordinate.
|
|
263
278
|
* @param startY - The starting vertical coordinate.
|
|
264
279
|
* @param options - Configuration for the fill operation.
|
|
265
|
-
* @param options.contiguous -
|
|
280
|
+
* @param options.contiguous - If true, only connected pixels are
|
|
266
281
|
* selected. If false, all pixels within tolerance are selected regardless of position.
|
|
267
|
-
* @param options.tolerance -
|
|
282
|
+
* @param options.tolerance - The maximum allowed difference in color
|
|
268
283
|
* distance (0-255) for a pixel to be included.
|
|
269
284
|
* @param options.bounds - Optional bounding box to restrict the search area.
|
|
270
285
|
*
|
|
@@ -577,7 +592,7 @@ declare function writeImageDataToClipboard(imageData: ImageData): Promise<void>;
|
|
|
577
592
|
/**
|
|
578
593
|
* Writes a {@link Blob} image to the system clipboard.
|
|
579
594
|
*
|
|
580
|
-
* @param blob - The image
|
|
595
|
+
* @param blob - The image blob (typically `image/png`) to copy.
|
|
581
596
|
* @returns A promise that resolves when the clipboard has been updated.
|
|
582
597
|
*/
|
|
583
598
|
declare function writeImgBlobToClipboard(blob: Blob): Promise<void>;
|
|
@@ -694,11 +709,11 @@ declare function makeFullPixelMutator(writer: PixelWriter<any>): {
|
|
|
694
709
|
applyRectPencil(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
|
|
695
710
|
applyRectBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): void;
|
|
696
711
|
applyRectBrush(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): void;
|
|
697
|
-
applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number,
|
|
698
|
-
applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number,
|
|
699
|
-
applyCircleBrush(color: Color32, centerX: number, centerY: number,
|
|
712
|
+
applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushBinaryMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
713
|
+
applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
714
|
+
applyCircleBrush(color: Color32, centerX: number, centerY: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
700
715
|
invert(opts?: PixelMutateOptions): void;
|
|
701
|
-
fill(color: Color32, rect?: Partial<
|
|
716
|
+
fill(color: Color32, rect?: Partial<Rect>): void;
|
|
702
717
|
blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): void;
|
|
703
718
|
blendColor(color: Color32, opts?: ColorBlendOptions): void;
|
|
704
719
|
blendPixelData(src: IPixelData, opts: PixelBlendOptions): void;
|
|
@@ -706,13 +721,20 @@ declare function makeFullPixelMutator(writer: PixelWriter<any>): {
|
|
|
706
721
|
applyAlphaMask: (mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions) => void;
|
|
707
722
|
};
|
|
708
723
|
|
|
724
|
+
/**
|
|
725
|
+
* Directly applies a mask to a region of PixelData,
|
|
726
|
+
* modifying the destination's alpha channel in-place.
|
|
727
|
+
*/
|
|
709
728
|
declare function applyAlphaMaskToPixelData(dst: IPixelData, mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): void;
|
|
710
729
|
|
|
711
|
-
declare const defaults$
|
|
730
|
+
declare const defaults$f: {
|
|
712
731
|
applyAlphaMaskToPixelData: typeof applyAlphaMaskToPixelData;
|
|
713
732
|
};
|
|
714
|
-
type Deps$
|
|
715
|
-
|
|
733
|
+
type Deps$f = Partial<typeof defaults$f>;
|
|
734
|
+
/**
|
|
735
|
+
* @param deps - @hidden
|
|
736
|
+
*/
|
|
737
|
+
declare const mutatorApplyAlphaMask: (writer: PixelWriter<any>, deps?: Deps$f) => {
|
|
716
738
|
applyAlphaMask: (mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions) => void;
|
|
717
739
|
};
|
|
718
740
|
|
|
@@ -722,40 +744,44 @@ declare const mutatorApplyAlphaMask: (writer: PixelWriter<any>, deps?: Deps$e) =
|
|
|
722
744
|
*/
|
|
723
745
|
declare function applyBinaryMaskToPixelData(dst: IPixelData, mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): void;
|
|
724
746
|
|
|
725
|
-
declare const defaults$
|
|
747
|
+
declare const defaults$e: {
|
|
726
748
|
applyBinaryMaskToPixelData: typeof applyBinaryMaskToPixelData;
|
|
727
749
|
};
|
|
728
|
-
type Deps$
|
|
729
|
-
|
|
750
|
+
type Deps$e = Partial<typeof defaults$e>;
|
|
751
|
+
/**
|
|
752
|
+
* @param deps - @hidden
|
|
753
|
+
*/
|
|
754
|
+
declare const mutatorApplyBinaryMask: (writer: PixelWriter<any>, deps?: Deps$e) => {
|
|
730
755
|
applyBinaryMask: (mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions) => void;
|
|
731
756
|
};
|
|
732
757
|
|
|
733
758
|
/**
|
|
734
|
-
* Applies a circular brush to pixel data
|
|
759
|
+
* Applies a circular brush to pixel data using a pre-calculated alpha mask.
|
|
735
760
|
*
|
|
736
761
|
* @param target The PixelData to modify.
|
|
737
762
|
* @param color The brush color.
|
|
738
763
|
* @param centerX The center x-coordinate of the brush.
|
|
739
764
|
* @param centerY The center y-coordinate of the brush.
|
|
740
|
-
* @param
|
|
765
|
+
* @param brush The pre-calculated CircleBrushAlphaMask.
|
|
741
766
|
* @param alpha The overall opacity of the brush (0-255).
|
|
742
|
-
* @default 255
|
|
743
|
-
* @param fallOff A function that returns an alpha multiplier (0-1) based on the normalized distance (0-1) from the circle's center.
|
|
744
767
|
* @param blendFn
|
|
768
|
+
* @param scratchOptions
|
|
745
769
|
* @param bounds precalculated result from {@link getCircleBrushOrPencilBounds}
|
|
746
|
-
* @default sourceOverPerfect
|
|
747
770
|
*/
|
|
748
|
-
declare function applyCircleBrushToPixelData(target: IPixelData, color: Color32, centerX: number, centerY: number,
|
|
771
|
+
declare function applyCircleBrushToPixelData(target: IPixelData, color: Color32, centerX: number, centerY: number, brush: CircleBrushMask, alpha?: number, blendFn?: BlendColor32, scratchOptions?: ColorBlendMaskOptions, bounds?: Rect): void;
|
|
749
772
|
|
|
750
773
|
declare function getCircleBrushOrPencilBounds(centerX: number, centerY: number, brushSize: number, targetWidth: number, targetHeight: number, out?: Rect): Rect;
|
|
751
774
|
|
|
752
|
-
declare const defaults$
|
|
775
|
+
declare const defaults$d: {
|
|
753
776
|
applyCircleBrushToPixelData: typeof applyCircleBrushToPixelData;
|
|
754
777
|
getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
|
|
755
778
|
};
|
|
756
|
-
type Deps$
|
|
757
|
-
|
|
758
|
-
|
|
779
|
+
type Deps$d = Partial<typeof defaults$d>;
|
|
780
|
+
/**
|
|
781
|
+
* @param deps - @hidden
|
|
782
|
+
*/
|
|
783
|
+
declare const mutatorApplyCircleBrush: (writer: PixelWriter<any>, deps?: Deps$d) => {
|
|
784
|
+
applyCircleBrush(color: Color32, centerX: number, centerY: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
759
785
|
};
|
|
760
786
|
|
|
761
787
|
/**
|
|
@@ -764,98 +790,145 @@ declare const mutatorApplyCircleBrush: (writer: PixelWriter<any>, deps?: Deps$c)
|
|
|
764
790
|
*/
|
|
765
791
|
declare function forEachLinePoint(x0: number, y0: number, x1: number, y1: number, callback: (x: number, y: number) => void): void;
|
|
766
792
|
|
|
767
|
-
|
|
793
|
+
/**
|
|
794
|
+
* Blends a solid color into a target pixel buffer using an alpha mask.
|
|
795
|
+
*
|
|
796
|
+
* @remarks
|
|
797
|
+
* If the width (`w`) or height (`h`) are omitted from the options, they will safely
|
|
798
|
+
* default to the dimensions of the provided mask to prevent out-of-bounds memory access.
|
|
799
|
+
*
|
|
800
|
+
* @param dst - The destination {@link IPixelData} buffer to modify.
|
|
801
|
+
* @param color - The solid color to apply.
|
|
802
|
+
* @param mask - The mask defining the per-pixel opacity of the target area.
|
|
803
|
+
* @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
|
|
804
|
+
*/
|
|
805
|
+
declare function blendColorPixelDataAlphaMask(dst: IPixelData, color: Color32, mask: AlphaMask, opts?: ColorBlendMaskOptions): void;
|
|
768
806
|
|
|
769
807
|
declare function getCircleBrushOrPencilStrokeBounds(x0: number, y0: number, x1: number, y1: number, brushSize: number, result: Rect): Rect;
|
|
770
808
|
|
|
771
|
-
declare const defaults$
|
|
809
|
+
declare const defaults$c: {
|
|
772
810
|
forEachLinePoint: typeof forEachLinePoint;
|
|
773
811
|
blendColorPixelDataAlphaMask: typeof blendColorPixelDataAlphaMask;
|
|
774
812
|
getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
|
|
775
813
|
getCircleBrushOrPencilStrokeBounds: typeof getCircleBrushOrPencilStrokeBounds;
|
|
776
814
|
};
|
|
777
|
-
type Deps$
|
|
778
|
-
|
|
779
|
-
|
|
815
|
+
type Deps$c = Partial<typeof defaults$c>;
|
|
816
|
+
/**
|
|
817
|
+
* @param deps - @hidden
|
|
818
|
+
*/
|
|
819
|
+
declare const mutatorApplyCircleBrushStroke: (writer: PixelWriter<any>, deps?: Deps$c) => {
|
|
820
|
+
applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
780
821
|
};
|
|
781
822
|
|
|
782
|
-
declare const defaults$
|
|
823
|
+
declare const defaults$b: {
|
|
783
824
|
applyCircleBrushToPixelData: typeof applyCircleBrushToPixelData;
|
|
784
825
|
getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
|
|
785
|
-
fallOff: () => number;
|
|
786
826
|
};
|
|
787
|
-
type Deps$
|
|
788
|
-
|
|
789
|
-
|
|
827
|
+
type Deps$b = Partial<typeof defaults$b>;
|
|
828
|
+
/**
|
|
829
|
+
* @param deps - @hidden
|
|
830
|
+
**/
|
|
831
|
+
declare const mutatorApplyCirclePencil: (writer: PixelWriter<any>, deps?: Deps$b) => {
|
|
832
|
+
applyCirclePencil(color: Color32, centerX: number, centerY: number, brush: CircleBrushMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
790
833
|
};
|
|
791
834
|
|
|
835
|
+
/**
|
|
836
|
+
* Blends a solid color into a target pixel buffer using a binary mask.
|
|
837
|
+
*
|
|
838
|
+
* @remarks
|
|
839
|
+
* If the width (`w`) or height (`h`) are omitted from the options, they will safely
|
|
840
|
+
* default to the dimensions of the provided mask to prevent out-of-bounds memory access.
|
|
841
|
+
*
|
|
842
|
+
* @param dst - The destination {@link IPixelData} buffer to modify.
|
|
843
|
+
* @param color - The solid color to apply.
|
|
844
|
+
* @param mask - The mask defining the per-pixel opacity of the target area.
|
|
845
|
+
* @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
|
|
846
|
+
*/
|
|
792
847
|
declare function blendColorPixelDataBinaryMask(dst: IPixelData, color: Color32, mask: BinaryMask, opts?: ColorBlendMaskOptions): void;
|
|
793
848
|
|
|
794
|
-
declare const defaults$
|
|
849
|
+
declare const defaults$a: {
|
|
795
850
|
forEachLinePoint: typeof forEachLinePoint;
|
|
796
851
|
blendColorPixelDataBinaryMask: typeof blendColorPixelDataBinaryMask;
|
|
797
852
|
getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
|
|
798
853
|
getCircleBrushOrPencilStrokeBounds: typeof getCircleBrushOrPencilStrokeBounds;
|
|
799
854
|
};
|
|
800
|
-
type Deps$
|
|
801
|
-
|
|
802
|
-
|
|
855
|
+
type Deps$a = Partial<typeof defaults$a>;
|
|
856
|
+
/**
|
|
857
|
+
* @param deps - @hidden
|
|
858
|
+
*/
|
|
859
|
+
declare const mutatorApplyCirclePencilStroke: (writer: PixelWriter<any>, deps?: Deps$a) => {
|
|
860
|
+
applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushBinaryMask, alpha?: number, blendFn?: BlendColor32): void;
|
|
803
861
|
};
|
|
804
862
|
|
|
805
863
|
declare function applyRectBrushToPixelData(target: IPixelData, color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32, bounds?: Rect): void;
|
|
806
864
|
|
|
807
865
|
declare function getRectBrushOrPencilBounds(centerX: number, centerY: number, brushWidth: number, brushHeight: number, targetWidth: number, targetHeight: number, out?: Rect): Rect;
|
|
808
866
|
|
|
809
|
-
declare const defaults$
|
|
867
|
+
declare const defaults$9: {
|
|
810
868
|
applyRectBrushToPixelData: typeof applyRectBrushToPixelData;
|
|
811
869
|
getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
|
|
812
870
|
fallOff: () => number;
|
|
813
871
|
};
|
|
814
|
-
type Deps$
|
|
815
|
-
|
|
872
|
+
type Deps$9 = Partial<typeof defaults$9>;
|
|
873
|
+
/**
|
|
874
|
+
* @param deps - @hidden
|
|
875
|
+
*/
|
|
876
|
+
declare const mutatorApplyRectPencil: (writer: PixelWriter<any>, deps?: Deps$9) => {
|
|
816
877
|
applyRectPencil(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
|
|
817
878
|
};
|
|
818
879
|
|
|
819
880
|
declare function getRectBrushOrPencilStrokeBounds(x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, result: Rect): Rect;
|
|
820
881
|
|
|
821
|
-
declare const defaults$
|
|
882
|
+
declare const defaults$8: {
|
|
822
883
|
forEachLinePoint: typeof forEachLinePoint;
|
|
823
884
|
getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
|
|
824
885
|
getRectBrushOrPencilStrokeBounds: typeof getRectBrushOrPencilStrokeBounds;
|
|
825
886
|
blendColorPixelDataBinaryMask: typeof blendColorPixelDataBinaryMask;
|
|
826
887
|
};
|
|
827
|
-
type Deps$
|
|
828
|
-
|
|
888
|
+
type Deps$8 = Partial<typeof defaults$8>;
|
|
889
|
+
/**
|
|
890
|
+
* @param deps - @hidden
|
|
891
|
+
*/
|
|
892
|
+
declare const mutatorApplyRectPencilStroke: (writer: PixelWriter<any>, deps?: Deps$8) => {
|
|
829
893
|
applyRectPencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
|
|
830
894
|
};
|
|
831
895
|
|
|
832
|
-
declare const defaults$
|
|
896
|
+
declare const defaults$7: {
|
|
833
897
|
applyRectBrushToPixelData: typeof applyRectBrushToPixelData;
|
|
834
898
|
getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
|
|
835
899
|
};
|
|
836
|
-
type Deps$
|
|
837
|
-
|
|
900
|
+
type Deps$7 = Partial<typeof defaults$7>;
|
|
901
|
+
/**
|
|
902
|
+
* @param deps - @hidden
|
|
903
|
+
*/
|
|
904
|
+
declare const mutatorApplyRectBrush: (writer: PixelWriter<any>, deps?: Deps$7) => {
|
|
838
905
|
applyRectBrush(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): void;
|
|
839
906
|
};
|
|
840
907
|
|
|
841
|
-
declare const defaults$
|
|
908
|
+
declare const defaults$6: {
|
|
842
909
|
forEachLinePoint: typeof forEachLinePoint;
|
|
843
910
|
blendColorPixelDataAlphaMask: typeof blendColorPixelDataAlphaMask;
|
|
844
911
|
getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
|
|
845
912
|
getRectBrushOrPencilStrokeBounds: typeof getRectBrushOrPencilStrokeBounds;
|
|
846
913
|
};
|
|
847
|
-
type Deps$
|
|
848
|
-
|
|
914
|
+
type Deps$6 = Partial<typeof defaults$6>;
|
|
915
|
+
/**
|
|
916
|
+
* @param deps - @hidden
|
|
917
|
+
*/
|
|
918
|
+
declare const mutatorApplyRectBrushStroke: (writer: PixelWriter<any>, deps?: Deps$6) => {
|
|
849
919
|
applyRectBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): void;
|
|
850
920
|
};
|
|
851
921
|
|
|
852
922
|
declare function blendColorPixelData(dst: IPixelData, color: Color32, opts?: ColorBlendOptions): void;
|
|
853
923
|
|
|
854
|
-
declare const defaults$
|
|
924
|
+
declare const defaults$5: {
|
|
855
925
|
blendColorPixelData: typeof blendColorPixelData;
|
|
856
926
|
};
|
|
857
|
-
type Deps$
|
|
858
|
-
|
|
927
|
+
type Deps$5 = Partial<typeof defaults$5>;
|
|
928
|
+
/**
|
|
929
|
+
* @param deps - @hidden
|
|
930
|
+
*/
|
|
931
|
+
declare const mutatorBlendColor: (writer: PixelWriter<any>, deps?: Deps$5) => {
|
|
859
932
|
blendColor(color: Color32, opts?: ColorBlendOptions): void;
|
|
860
933
|
};
|
|
861
934
|
|
|
@@ -879,47 +952,78 @@ declare function mutatorBlendPixel(writer: PixelWriter<any>): {
|
|
|
879
952
|
*/
|
|
880
953
|
declare function blendPixelData(dst: IPixelData, src: IPixelData, opts: PixelBlendOptions): void;
|
|
881
954
|
|
|
882
|
-
declare const defaults$
|
|
955
|
+
declare const defaults$4: {
|
|
883
956
|
blendPixelData: typeof blendPixelData;
|
|
884
957
|
};
|
|
885
|
-
type Deps$
|
|
886
|
-
|
|
958
|
+
type Deps$4 = Partial<typeof defaults$4>;
|
|
959
|
+
/**
|
|
960
|
+
* @param deps - @hidden
|
|
961
|
+
*/
|
|
962
|
+
declare const mutatorBlendPixelData: (writer: PixelWriter<any>, deps?: Partial<Deps$4>) => {
|
|
887
963
|
blendPixelData(src: IPixelData, opts: PixelBlendOptions): void;
|
|
888
964
|
};
|
|
889
965
|
|
|
890
966
|
/**
|
|
891
|
-
* Fills a region or the {@link
|
|
967
|
+
* Fills a region or the {@link IPixelData} buffer with a solid color.
|
|
892
968
|
*
|
|
893
|
-
* @param dst - The target
|
|
894
|
-
* @param color - The
|
|
895
|
-
* @param rect -
|
|
969
|
+
* @param dst - The target to modify.
|
|
970
|
+
* @param color - The color to apply.
|
|
971
|
+
* @param rect - Defines the area to fill. If omitted, the entire
|
|
972
|
+
* buffer is filled.
|
|
896
973
|
*/
|
|
897
|
-
declare function fillPixelData(dst: IPixelData, color: Color32, rect?: Partial<
|
|
974
|
+
declare function fillPixelData(dst: IPixelData, color: Color32, rect?: Partial<Rect>): void;
|
|
898
975
|
/**
|
|
899
|
-
* @param dst - The target
|
|
900
|
-
* @param color - The
|
|
976
|
+
* @param dst - The target to modify.
|
|
977
|
+
* @param color - The color to apply.
|
|
901
978
|
* @param x - Starting horizontal coordinate.
|
|
902
979
|
* @param y - Starting vertical coordinate.
|
|
903
980
|
* @param w - Width of the fill area.
|
|
904
981
|
* @param h - Height of the fill area.
|
|
905
|
-
* @param mask - A {@link BinaryMaskRect} defining the area to fill
|
|
906
982
|
*/
|
|
907
|
-
declare function fillPixelData(dst: IPixelData, color: Color32, x: number, y: number, w: number, h: number
|
|
983
|
+
declare function fillPixelData(dst: IPixelData, color: Color32, x: number, y: number, w: number, h: number): void;
|
|
984
|
+
|
|
985
|
+
declare const defaults$3: {
|
|
986
|
+
fillPixelData: typeof fillPixelData;
|
|
987
|
+
};
|
|
988
|
+
type Deps$3 = Partial<typeof defaults$3>;
|
|
989
|
+
/**
|
|
990
|
+
* @param deps - @hidden
|
|
991
|
+
*/
|
|
992
|
+
declare const mutatorClear: (writer: PixelWriter<any>, deps?: Deps$3) => {
|
|
993
|
+
clear(rect?: Partial<BinaryMaskRect>): void;
|
|
994
|
+
};
|
|
908
995
|
|
|
909
996
|
declare const defaults$2: {
|
|
910
997
|
fillPixelData: typeof fillPixelData;
|
|
911
998
|
};
|
|
912
999
|
type Deps$2 = Partial<typeof defaults$2>;
|
|
913
|
-
|
|
914
|
-
|
|
1000
|
+
/**
|
|
1001
|
+
* @param deps - @hidden
|
|
1002
|
+
*/
|
|
1003
|
+
declare const mutatorFill: (writer: PixelWriter<any>, deps?: Deps$2) => {
|
|
1004
|
+
fill(color: Color32, rect?: Partial<Rect>): void;
|
|
915
1005
|
};
|
|
916
1006
|
|
|
1007
|
+
/**
|
|
1008
|
+
* Fills a region of the {@link IPixelData} buffer with a solid color using a mask.
|
|
1009
|
+
* @param dst - The target to modify.
|
|
1010
|
+
* @param color - The color to apply.
|
|
1011
|
+
* @param mask - The mask defining the area to fill.
|
|
1012
|
+
* @param alpha - The overall opacity of the fill (0-255).
|
|
1013
|
+
* @param x - Starting horizontal coordinate for the mask placement.
|
|
1014
|
+
* @param y - Starting vertical coordinate for the mask placement.
|
|
1015
|
+
*/
|
|
1016
|
+
declare function fillPixelDataBinaryMask(dst: IPixelData, color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): void;
|
|
1017
|
+
|
|
917
1018
|
declare const defaults$1: {
|
|
918
|
-
|
|
1019
|
+
fillPixelDataBinaryMask: typeof fillPixelDataBinaryMask;
|
|
919
1020
|
};
|
|
920
1021
|
type Deps$1 = Partial<typeof defaults$1>;
|
|
921
|
-
|
|
922
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* @param deps - @hidden
|
|
1024
|
+
*/
|
|
1025
|
+
declare const mutatorFillBinaryMask: (writer: PixelWriter<any>, deps?: Deps$1) => {
|
|
1026
|
+
fillBinaryMask(color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): void;
|
|
923
1027
|
};
|
|
924
1028
|
|
|
925
1029
|
declare function invertPixelData(pixelData: IPixelData, opts?: PixelMutateOptions): void;
|
|
@@ -928,6 +1032,9 @@ declare const defaults: {
|
|
|
928
1032
|
invertPixelData: typeof invertPixelData;
|
|
929
1033
|
};
|
|
930
1034
|
type Deps = Partial<typeof defaults>;
|
|
1035
|
+
/**
|
|
1036
|
+
* @param deps - @hidden
|
|
1037
|
+
*/
|
|
931
1038
|
declare const mutatorInvert: (writer: PixelWriter<any>, deps?: Deps) => {
|
|
932
1039
|
invert(opts?: PixelMutateOptions): void;
|
|
933
1040
|
};
|
|
@@ -942,8 +1049,8 @@ declare function copyImageDataLike({ data, width, height }: ImageDataLike): Imag
|
|
|
942
1049
|
* This is a "read-only" operation that returns a copy of the pixel data.
|
|
943
1050
|
*
|
|
944
1051
|
* @param imageData - The source image data to read from.
|
|
945
|
-
* @param rect - A
|
|
946
|
-
* @returns A
|
|
1052
|
+
* @param rect - A rect defining the region to extract.
|
|
1053
|
+
* @returns A buffer containing the RGBA pixel data of the region.
|
|
947
1054
|
*/
|
|
948
1055
|
declare function extractImageDataBuffer(imageData: ImageDataLike, rect: Rect): Uint8ClampedArray;
|
|
949
1056
|
/**
|
|
@@ -952,7 +1059,7 @@ declare function extractImageDataBuffer(imageData: ImageDataLike, rect: Rect): U
|
|
|
952
1059
|
* @param y - The starting vertical coordinate.
|
|
953
1060
|
* @param w - The width of the region to extract.
|
|
954
1061
|
* @param h - The height of the region to extract.
|
|
955
|
-
* @returns A
|
|
1062
|
+
* @returns A buffer containing the RGBA pixel data of the region.
|
|
956
1063
|
*/
|
|
957
1064
|
declare function extractImageDataBuffer(imageData: ImageDataLike, x: number, y: number, w: number, h: number): Uint8ClampedArray;
|
|
958
1065
|
|
|
@@ -963,7 +1070,7 @@ declare function makeImageDataLike(width: number, height: number, data?: Buffer)
|
|
|
963
1070
|
* When possible use {@link pixelDataToAlphaMask} instead.
|
|
964
1071
|
* Repeat calls to the same data will use less memory.
|
|
965
1072
|
*/
|
|
966
|
-
declare function
|
|
1073
|
+
declare function imageDataToAlphaMaskBuffer(imageData: ImageData): Uint8Array;
|
|
967
1074
|
|
|
968
1075
|
/**
|
|
969
1076
|
* Converts an {@link ImageData} object into a base64-encoded Data URL string.
|
|
@@ -1051,15 +1158,13 @@ declare function resampleImageData(source: ImageData, factor: number): ImageData
|
|
|
1051
1158
|
* instead, it crops or pads the image based on the new dimensions and
|
|
1052
1159
|
* provides an offset for repositioning.
|
|
1053
1160
|
*
|
|
1054
|
-
* @param
|
|
1161
|
+
* @param target The target to resize.
|
|
1055
1162
|
* @param newWidth The target width in pixels.
|
|
1056
1163
|
* @param newHeight The target height in pixels.
|
|
1057
1164
|
* @param offsetX The horizontal offset for placing the
|
|
1058
1165
|
* original image within the new buffer.
|
|
1059
|
-
* @default 0
|
|
1060
1166
|
* @param offsetY The vertical offset for placing the
|
|
1061
1167
|
* original image within the new buffer.
|
|
1062
|
-
* @default 0
|
|
1063
1168
|
*
|
|
1064
1169
|
* @returns A new {@link ImageData} instance with the specified dimensions.
|
|
1065
1170
|
*
|
|
@@ -1075,7 +1180,7 @@ declare function resampleImageData(source: ImageData, factor: number): ImageData
|
|
|
1075
1180
|
* );
|
|
1076
1181
|
* ```
|
|
1077
1182
|
*/
|
|
1078
|
-
declare function resizeImageData(
|
|
1183
|
+
declare function resizeImageData(target: ImageDataLike, newWidth: number, newHeight: number, offsetX?: number, offsetY?: number): ImageData;
|
|
1079
1184
|
|
|
1080
1185
|
type ReusableImageData = ReturnType<typeof makeReusableImageData>;
|
|
1081
1186
|
/**
|
|
@@ -1123,20 +1228,20 @@ declare function writeImageData(target: ImageData, source: ImageData, x: number,
|
|
|
1123
1228
|
* into the target {@link ImageData} buffer. It supports both {@link Rect}
|
|
1124
1229
|
* objects and discrete coordinates.
|
|
1125
1230
|
*
|
|
1126
|
-
* @param
|
|
1231
|
+
* @param target - The target to write into. Must match the rect width/height.
|
|
1127
1232
|
* @param data - The source pixel data (RGBA).
|
|
1128
|
-
* @param rect - A
|
|
1233
|
+
* @param rect - A rect defining the destination region.
|
|
1129
1234
|
*/
|
|
1130
|
-
declare function writeImageDataBuffer(
|
|
1235
|
+
declare function writeImageDataBuffer(target: ImageData, data: Uint8ClampedArray, rect: Rect): void;
|
|
1131
1236
|
/**
|
|
1132
|
-
* @param
|
|
1237
|
+
* @param target - The target to write into.
|
|
1133
1238
|
* @param data - The source pixel data (RGBA). Must match the width/height.
|
|
1134
1239
|
* @param x - The starting horizontal coordinate in the target.
|
|
1135
1240
|
* @param y - The starting vertical coordinate in the target.
|
|
1136
1241
|
* @param w - The width of the region to write.
|
|
1137
1242
|
* @param h - The height of the region to write.
|
|
1138
1243
|
*/
|
|
1139
|
-
declare function writeImageDataBuffer(
|
|
1244
|
+
declare function writeImageDataBuffer(target: ImageData, data: Uint8ClampedArray, x: number, y: number, w: number, h: number): void;
|
|
1140
1245
|
|
|
1141
1246
|
/**
|
|
1142
1247
|
* Represents an image using a palette-based indexing system.
|
|
@@ -1307,27 +1412,67 @@ declare function fileToImageData(file: File | null | undefined): Promise<ImageDa
|
|
|
1307
1412
|
*/
|
|
1308
1413
|
declare function getSupportedPixelFormats(rasterMimes?: string[]): Promise<string[]>;
|
|
1309
1414
|
|
|
1310
|
-
|
|
1415
|
+
/**
|
|
1416
|
+
* Creates an Alpha Mask
|
|
1417
|
+
* @param w - width
|
|
1418
|
+
* @param h - height
|
|
1419
|
+
* @param data - values 0-255
|
|
1420
|
+
*/
|
|
1421
|
+
declare function makeAlphaMask(w: number, h: number, data?: Uint8Array): AlphaMask;
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Creates a Binary Mask
|
|
1425
|
+
* @param w - width
|
|
1426
|
+
* @param h - height
|
|
1427
|
+
* @param data - values 0-1
|
|
1428
|
+
*/
|
|
1429
|
+
declare function makeBinaryMask(w: number, h: number, data?: Uint8Array): BinaryMask;
|
|
1430
|
+
|
|
1431
|
+
declare function makeCircleBrushAlphaMask(size: number, fallOff?: (d: number) => number): CircleBrushAlphaMask;
|
|
1432
|
+
|
|
1433
|
+
declare function makeCircleBrushBinaryMask(size: number): CircleBrushBinaryMask;
|
|
1434
|
+
|
|
1435
|
+
declare function applyBinaryMaskToAlphaMask(alphaMaskDst: AlphaMask, binaryMaskSrc: BinaryMask, opts?: ApplyMaskToPixelDataOptions): void;
|
|
1311
1436
|
|
|
1312
1437
|
/**
|
|
1313
1438
|
* Creates a new copy of a mask.
|
|
1314
1439
|
* Uses the underlying buffer's slice method for high-performance memory copying.
|
|
1315
1440
|
*/
|
|
1316
|
-
declare function copyMask<T extends
|
|
1441
|
+
declare function copyMask<T extends Mask>(src: T): T;
|
|
1317
1442
|
|
|
1318
1443
|
/**
|
|
1319
1444
|
* Extracts a rectangular region from a 1D {@link Uint8Array} mask.
|
|
1320
1445
|
* This utility calculates the necessary offsets based on the `maskWidth` to
|
|
1321
1446
|
* slice out a specific area.
|
|
1322
1447
|
*
|
|
1323
|
-
* @param mask - The
|
|
1448
|
+
* @param mask - The target mask.
|
|
1449
|
+
* @param rect - A rect defining the region to extract.
|
|
1450
|
+
* @returns A new mask containing the extracted region.
|
|
1451
|
+
*/
|
|
1452
|
+
declare function extractMask<T extends Mask>(mask: T, rect: Rect): T;
|
|
1453
|
+
/**
|
|
1454
|
+
* @param mask - The target mask.
|
|
1455
|
+
* @param x - The starting horizontal coordinate.
|
|
1456
|
+
* @param y - The starting vertical coordinate.
|
|
1457
|
+
* @param w - The width of the region to extract.
|
|
1458
|
+
* @param h - The height of the region to extract.
|
|
1459
|
+
* @returns A new {@link Uint8Array} containing the extracted region.
|
|
1460
|
+
*/
|
|
1461
|
+
declare function extractMask<T extends Mask>(mask: T, x: number, y: number, w: number, h: number): T;
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* Extracts a rectangular region from a 1D {@link Uint8Array} mask.
|
|
1465
|
+
* This utility calculates the necessary offsets based on the `maskWidth` to
|
|
1466
|
+
* slice out a specific area.
|
|
1467
|
+
*
|
|
1468
|
+
* @param maskBuffer - The source 1D array representing the full 2D mask.
|
|
1324
1469
|
* @param maskWidth - The width of the original source mask (stride).
|
|
1325
1470
|
* @param rect - A {@link Rect} object defining the region to extract.
|
|
1326
1471
|
* @returns A new {@link Uint8Array} containing the extracted region.
|
|
1327
1472
|
*/
|
|
1328
|
-
declare function
|
|
1473
|
+
declare function extractMaskBuffer(maskBuffer: Uint8Array, maskWidth: number, rect: Rect): Uint8Array;
|
|
1329
1474
|
/**
|
|
1330
|
-
* @param
|
|
1475
|
+
* @param maskBuffer - The source 1D array representing the full 2D mask.
|
|
1331
1476
|
* @param maskWidth - The width of the original source mask (stride).
|
|
1332
1477
|
* @param x - The starting horizontal coordinate.
|
|
1333
1478
|
* @param y - The starting vertical coordinate.
|
|
@@ -1335,7 +1480,7 @@ declare function extractMask(mask: Uint8Array, maskWidth: number, rect: Rect): U
|
|
|
1335
1480
|
* @param h - The height of the region to extract.
|
|
1336
1481
|
* @returns A new {@link Uint8Array} containing the extracted region.
|
|
1337
1482
|
*/
|
|
1338
|
-
declare function
|
|
1483
|
+
declare function extractMaskBuffer(maskBuffer: Uint8Array, maskWidth: number, x: number, y: number, w: number, h: number): Uint8Array;
|
|
1339
1484
|
|
|
1340
1485
|
/**
|
|
1341
1486
|
* Inverts a BinaryMask in-place.
|
|
@@ -1349,9 +1494,17 @@ declare function invertAlphaMask(dst: AlphaMask): void;
|
|
|
1349
1494
|
/**
|
|
1350
1495
|
* Merges 2 alpha masks values are 0-255
|
|
1351
1496
|
*/
|
|
1352
|
-
declare function mergeAlphaMasks(dst: AlphaMask,
|
|
1497
|
+
declare function mergeAlphaMasks(dst: AlphaMask, src: AlphaMask, opts: MergeAlphaMasksOptions): void;
|
|
1498
|
+
|
|
1499
|
+
declare function mergeBinaryMasks(dst: BinaryMask, src: BinaryMask, opts: MergeAlphaMasksOptions): void;
|
|
1353
1500
|
|
|
1354
|
-
declare function
|
|
1501
|
+
declare function setMaskData(mask: Mask, width: number, height: number, data: Uint8Array): void;
|
|
1502
|
+
|
|
1503
|
+
declare function subtractBinaryMaskRects(current: NullableBinaryMaskRect[], subtracting: NullableBinaryMaskRect[]): NullableBinaryMaskRect[];
|
|
1504
|
+
|
|
1505
|
+
declare function merge2BinaryMaskRects(a: NullableBinaryMaskRect, b: NullableBinaryMaskRect): NullableBinaryMaskRect;
|
|
1506
|
+
|
|
1507
|
+
declare function mergeBinaryMaskRects(current: NullableBinaryMaskRect[], adding: NullableBinaryMaskRect[]): NullableBinaryMaskRect[];
|
|
1355
1508
|
|
|
1356
1509
|
declare function blendPixelDataAlphaMask(dst: IPixelData, src: IPixelData, alphaMask: AlphaMask, opts?: PixelBlendMaskOptions): void;
|
|
1357
1510
|
|
|
@@ -1409,19 +1562,21 @@ declare function resamplePixelData(pixelData: IPixelData, factor: number): Pixel
|
|
|
1409
1562
|
declare function rotatePixelData(pixelData: PixelData): void;
|
|
1410
1563
|
|
|
1411
1564
|
/**
|
|
1412
|
-
* Copies a pixel buffer into a specific region of a {@link
|
|
1565
|
+
* Copies a pixel buffer into a specific region of a {@link IPixelData} object.
|
|
1413
1566
|
*
|
|
1414
1567
|
* This function performs a direct memory copy from a {@link Uint32Array}
|
|
1415
|
-
* into the target
|
|
1568
|
+
* into the target buffer.
|
|
1416
1569
|
*/
|
|
1417
1570
|
declare function writePixelDataBuffer(target: IPixelData, data: Uint32Array, rect: Rect): void;
|
|
1418
1571
|
declare function writePixelDataBuffer(target: IPixelData, data: Uint32Array, x: number, y: number, w: number, h: number): void;
|
|
1419
1572
|
|
|
1573
|
+
declare function getRectsBounds<T extends Rect>(rects: T[]): T;
|
|
1574
|
+
|
|
1420
1575
|
/**
|
|
1421
1576
|
* Intersects a target rectangle with a boundary, trimming dimensions and masks in-place.
|
|
1422
1577
|
* This utility calculates the axis-aligned intersection between the `target` and `bounds`.
|
|
1423
|
-
* If the `target` includes a `mask` (as in a {@link
|
|
1424
|
-
* cropped and re-aligned using `
|
|
1578
|
+
* If the `target` includes a `mask` (as in a {@link NullableMaskRect}), the mask is physically
|
|
1579
|
+
* cropped and re-aligned using `extractMaskBuffer` to match the new dimensions.
|
|
1425
1580
|
* @param target - The rectangle or selection object to be trimmed. **Note:** This object is mutated in-place.
|
|
1426
1581
|
* @param bounds - The boundary rectangle defining the maximum allowable area (e.g., canvas dimensions).
|
|
1427
1582
|
* @example
|
|
@@ -1431,6 +1586,6 @@ declare function writePixelDataBuffer(target: IPixelData, data: Uint32Array, x:
|
|
|
1431
1586
|
* // The mask is cropped by 10 px on the top and left.
|
|
1432
1587
|
* trimRectBounds(selection, canvas);
|
|
1433
1588
|
*/
|
|
1434
|
-
declare function trimRectBounds<T extends
|
|
1589
|
+
declare function trimRectBounds<T extends NullableMaskRect>(target: T, bounds: Rect): void;
|
|
1435
1590
|
|
|
1436
|
-
export { type
|
|
1591
|
+
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, CANVAS_CTX_FAILED, type CircleBrushAlphaMask, type CircleBrushBinaryMask, type CircleBrushMask, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, type FloodFillImageDataOptions, type FloodFillResult, type HistoryAction, HistoryManager, type HistoryMutator, type IPixelData, type ImageDataLike, type ImageDataLikeConstructor, IndexedImage, type InvertMask, type Mask, type MaskOffset, MaskType, type MergeAlphaMasksOptions, type NullableBinaryMaskRect, type NullableMaskRect, OFFSCREEN_CANVAS_CTX_FAILED, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, PixelBuffer32, type PixelCanvas, PixelData, PixelEngineConfig, type PixelMutateOptions, type PixelPatchTiles, type PixelRect, PixelTile, PixelWriter, type PixelWriterOptions, type RGBA, type Rect, type RequiredBlendModes, type ReusableCanvas, type ReusableImageData, type SerializedImageData, UnsupportedFormatError, applyAlphaMaskToPixelData, applyBinaryMaskToAlphaMask, applyBinaryMaskToPixelData, applyCircleBrushToPixelData, applyPatchTiles, applyRectBrushToPixelData, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, clearPixelData, 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, floodFillSelection, forEachLinePoint, getCircleBrushOrPencilBounds, getCircleBrushOrPencilStrokeBounds, getImageDataFromClipboard, getIndexedImageColorCounts, getRectBrushOrPencilBounds, getRectBrushOrPencilStrokeBounds, 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, makeCircleBrushAlphaMask, makeCircleBrushBinaryMask, makeFastBlendModeRegistry, makeFullPixelMutator, makeImageDataLike, makePerfectBlendModeRegistry, makePixelCanvas, makeReusableCanvas, makeReusableImageData, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyCircleBrush, mutatorApplyCircleBrushStroke, mutatorApplyCirclePencil, mutatorApplyCirclePencilStroke, mutatorApplyRectBrush, mutatorApplyRectBrushStroke, mutatorApplyRectPencil, mutatorApplyRectPencilStroke, mutatorBlendColor, mutatorBlendPixel, mutatorBlendPixelData, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorInvert, overlayFast, overlayPerfect, overwriteBase, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, reflectPixelDataHorizontal, reflectPixelDataVertical, resampleImageData, resampleIndexedImage, resamplePixelData, resizeImageData, rotatePixelData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, setMaskData, softLightFast, softLightPerfect, sourceOverFast, sourceOverPerfect, subtractBinaryMaskRects, subtractFast, subtractPerfect, toBlendModeIndexAndName, trimRectBounds, uInt32ArrayToImageData, uInt32ArrayToImageDataLike, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageData, writeImageDataBuffer, writeImageDataToClipboard, writeImgBlobToClipboard, writePixelDataBuffer };
|