pixel-data-js 0.23.0 → 0.24.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.
Files changed (66) hide show
  1. package/dist/index.dev.cjs +1024 -596
  2. package/dist/index.dev.cjs.map +1 -1
  3. package/dist/index.dev.js +1010 -592
  4. package/dist/index.dev.js.map +1 -1
  5. package/dist/index.prod.cjs +1024 -596
  6. package/dist/index.prod.cjs.map +1 -1
  7. package/dist/index.prod.d.ts +280 -165
  8. package/dist/index.prod.js +1010 -592
  9. package/dist/index.prod.js.map +1 -1
  10. package/package.json +3 -2
  11. package/src/Canvas/CanvasFrameRenderer.ts +57 -0
  12. package/src/Canvas/ReusableCanvas.ts +60 -11
  13. package/src/History/HistoryAction.ts +38 -0
  14. package/src/History/HistoryManager.ts +4 -8
  15. package/src/History/PixelAccumulator.ts +95 -80
  16. package/src/History/PixelEngineConfig.ts +18 -6
  17. package/src/History/PixelMutator/mutatorApplyAlphaMask.ts +6 -6
  18. package/src/History/PixelMutator/mutatorApplyBinaryMask.ts +6 -6
  19. package/src/History/PixelMutator/mutatorApplyCircleBrushStroke.ts +6 -5
  20. package/src/History/PixelMutator/mutatorApplyCirclePencil.ts +22 -22
  21. package/src/History/PixelMutator/mutatorApplyCirclePencilStroke.ts +6 -5
  22. package/src/History/PixelMutator/mutatorApplyRectBrush.ts +19 -19
  23. package/src/History/PixelMutator/mutatorApplyRectBrushStroke.ts +6 -4
  24. package/src/History/PixelMutator/mutatorApplyRectPencil.ts +20 -20
  25. package/src/History/PixelMutator/mutatorApplyRectPencilStroke.ts +6 -4
  26. package/src/History/PixelMutator/mutatorBlendColor.ts +8 -5
  27. package/src/History/PixelMutator/mutatorBlendColorCircleMask.ts +71 -0
  28. package/src/History/PixelMutator/mutatorBlendPixel.ts +22 -26
  29. package/src/History/PixelMutator/mutatorBlendPixelData.ts +5 -3
  30. package/src/History/PixelMutator/mutatorBlendPixelDataAlphaMask.ts +5 -3
  31. package/src/History/PixelMutator/mutatorBlendPixelDataBinaryMask.ts +5 -3
  32. package/src/History/PixelMutator/mutatorClear.ts +7 -6
  33. package/src/History/PixelMutator/mutatorFill.ts +34 -9
  34. package/src/History/PixelMutator/mutatorFillBinaryMask.ts +4 -2
  35. package/src/History/PixelMutator/mutatorInvert.ts +8 -4
  36. package/src/History/PixelMutator.ts +4 -3
  37. package/src/History/PixelPatchTiles.ts +3 -15
  38. package/src/History/PixelWriter.ts +29 -33
  39. package/src/ImageData/ReusableImageData.ts +3 -5
  40. package/src/Mask/{CircleBrushAlphaMask.ts → CircleAlphaMask.ts} +2 -2
  41. package/src/Mask/{CircleBrushBinaryMask.ts → CircleBinaryMask.ts} +2 -2
  42. package/src/PixelData/PixelData.ts +1 -27
  43. package/src/PixelData/applyAlphaMaskToPixelData.ts +19 -9
  44. package/src/PixelData/applyBinaryMaskToPixelData.ts +24 -17
  45. package/src/PixelData/applyRectBrushToPixelData.ts +18 -5
  46. package/src/PixelData/blendColorPixelData.ts +31 -7
  47. package/src/PixelData/blendColorPixelDataAlphaMask.ts +16 -6
  48. package/src/PixelData/blendColorPixelDataBinaryMask.ts +16 -7
  49. package/src/PixelData/{applyCircleBrushToPixelData.ts → blendColorPixelDataCircleMask.ts} +11 -10
  50. package/src/PixelData/blendPixel.ts +47 -0
  51. package/src/PixelData/blendPixelData.ts +14 -4
  52. package/src/PixelData/blendPixelDataAlphaMask.ts +12 -4
  53. package/src/PixelData/blendPixelDataBinaryMask.ts +13 -4
  54. package/src/PixelData/blendPixelDataPaintBuffer.ts +37 -0
  55. package/src/PixelData/clearPixelData.ts +2 -2
  56. package/src/PixelData/fillPixelData.ts +26 -16
  57. package/src/PixelData/fillPixelDataBinaryMask.ts +12 -4
  58. package/src/PixelData/fillPixelDataFast.ts +94 -0
  59. package/src/PixelData/invertPixelData.ts +4 -2
  60. package/src/PixelTile/PaintBuffer.ts +122 -0
  61. package/src/PixelTile/PaintBufferRenderer.ts +40 -0
  62. package/src/PixelTile/PixelTile.ts +21 -0
  63. package/src/PixelTile/PixelTilePool.ts +63 -0
  64. package/src/_types.ts +9 -9
  65. package/src/index.ts +16 -6
  66. package/src/History/PixelMutator/mutatorApplyCircleBrush.ts +0 -78
@@ -71,16 +71,16 @@ interface BinaryMask extends Mask {
71
71
  interface AlphaMask extends Mask {
72
72
  readonly type: MaskType.ALPHA;
73
73
  }
74
- interface CircleBrush {
74
+ interface BaseCircleMask {
75
75
  readonly size: number;
76
76
  readonly radius: number;
77
77
  readonly minOffset: number;
78
78
  }
79
- interface CircleBrushAlphaMask extends CircleBrush, AlphaMask {
79
+ interface CircleAlphaMask extends BaseCircleMask, AlphaMask {
80
80
  }
81
- interface CircleBrushBinaryMask extends CircleBrush, BinaryMask {
81
+ interface CircleBinaryMask extends BaseCircleMask, BinaryMask {
82
82
  }
83
- type CircleBrushMask = CircleBrushAlphaMask | CircleBrushBinaryMask;
83
+ type CircleMask = CircleAlphaMask | CircleBinaryMask;
84
84
  /**
85
85
  * Configuration for pixel manipulation operations.
86
86
  * Designed to be used by spreading a Rect object ({x, y, w, h}) directly.
@@ -181,6 +181,10 @@ type BinaryMaskRect = Rect & {
181
181
  type: MaskType.BINARY;
182
182
  data: Uint8Array;
183
183
  };
184
+ type AlphaMaskRect = Rect & {
185
+ type: MaskType.ALPHA;
186
+ data: Uint8Array;
187
+ };
184
188
  type NullableBinaryMaskRect = Rect & ({
185
189
  type: MaskType.BINARY;
186
190
  data: Uint8Array;
@@ -195,9 +199,6 @@ type NullableMaskRect = Rect & ({
195
199
  type?: null;
196
200
  data?: null;
197
201
  });
198
- type AlphaMaskRect = Rect & {
199
- mask: AlphaMask;
200
- };
201
202
  type HistoryMutator<T extends {}, D extends {}> = (writer: PixelWriter<any>, deps?: Partial<D>) => T;
202
203
  interface IPixelData {
203
204
  readonly data32: Uint32Array;
@@ -253,7 +254,6 @@ declare class PixelData<T extends ImageDataLike = ImageData> implements IPixelDa
253
254
  readonly height: number;
254
255
  constructor(imageData: T);
255
256
  set(imageData: T): void;
256
- copy(): PixelData<T>;
257
257
  }
258
258
 
259
259
  type FloodFillImageDataOptions = {
@@ -301,6 +301,12 @@ type FloodFillResult = {
301
301
  */
302
302
  declare function floodFillSelection(img: ImageDataLike | PixelData, startX: number, startY: number, { contiguous, tolerance, bounds, }?: FloodFillImageDataOptions): FloodFillResult | null;
303
303
 
304
+ /**
305
+ * Iterates through a line with sub-pixel precision.
306
+ * Guarantees that the first and last points are exactly (x0, y0) and (x1, y1).
307
+ */
308
+ declare function forEachLinePoint(x0: number, y0: number, x1: number, y1: number, callback: (x: number, y: number) => void): void;
309
+
304
310
  declare const overwriteFast: BlendColor32;
305
311
  declare const sourceOverFast: BlendColor32;
306
312
  declare const darkenFast: BlendColor32;
@@ -532,21 +538,44 @@ type PixelCanvas = {
532
538
  */
533
539
  declare function makePixelCanvas(canvas: HTMLCanvasElement): PixelCanvas;
534
540
 
535
- type ReusableCanvas = {
536
- readonly canvas: HTMLCanvasElement;
537
- readonly ctx: CanvasRenderingContext2D;
541
+ type CanvasContext<T> = T extends HTMLCanvasElement ? CanvasRenderingContext2D : OffscreenCanvasRenderingContext2D;
542
+ type ReusableCanvas<T extends HTMLCanvasElement | OffscreenCanvas> = {
543
+ readonly canvas: T;
544
+ readonly ctx: CanvasContext<T>;
538
545
  };
539
546
  /**
540
- * Creates a reusable canvas and context that are not part of the DOM.
547
+ * Creates a reusable HTMLCanvasElement and context that are not part of the DOM.
541
548
  * Ensures it is always set to `context.imageSmoothingEnabled = false`
542
549
  * @see makePixelCanvas
543
550
  * @throws {Error} If the {@link HTMLCanvasElement} context cannot be initialized.
544
551
  */
545
552
  declare function makeReusableCanvas(): {
546
- (width: number, height: number): ReusableCanvas;
553
+ (width: number, height: number): ReusableCanvas<HTMLCanvasElement>;
554
+ reset(): void;
555
+ };
556
+ /**
557
+ * Creates a reusable OffscreenCanvas and context.
558
+ * Ensures it is always set to `context.imageSmoothingEnabled = false`
559
+ * @see makePixelCanvas
560
+ * @throws {Error} If the {@link OffscreenCanvasRenderingContext2D} context cannot be initialized.
561
+ */
562
+ declare function makeReusableOffscreenCanvas(): {
563
+ (width: number, height: number): ReusableCanvas<OffscreenCanvas>;
547
564
  reset(): void;
548
565
  };
549
566
 
567
+ type DrawPixelLayer = (ctx: CanvasRenderingContext2D) => void;
568
+ type DrawScreenLayer = (ctx: CanvasRenderingContext2D, scale: number) => void;
569
+ type CanvasFrameRenderer = ReturnType<typeof makeCanvasFrameRenderer>;
570
+ declare const defaults$j: {
571
+ makeReusableCanvas: typeof makeReusableCanvas;
572
+ };
573
+ type Deps$j = Partial<typeof defaults$j>;
574
+ /**
575
+ * @param deps - @hidden
576
+ */
577
+ declare function makeCanvasFrameRenderer(deps?: Deps$j): (pixelCanvas: PixelCanvas, scale: number, getImageData: () => ImageData | undefined | null, drawPixelLayer?: DrawPixelLayer, drawScreenLayer?: DrawScreenLayer) => void;
578
+
550
579
  /**
551
580
  * Extracts {@link ImageData} from a clipboard event if an image is present.
552
581
  *
@@ -597,16 +626,28 @@ declare function writeImageDataToClipboard(imageData: ImageData): Promise<void>;
597
626
  */
598
627
  declare function writeImgBlobToClipboard(blob: Blob): Promise<void>;
599
628
 
600
- interface HistoryAction {
601
- undo: () => void;
602
- redo: () => void;
603
- dispose?: () => void;
629
+ declare class PixelTile implements IPixelData {
630
+ id: number;
631
+ tx: number;
632
+ ty: number;
633
+ readonly data32: Uint32Array;
634
+ readonly width: number;
635
+ readonly height: number;
636
+ readonly imageData: ImageData;
637
+ constructor(id: number, tx: number, ty: number, tileSize: number, tileArea: number);
604
638
  }
639
+
640
+ type PixelPatchTiles = {
641
+ beforeTiles: PixelTile[];
642
+ afterTiles: PixelTile[];
643
+ };
644
+ declare function applyPatchTiles(target: IPixelData, tiles: PixelTile[], tileSize: number): void;
645
+
605
646
  declare class HistoryManager {
606
647
  maxSteps: number;
607
- undoStack: HistoryAction[];
608
- redoStack: HistoryAction[];
609
- listeners: Set<() => void>;
648
+ readonly undoStack: HistoryAction[];
649
+ readonly redoStack: HistoryAction[];
650
+ readonly listeners: Set<() => void>;
610
651
  constructor(maxSteps?: number);
611
652
  get canUndo(): boolean;
612
653
  get canRedo(): boolean;
@@ -623,53 +664,53 @@ declare class PixelEngineConfig {
623
664
  readonly tileShift: number;
624
665
  readonly tileMask: number;
625
666
  readonly tileArea: number;
626
- constructor(tileSize?: number);
667
+ readonly target: IPixelData;
668
+ readonly targetColumns: number;
669
+ constructor(tileSize: number, target: IPixelData);
670
+ setTarget(target: IPixelData): void;
627
671
  }
628
672
 
629
- type PixelPatchTiles = {
630
- beforeTiles: PixelTile[];
631
- afterTiles: PixelTile[];
632
- };
633
- declare class PixelTile {
634
- id: number;
635
- tx: number;
636
- ty: number;
637
- data32: Uint32Array;
638
- constructor(id: number, tx: number, ty: number, tileArea: number);
673
+ declare class PixelTilePool {
674
+ pool: PixelTile[];
675
+ private tileSize;
676
+ private tileArea;
677
+ constructor(config: PixelEngineConfig);
678
+ getTile(id: number, tx: number, ty: number): PixelTile;
679
+ releaseTile(tile: PixelTile): void;
680
+ releaseTiles(tiles: (PixelTile | undefined)[]): void;
639
681
  }
640
- declare function applyPatchTiles(target: IPixelData, tiles: PixelTile[], tileSize?: number): void;
641
682
 
683
+ type DidChangeFn = (didChange: boolean) => boolean;
642
684
  declare class PixelAccumulator {
643
- target: IPixelData;
644
685
  readonly config: PixelEngineConfig;
686
+ readonly tilePool: PixelTilePool;
645
687
  lookup: (PixelTile | undefined)[];
646
688
  beforeTiles: PixelTile[];
647
- pool: PixelTile[];
648
- constructor(target: IPixelData, config: PixelEngineConfig);
649
- getTile(id: number, tx: number, ty: number): PixelTile;
689
+ constructor(config: PixelEngineConfig, tilePool: PixelTilePool);
650
690
  recyclePatch(patch: PixelPatchTiles): void;
651
691
  /**
652
692
  * @param x pixel x coordinate
653
693
  * @param y pixel y coordinate
654
694
  */
655
- storeTileBeforeState(x: number, y: number): void;
695
+ storePixelBeforeState(x: number, y: number): DidChangeFn;
656
696
  /**
657
- *
658
697
  * @param x pixel x coordinate
659
698
  * @param y pixel y coordinate
660
699
  * @param w pixel width
661
700
  * @param h pixel height
662
701
  */
663
- storeRegionBeforeState(x: number, y: number, w: number, h: number): void;
702
+ storeRegionBeforeState(x: number, y: number, w: number, h: number): DidChangeFn;
664
703
  extractState(tile: PixelTile): void;
665
- extractAfterTiles(): PixelTile[];
666
- reset(): void;
704
+ extractPatch(): PixelPatchTiles;
705
+ rollback(): void;
667
706
  }
668
707
 
669
708
  interface PixelWriterOptions {
670
709
  maxHistorySteps?: number;
671
710
  tileSize?: number;
672
711
  historyManager?: HistoryManager;
712
+ historyActionFactory?: HistoryActionFactory;
713
+ pixelTilePool?: PixelTilePool;
673
714
  }
674
715
  /**
675
716
  * @example
@@ -693,107 +734,82 @@ interface PixelWriterOptions {
693
734
  * })
694
735
  */
695
736
  declare class PixelWriter<M> {
696
- target: IPixelData;
697
- historyManager: HistoryManager;
698
- accumulator: PixelAccumulator;
699
- protected config: PixelEngineConfig;
737
+ readonly historyManager: HistoryManager;
738
+ readonly accumulator: PixelAccumulator;
739
+ readonly historyActionFactory: HistoryActionFactory;
740
+ readonly config: PixelEngineConfig;
700
741
  readonly mutator: M;
701
- constructor(target: IPixelData, mutatorFactory: (writer: PixelWriter<any>) => M, { tileSize, maxHistorySteps, historyManager, }?: PixelWriterOptions);
702
- withHistory(cb: (mutator: M) => void): void;
703
- captureHistory(): void;
742
+ constructor(target: IPixelData, mutatorFactory: (writer: PixelWriter<any>) => M, { tileSize, maxHistorySteps, historyManager, historyActionFactory, pixelTilePool, }?: PixelWriterOptions);
743
+ withHistory(cb: (mutator: M) => void, after?: () => void, afterUndo?: () => void, afterRedo?: () => void): void;
704
744
  }
705
745
 
746
+ interface HistoryAction {
747
+ undo: () => void;
748
+ redo: () => void;
749
+ dispose?: () => void;
750
+ }
751
+ type HistoryActionFactory = typeof makeHistoryAction;
752
+ declare function makeHistoryAction(writer: PixelWriter<any>, patch: PixelPatchTiles, after?: () => void, afterUndo?: () => void, afterRedo?: () => void, applyPatchTilesFn?: typeof applyPatchTiles): HistoryAction;
753
+
706
754
  declare function makeFullPixelMutator(writer: PixelWriter<any>): {
707
- invert(opts?: PixelMutateOptions): void;
708
- fillBinaryMask(color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): void;
709
- fill(color: Color32, rect?: Partial<Rect>): void;
755
+ invert(opts?: PixelMutateOptions): boolean;
756
+ fillRect(color: Color32, rect: Rect): boolean;
757
+ fillBinaryMask(color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): boolean;
758
+ fill(color: Color32, x?: number, y?: number, w?: number, h?: number): boolean;
710
759
  clear(rect?: Partial<Rect>): void;
711
- blendPixelDataBinaryMask(src: IPixelData, mask: BinaryMask, opts?: PixelBlendMaskOptions): void;
712
- blendPixelDataAlphaMask(src: IPixelData, mask: AlphaMask, opts?: PixelBlendMaskOptions): void;
713
- blendPixelData(src: IPixelData, opts?: PixelBlendOptions): void;
714
- blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): void;
715
- blendColor(color: Color32, opts?: ColorBlendOptions): void;
760
+ blendPixelDataBinaryMask(src: IPixelData, mask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
761
+ blendPixelDataAlphaMask(src: IPixelData, mask: AlphaMask, opts?: PixelBlendMaskOptions): boolean;
762
+ blendPixelData(src: IPixelData, opts?: PixelBlendOptions): boolean;
763
+ blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
764
+ applyCircleMask(color: Color32, centerX: number, centerY: number, brush: CircleMask, alpha?: number, blendFn?: BlendColor32): boolean;
765
+ blendColor(color: Color32, opts?: ColorBlendOptions): boolean;
716
766
  applyRectPencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
717
- applyRectPencil(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
767
+ applyRectPencil(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): boolean;
718
768
  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;
719
- applyRectBrush(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): void;
720
- applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushBinaryMask, alpha?: number, blendFn?: BlendColor32): void;
721
- applyCirclePencil(color: Color32, centerX: number, centerY: number, brush: CircleBrushMask, alpha?: number, blendFn?: BlendColor32): void;
722
- applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
723
- applyCircleBrush(color: Color32, centerX: number, centerY: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
724
- applyBinaryMask: (mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions) => void;
725
- applyAlphaMask: (mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions) => void;
769
+ applyRectBrush(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): boolean;
770
+ applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBinaryMask, alpha?: number, blendFn?: BlendColor32): void;
771
+ applyCirclePencil(color: Color32, centerX: number, centerY: number, brush: CircleMask, alpha?: number, blendFn?: BlendColor32): boolean;
772
+ applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
773
+ applyBinaryMask(mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): boolean;
774
+ applyAlphaMask(mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): boolean;
726
775
  };
727
776
 
728
777
  /**
729
778
  * Directly applies a mask to a region of PixelData,
730
779
  * modifying the destination's alpha channel in-place.
780
+ * @returns true if any pixels were actually modified.
731
781
  */
732
- declare function applyAlphaMaskToPixelData(dst: IPixelData, mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): void;
782
+ declare function applyAlphaMaskToPixelData(dst: IPixelData, mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): boolean;
733
783
 
734
- declare const defaults$h: {
784
+ declare const defaults$i: {
735
785
  applyAlphaMaskToPixelData: typeof applyAlphaMaskToPixelData;
736
786
  };
737
- type Deps$h = Partial<typeof defaults$h>;
787
+ type Deps$i = Partial<typeof defaults$i>;
738
788
  /**
739
789
  * @param deps - @hidden
740
790
  */
741
- declare const mutatorApplyAlphaMask: (writer: PixelWriter<any>, deps?: Deps$h) => {
742
- applyAlphaMask: (mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions) => void;
791
+ declare const mutatorApplyAlphaMask: (writer: PixelWriter<any>, deps?: Deps$i) => {
792
+ applyAlphaMask(mask: AlphaMask, opts?: ApplyMaskToPixelDataOptions): boolean;
743
793
  };
744
794
 
745
795
  /**
746
796
  * Directly applies a mask to a region of PixelData,
747
797
  * modifying the destination's alpha channel in-place.
798
+ * @returns true if any pixels were actually modified.
748
799
  */
749
- declare function applyBinaryMaskToPixelData(dst: IPixelData, mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): void;
800
+ declare function applyBinaryMaskToPixelData(dst: IPixelData, mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): boolean;
750
801
 
751
- declare const defaults$g: {
802
+ declare const defaults$h: {
752
803
  applyBinaryMaskToPixelData: typeof applyBinaryMaskToPixelData;
753
804
  };
754
- type Deps$g = Partial<typeof defaults$g>;
755
- /**
756
- * @param deps - @hidden
757
- */
758
- declare const mutatorApplyBinaryMask: (writer: PixelWriter<any>, deps?: Deps$g) => {
759
- applyBinaryMask: (mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions) => void;
760
- };
761
-
762
- /**
763
- * Applies a circular brush to pixel data using a pre-calculated alpha mask.
764
- *
765
- * @param target The PixelData to modify.
766
- * @param color The brush color.
767
- * @param centerX The center x-coordinate of the brush.
768
- * @param centerY The center y-coordinate of the brush.
769
- * @param brush The pre-calculated CircleBrushAlphaMask.
770
- * @param alpha The overall opacity of the brush (0-255).
771
- * @param blendFn
772
- * @param scratchOptions
773
- * @param bounds precalculated result from {@link getCircleBrushOrPencilBounds}
774
- */
775
- declare function applyCircleBrushToPixelData(target: IPixelData, color: Color32, centerX: number, centerY: number, brush: CircleBrushMask, alpha?: number, blendFn?: BlendColor32, scratchOptions?: ColorBlendMaskOptions, bounds?: Rect): void;
776
-
777
- declare function getCircleBrushOrPencilBounds(centerX: number, centerY: number, brushSize: number, targetWidth: number, targetHeight: number, out?: Rect): Rect;
778
-
779
- declare const defaults$f: {
780
- applyCircleBrushToPixelData: typeof applyCircleBrushToPixelData;
781
- getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
782
- };
783
- type Deps$f = Partial<typeof defaults$f>;
805
+ type Deps$h = Partial<typeof defaults$h>;
784
806
  /**
785
807
  * @param deps - @hidden
786
808
  */
787
- declare const mutatorApplyCircleBrush: (writer: PixelWriter<any>, deps?: Deps$f) => {
788
- applyCircleBrush(color: Color32, centerX: number, centerY: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
809
+ declare const mutatorApplyBinaryMask: (writer: PixelWriter<any>, deps?: Deps$h) => {
810
+ applyBinaryMask(mask: BinaryMask, opts?: ApplyMaskToPixelDataOptions): boolean;
789
811
  };
790
812
 
791
- /**
792
- * Iterates through a line with sub-pixel precision.
793
- * Guarantees that the first and last points are exactly (x0, y0) and (x1, y1).
794
- */
795
- declare function forEachLinePoint(x0: number, y0: number, x1: number, y1: number, callback: (x: number, y: number) => void): void;
796
-
797
813
  /**
798
814
  * Blends a solid color into a target pixel buffer using an alpha mask.
799
815
  *
@@ -805,35 +821,65 @@ declare function forEachLinePoint(x0: number, y0: number, x1: number, y1: number
805
821
  * @param color - The solid color to apply.
806
822
  * @param mask - The mask defining the per-pixel opacity of the target area.
807
823
  * @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
824
+ * @returns true if any pixels were actually modified.
808
825
  */
809
- declare function blendColorPixelDataAlphaMask(dst: IPixelData, color: Color32, mask: AlphaMask, opts?: ColorBlendMaskOptions): void;
826
+ declare function blendColorPixelDataAlphaMask(dst: IPixelData, color: Color32, mask: AlphaMask, opts?: ColorBlendMaskOptions): boolean;
827
+
828
+ declare function getCircleBrushOrPencilBounds(centerX: number, centerY: number, brushSize: number, targetWidth: number, targetHeight: number, out?: Rect): Rect;
810
829
 
811
830
  declare function getCircleBrushOrPencilStrokeBounds(x0: number, y0: number, x1: number, y1: number, brushSize: number, result: Rect): Rect;
812
831
 
813
- declare const defaults$e: {
832
+ declare const defaults$g: {
814
833
  forEachLinePoint: typeof forEachLinePoint;
815
834
  blendColorPixelDataAlphaMask: typeof blendColorPixelDataAlphaMask;
816
835
  getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
817
836
  getCircleBrushOrPencilStrokeBounds: typeof getCircleBrushOrPencilStrokeBounds;
818
837
  };
819
- type Deps$e = Partial<typeof defaults$e>;
838
+ type Deps$g = Partial<typeof defaults$g>;
820
839
  /**
821
840
  * @param deps - @hidden
822
841
  */
823
- declare const mutatorApplyCircleBrushStroke: (writer: PixelWriter<any>, deps?: Deps$e) => {
824
- applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
842
+ declare const mutatorApplyCircleBrushStroke: (writer: PixelWriter<any>, deps?: Deps$g) => {
843
+ applyCircleBrushStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleAlphaMask, alpha?: number, blendFn?: BlendColor32): void;
825
844
  };
826
845
 
827
- declare const defaults$d: {
828
- applyCircleBrushToPixelData: typeof applyCircleBrushToPixelData;
846
+ /**
847
+ * Applies a circular mask to pixel data using a pre-calculated alpha mask.
848
+ *
849
+ * @param target The PixelData to modify.
850
+ * @param color The brush color.
851
+ * @param centerX The center x-coordinate of the brush.
852
+ * @param centerY The center y-coordinate of the brush.
853
+ * @param brush The pre-calculated CircleBrushAlphaMask.
854
+ * @param alpha The overall opacity of the brush (0-255).
855
+ * @param blendFn
856
+ * @param scratchOptions
857
+ * @param bounds precalculated result from {@link getCircleBrushOrPencilBounds}
858
+ */
859
+ declare function blendColorPixelDataCircleMask(target: IPixelData, color: Color32, centerX: number, centerY: number, brush: CircleMask, alpha?: number, blendFn?: BlendColor32, scratchOptions?: ColorBlendMaskOptions, bounds?: Rect): boolean;
860
+
861
+ declare const defaults$f: {
862
+ blendColorPixelDataCircleMask: typeof blendColorPixelDataCircleMask;
829
863
  getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
830
864
  };
831
- type Deps$d = Partial<typeof defaults$d>;
865
+ type Deps$f = Partial<typeof defaults$f>;
866
+ /**
867
+ * @param deps - @hidden
868
+ */
869
+ declare const mutatorBlendColorCircleMask: (writer: PixelWriter<any>, deps?: Deps$f) => {
870
+ applyCircleMask(color: Color32, centerX: number, centerY: number, brush: CircleMask, alpha?: number, blendFn?: BlendColor32): boolean;
871
+ };
872
+
873
+ declare const defaults$e: {
874
+ applyCircleMaskToPixelData: typeof blendColorPixelDataCircleMask;
875
+ getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
876
+ };
877
+ type Deps$e = Partial<typeof defaults$e>;
832
878
  /**
833
879
  * @param deps - @hidden
834
880
  **/
835
- declare const mutatorApplyCirclePencil: (writer: PixelWriter<any>, deps?: Deps$d) => {
836
- applyCirclePencil(color: Color32, centerX: number, centerY: number, brush: CircleBrushMask, alpha?: number, blendFn?: BlendColor32): void;
881
+ declare const mutatorApplyCirclePencil: (writer: PixelWriter<any>, deps?: Deps$e) => {
882
+ applyCirclePencil(color: Color32, centerX: number, centerY: number, brush: CircleMask, alpha?: number, blendFn?: BlendColor32): boolean;
837
883
  };
838
884
 
839
885
  /**
@@ -847,97 +893,115 @@ declare const mutatorApplyCirclePencil: (writer: PixelWriter<any>, deps?: Deps$d
847
893
  * @param color - The solid color to apply.
848
894
  * @param mask - The mask defining the per-pixel opacity of the target area.
849
895
  * @param opts - Configuration options including placement coordinates, bounds, global alpha, and mask offsets.
896
+ * @returns true if any pixels were actually modified.
850
897
  */
851
- declare function blendColorPixelDataBinaryMask(dst: IPixelData, color: Color32, mask: BinaryMask, opts?: ColorBlendMaskOptions): void;
898
+ declare function blendColorPixelDataBinaryMask(dst: IPixelData, color: Color32, mask: BinaryMask, opts?: ColorBlendMaskOptions): boolean;
852
899
 
853
- declare const defaults$c: {
900
+ declare const defaults$d: {
854
901
  forEachLinePoint: typeof forEachLinePoint;
855
902
  blendColorPixelDataBinaryMask: typeof blendColorPixelDataBinaryMask;
856
903
  getCircleBrushOrPencilBounds: typeof getCircleBrushOrPencilBounds;
857
904
  getCircleBrushOrPencilStrokeBounds: typeof getCircleBrushOrPencilStrokeBounds;
858
905
  };
859
- type Deps$c = Partial<typeof defaults$c>;
906
+ type Deps$d = Partial<typeof defaults$d>;
860
907
  /**
861
908
  * @param deps - @hidden
862
909
  */
863
- declare const mutatorApplyCirclePencilStroke: (writer: PixelWriter<any>, deps?: Deps$c) => {
864
- applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBrushBinaryMask, alpha?: number, blendFn?: BlendColor32): void;
910
+ declare const mutatorApplyCirclePencilStroke: (writer: PixelWriter<any>, deps?: Deps$d) => {
911
+ applyCirclePencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brush: CircleBinaryMask, alpha?: number, blendFn?: BlendColor32): void;
865
912
  };
866
913
 
867
- 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;
914
+ /**
915
+ * Applies a rectangular brush to the pixel data.
916
+ * @returns true if any pixels were actually modified.
917
+ */
918
+ 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): boolean;
868
919
 
869
920
  declare function getRectBrushOrPencilBounds(centerX: number, centerY: number, brushWidth: number, brushHeight: number, targetWidth: number, targetHeight: number, out?: Rect): Rect;
870
921
 
871
- declare const defaults$b: {
922
+ declare const defaults$c: {
872
923
  applyRectBrushToPixelData: typeof applyRectBrushToPixelData;
873
924
  getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
874
925
  fallOff: () => number;
875
926
  };
876
- type Deps$b = Partial<typeof defaults$b>;
927
+ type Deps$c = Partial<typeof defaults$c>;
877
928
  /**
878
929
  * @param deps - @hidden
879
930
  */
880
- declare const mutatorApplyRectPencil: (writer: PixelWriter<any>, deps?: Deps$b) => {
881
- applyRectPencil(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
931
+ declare const mutatorApplyRectPencil: (writer: PixelWriter<any>, deps?: Deps$c) => {
932
+ applyRectPencil(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): boolean;
882
933
  };
883
934
 
884
935
  declare function getRectBrushOrPencilStrokeBounds(x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, result: Rect): Rect;
885
936
 
886
- declare const defaults$a: {
937
+ declare const defaults$b: {
887
938
  forEachLinePoint: typeof forEachLinePoint;
888
939
  getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
889
940
  getRectBrushOrPencilStrokeBounds: typeof getRectBrushOrPencilStrokeBounds;
890
941
  blendColorPixelDataBinaryMask: typeof blendColorPixelDataBinaryMask;
891
942
  };
892
- type Deps$a = Partial<typeof defaults$a>;
943
+ type Deps$b = Partial<typeof defaults$b>;
893
944
  /**
894
945
  * @param deps - @hidden
895
946
  */
896
- declare const mutatorApplyRectPencilStroke: (writer: PixelWriter<any>, deps?: Deps$a) => {
947
+ declare const mutatorApplyRectPencilStroke: (writer: PixelWriter<any>, deps?: Deps$b) => {
897
948
  applyRectPencilStroke(color: Color32, x0: number, y0: number, x1: number, y1: number, brushWidth: number, brushHeight: number, alpha?: number, blendFn?: BlendColor32): void;
898
949
  };
899
950
 
900
- declare const defaults$9: {
951
+ declare const defaults$a: {
901
952
  applyRectBrushToPixelData: typeof applyRectBrushToPixelData;
902
953
  getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
903
954
  };
904
- type Deps$9 = Partial<typeof defaults$9>;
955
+ type Deps$a = Partial<typeof defaults$a>;
905
956
  /**
906
957
  * @param deps - @hidden
907
958
  */
908
- declare const mutatorApplyRectBrush: (writer: PixelWriter<any>, deps?: Deps$9) => {
909
- applyRectBrush(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): void;
959
+ declare const mutatorApplyRectBrush: (writer: PixelWriter<any>, deps?: Deps$a) => {
960
+ applyRectBrush(color: Color32, centerX: number, centerY: number, brushWidth: number, brushHeight: number, alpha: number | undefined, fallOff: (dist: number) => number, blendFn?: BlendColor32): boolean;
910
961
  };
911
962
 
912
- declare const defaults$8: {
963
+ declare const defaults$9: {
913
964
  forEachLinePoint: typeof forEachLinePoint;
914
965
  blendColorPixelDataAlphaMask: typeof blendColorPixelDataAlphaMask;
915
966
  getRectBrushOrPencilBounds: typeof getRectBrushOrPencilBounds;
916
967
  getRectBrushOrPencilStrokeBounds: typeof getRectBrushOrPencilStrokeBounds;
917
968
  };
918
- type Deps$8 = Partial<typeof defaults$8>;
969
+ type Deps$9 = Partial<typeof defaults$9>;
919
970
  /**
920
971
  * @param deps - @hidden
921
972
  */
922
- declare const mutatorApplyRectBrushStroke: (writer: PixelWriter<any>, deps?: Deps$8) => {
973
+ declare const mutatorApplyRectBrushStroke: (writer: PixelWriter<any>, deps?: Deps$9) => {
923
974
  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;
924
975
  };
925
976
 
926
- declare function blendColorPixelData(dst: IPixelData, color: Color32, opts?: ColorBlendOptions): void;
977
+ /**
978
+ * Blends a solid color into a target pixel buffer.
979
+ * @returns true if any pixels were actually modified.
980
+ */
981
+ declare function blendColorPixelData(dst: IPixelData, color: Color32, opts?: ColorBlendOptions): boolean;
927
982
 
928
- declare const defaults$7: {
983
+ declare const defaults$8: {
929
984
  blendColorPixelData: typeof blendColorPixelData;
930
985
  };
931
- type Deps$7 = Partial<typeof defaults$7>;
986
+ type Deps$8 = Partial<typeof defaults$8>;
932
987
  /**
933
988
  * @param deps - @hidden
934
989
  */
935
- declare const mutatorBlendColor: (writer: PixelWriter<any>, deps?: Deps$7) => {
936
- blendColor(color: Color32, opts?: ColorBlendOptions): void;
990
+ declare const mutatorBlendColor: (writer: PixelWriter<any>, deps?: Deps$8) => {
991
+ blendColor(color: Color32, opts?: ColorBlendOptions): boolean;
937
992
  };
938
993
 
939
- declare function mutatorBlendPixel(writer: PixelWriter<any>): {
940
- blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): void;
994
+ declare function blendPixel(target: IPixelData, x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
995
+
996
+ declare const defaults$7: {
997
+ blendPixel: typeof blendPixel;
998
+ };
999
+ type Deps$7 = Partial<typeof defaults$7>;
1000
+ /**
1001
+ * @param deps - @hidden
1002
+ */
1003
+ declare const mutatorBlendPixel: (writer: PixelWriter<any>, deps?: Partial<Deps$7>) => {
1004
+ blendPixel(x: number, y: number, color: Color32, alpha?: number, blendFn?: BlendColor32): boolean;
941
1005
  };
942
1006
 
943
1007
  /**
@@ -954,7 +1018,7 @@ declare function mutatorBlendPixel(writer: PixelWriter<any>): {
954
1018
  * maskType: MaskType.ALPHA
955
1019
  * });
956
1020
  */
957
- declare function blendPixelData(dst: IPixelData, src: IPixelData, opts?: PixelBlendOptions): void;
1021
+ declare function blendPixelData(dst: IPixelData, src: IPixelData, opts?: PixelBlendOptions): boolean;
958
1022
 
959
1023
  declare const defaults$6: {
960
1024
  blendPixelData: typeof blendPixelData;
@@ -964,10 +1028,10 @@ type Deps$6 = Partial<typeof defaults$6>;
964
1028
  * @param deps - @hidden
965
1029
  */
966
1030
  declare const mutatorBlendPixelData: (writer: PixelWriter<any>, deps?: Partial<Deps$6>) => {
967
- blendPixelData(src: IPixelData, opts?: PixelBlendOptions): void;
1031
+ blendPixelData(src: IPixelData, opts?: PixelBlendOptions): boolean;
968
1032
  };
969
1033
 
970
- declare function blendPixelDataAlphaMask(dst: IPixelData, src: IPixelData, alphaMask: AlphaMask, opts?: PixelBlendMaskOptions): void;
1034
+ declare function blendPixelDataAlphaMask(dst: IPixelData, src: IPixelData, alphaMask: AlphaMask, opts?: PixelBlendMaskOptions): boolean;
971
1035
 
972
1036
  declare const defaults$5: {
973
1037
  blendPixelDataAlphaMask: typeof blendPixelDataAlphaMask;
@@ -977,10 +1041,10 @@ type Deps$5 = Partial<typeof defaults$5>;
977
1041
  * @param deps - @hidden
978
1042
  */
979
1043
  declare const mutatorBlendPixelDataAlphaMask: (writer: PixelWriter<any>, deps?: Partial<Deps$5>) => {
980
- blendPixelDataAlphaMask(src: IPixelData, mask: AlphaMask, opts?: PixelBlendMaskOptions): void;
1044
+ blendPixelDataAlphaMask(src: IPixelData, mask: AlphaMask, opts?: PixelBlendMaskOptions): boolean;
981
1045
  };
982
1046
 
983
- declare function blendPixelDataBinaryMask(dst: IPixelData, src: IPixelData, binaryMask: BinaryMask, opts?: PixelBlendMaskOptions): void;
1047
+ declare function blendPixelDataBinaryMask(dst: IPixelData, src: IPixelData, binaryMask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
984
1048
 
985
1049
  declare const defaults$4: {
986
1050
  blendPixelDataBinaryMask: typeof blendPixelDataBinaryMask;
@@ -990,18 +1054,20 @@ type Deps$4 = Partial<typeof defaults$4>;
990
1054
  * @param deps - @hidden
991
1055
  */
992
1056
  declare const mutatorBlendPixelDataBinaryMask: (writer: PixelWriter<any>, deps?: Partial<Deps$4>) => {
993
- blendPixelDataBinaryMask(src: IPixelData, mask: BinaryMask, opts?: PixelBlendMaskOptions): void;
1057
+ blendPixelDataBinaryMask(src: IPixelData, mask: BinaryMask, opts?: PixelBlendMaskOptions): boolean;
994
1058
  };
995
1059
 
996
1060
  /**
997
1061
  * Fills a region or the {@link IPixelData} buffer with a solid color.
1062
+ * This function is faster than {@link fillPixelData} but does not
1063
+ * return a boolean value indicating changes were made.
998
1064
  *
999
1065
  * @param dst - The target to modify.
1000
1066
  * @param color - The color to apply.
1001
1067
  * @param rect - Defines the area to fill. If omitted, the entire
1002
1068
  * buffer is filled.
1003
1069
  */
1004
- declare function fillPixelData(dst: IPixelData, color: Color32, rect?: Partial<Rect>): void;
1070
+ declare function fillPixelDataFast(dst: IPixelData, color: Color32, rect?: Partial<Rect>): void;
1005
1071
  /**
1006
1072
  * @param dst - The target to modify.
1007
1073
  * @param color - The color to apply.
@@ -1010,10 +1076,10 @@ declare function fillPixelData(dst: IPixelData, color: Color32, rect?: Partial<R
1010
1076
  * @param w - Width of the fill area.
1011
1077
  * @param h - Height of the fill area.
1012
1078
  */
1013
- declare function fillPixelData(dst: IPixelData, color: Color32, x: number, y: number, w: number, h: number): void;
1079
+ declare function fillPixelDataFast(dst: IPixelData, color: Color32, x: number, y: number, w: number, h: number): void;
1014
1080
 
1015
1081
  declare const defaults$3: {
1016
- fillPixelData: typeof fillPixelData;
1082
+ fillPixelData: typeof fillPixelDataFast;
1017
1083
  };
1018
1084
  type Deps$3 = Partial<typeof defaults$3>;
1019
1085
  /**
@@ -1023,6 +1089,25 @@ declare const mutatorClear: (writer: PixelWriter<any>, deps?: Deps$3) => {
1023
1089
  clear(rect?: Partial<Rect>): void;
1024
1090
  };
1025
1091
 
1092
+ /**
1093
+ * Fills a region or the {@link IPixelData} buffer with a solid color.
1094
+ *
1095
+ * @param dst - The target to modify.
1096
+ * @param color - The color to apply.
1097
+ * @param rect - Defines the area to fill. If omitted, the entire
1098
+ * @returns true if any pixels were actually modified.
1099
+ */
1100
+ declare function fillPixelData(dst: IPixelData, color: Color32, rect?: Partial<Rect>): boolean;
1101
+ /**
1102
+ * @param dst - The target to modify.
1103
+ * @param color - The color to apply.
1104
+ * @param x - Starting horizontal coordinate.
1105
+ * @param y - Starting vertical coordinate.
1106
+ * @param w - Width of the fill area.
1107
+ * @param h - Height of the fill area.
1108
+ */
1109
+ declare function fillPixelData(dst: IPixelData, color: Color32, x: number, y: number, w: number, h: number): boolean;
1110
+
1026
1111
  declare const defaults$2: {
1027
1112
  fillPixelData: typeof fillPixelData;
1028
1113
  };
@@ -1031,7 +1116,13 @@ type Deps$2 = Partial<typeof defaults$2>;
1031
1116
  * @param deps - @hidden
1032
1117
  */
1033
1118
  declare const mutatorFill: (writer: PixelWriter<any>, deps?: Deps$2) => {
1034
- fill(color: Color32, rect?: Partial<Rect>): void;
1119
+ fill(color: Color32, x?: number, y?: number, w?: number, h?: number): boolean;
1120
+ };
1121
+ /**
1122
+ * @param deps - @hidden
1123
+ */
1124
+ declare const mutatorFillRect: (writer: PixelWriter<any>, deps?: Deps$2) => {
1125
+ fillRect(color: Color32, rect: Rect): boolean;
1035
1126
  };
1036
1127
 
1037
1128
  /**
@@ -1043,7 +1134,7 @@ declare const mutatorFill: (writer: PixelWriter<any>, deps?: Deps$2) => {
1043
1134
  * @param x - Starting horizontal coordinate for the mask placement.
1044
1135
  * @param y - Starting vertical coordinate for the mask placement.
1045
1136
  */
1046
- declare function fillPixelDataBinaryMask(dst: IPixelData, color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): void;
1137
+ declare function fillPixelDataBinaryMask(dst: IPixelData, color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): boolean;
1047
1138
 
1048
1139
  declare const defaults$1: {
1049
1140
  fillPixelDataBinaryMask: typeof fillPixelDataBinaryMask;
@@ -1053,10 +1144,10 @@ type Deps$1 = Partial<typeof defaults$1>;
1053
1144
  * @param deps - @hidden
1054
1145
  */
1055
1146
  declare const mutatorFillBinaryMask: (writer: PixelWriter<any>, deps?: Deps$1) => {
1056
- fillBinaryMask(color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): void;
1147
+ fillBinaryMask(color: Color32, mask: BinaryMask, alpha?: number, x?: number, y?: number): boolean;
1057
1148
  };
1058
1149
 
1059
- declare function invertPixelData(pixelData: IPixelData, opts?: PixelMutateOptions): void;
1150
+ declare function invertPixelData(pixelData: IPixelData, opts?: PixelMutateOptions): boolean;
1060
1151
 
1061
1152
  declare const defaults: {
1062
1153
  invertPixelData: typeof invertPixelData;
@@ -1066,7 +1157,7 @@ type Deps = Partial<typeof defaults>;
1066
1157
  * @param deps - @hidden
1067
1158
  */
1068
1159
  declare const mutatorInvert: (writer: PixelWriter<any>, deps?: Deps) => {
1069
- invert(opts?: PixelMutateOptions): void;
1160
+ invert(opts?: PixelMutateOptions): boolean;
1070
1161
  };
1071
1162
 
1072
1163
  declare function copyImageData({ data, width, height }: ImageDataLike): ImageData;
@@ -1458,9 +1549,9 @@ declare function makeAlphaMask(w: number, h: number, data?: Uint8Array): AlphaMa
1458
1549
  */
1459
1550
  declare function makeBinaryMask(w: number, h: number, data?: Uint8Array): BinaryMask;
1460
1551
 
1461
- declare function makeCircleBrushAlphaMask(size: number, fallOff?: (d: number) => number): CircleBrushAlphaMask;
1552
+ declare function makeCircleAlphaMask(size: number, fallOff?: (d: number) => number): CircleAlphaMask;
1462
1553
 
1463
- declare function makeCircleBrushBinaryMask(size: number): CircleBrushBinaryMask;
1554
+ declare function makeCircleBinaryMask(size: number): CircleBinaryMask;
1464
1555
 
1465
1556
  declare function applyBinaryMaskToAlphaMask(alphaMaskDst: AlphaMask, binaryMaskSrc: BinaryMask, opts?: ApplyMaskToPixelDataOptions): void;
1466
1557
 
@@ -1530,12 +1621,25 @@ declare function mergeBinaryMasks(dst: BinaryMask, src: BinaryMask, opts: MergeA
1530
1621
 
1531
1622
  declare function setMaskData(mask: Mask, width: number, height: number, data: Uint8Array): void;
1532
1623
 
1533
- declare function subtractBinaryMaskRects(current: NullableBinaryMaskRect[], subtracting: NullableBinaryMaskRect[]): NullableBinaryMaskRect[];
1534
-
1535
1624
  declare function merge2BinaryMaskRects(a: NullableBinaryMaskRect, b: NullableBinaryMaskRect): NullableBinaryMaskRect;
1536
1625
 
1537
1626
  declare function mergeBinaryMaskRects(current: NullableBinaryMaskRect[], adding: NullableBinaryMaskRect[]): NullableBinaryMaskRect[];
1538
1627
 
1628
+ declare function subtractBinaryMaskRects(current: NullableBinaryMaskRect[], subtracting: NullableBinaryMaskRect[]): NullableBinaryMaskRect[];
1629
+
1630
+ declare class PaintBuffer {
1631
+ readonly config: PixelEngineConfig;
1632
+ readonly tilePool: PixelTilePool;
1633
+ readonly lookup: (PixelTile | undefined)[];
1634
+ constructor(config: PixelEngineConfig, tilePool: PixelTilePool);
1635
+ private processMaskTiles;
1636
+ writeColorBinaryMaskRect(color: Color32, mask: BinaryMaskRect): void;
1637
+ writeColorAlphaMaskRect(color: Color32, mask: AlphaMaskRect): void;
1638
+ clear(): void;
1639
+ }
1640
+
1641
+ declare function blendPixelDataPaintBuffer(paintBuffer: PaintBuffer, target: IPixelData, alpha?: number, blendFn?: BlendColor32, blendPixelDataFn?: typeof blendPixelData): void;
1642
+
1539
1643
  /**
1540
1644
  * Clears a region of the PixelData to transparent (0x00000000).
1541
1645
  * Internally uses the optimized fillPixelData.
@@ -1614,4 +1718,15 @@ declare function getRectsBounds<T extends Rect>(rects: T[]): T;
1614
1718
  */
1615
1719
  declare function trimRectBounds<T extends NullableMaskRect>(target: T, bounds: Rect): void;
1616
1720
 
1617
- 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, mutatorBlendPixelDataAlphaMask, mutatorBlendPixelDataBinaryMask, 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 };
1721
+ type PaintBufferRenderer = ReturnType<typeof makePaintBufferRenderer>;
1722
+ /**
1723
+ *
1724
+ * @param paintBuffer
1725
+ * @param offscreenCanvasClass - @internal
1726
+ */
1727
+ declare function makePaintBufferRenderer(paintBuffer: PaintBuffer, offscreenCanvasClass?: {
1728
+ new (width: number, height: number): OffscreenCanvas;
1729
+ prototype: OffscreenCanvas;
1730
+ }): (target: CanvasRenderingContext2D) => void;
1731
+
1732
+ 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 CanvasContext, type CanvasFrameRenderer, type CircleAlphaMask, type CircleBinaryMask, type CircleMask, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, type DidChangeFn, type DrawPixelLayer, type DrawScreenLayer, type FloodFillImageDataOptions, type FloodFillResult, type HistoryAction, type HistoryActionFactory, 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, PaintBuffer, type PaintBufferRenderer, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, PixelBuffer32, 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, applyPatchTiles, applyRectBrushToPixelData, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendColorPixelDataCircleMask, blendPixel, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, blendPixelDataPaintBuffer, 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, fillPixelDataFast, 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, makeCanvasFrameRenderer, makeCircleAlphaMask, makeCircleBinaryMask, makeFastBlendModeRegistry, makeFullPixelMutator, makeHistoryAction, makeImageDataLike, makePaintBufferRenderer, makePerfectBlendModeRegistry, makePixelCanvas, makeReusableCanvas, makeReusableImageData, makeReusableOffscreenCanvas, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyCircleBrushStroke, mutatorApplyCirclePencil, mutatorApplyCirclePencilStroke, mutatorApplyRectBrush, mutatorApplyRectBrushStroke, mutatorApplyRectPencil, mutatorApplyRectPencilStroke, mutatorBlendColor, mutatorBlendColorCircleMask, mutatorBlendPixel, mutatorBlendPixelData, mutatorBlendPixelDataAlphaMask, mutatorBlendPixelDataBinaryMask, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorFillRect, 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 };