pixel-data-js 0.33.0 → 0.35.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.
@@ -1051,6 +1051,16 @@ interface PaintAlphaMask<T extends PaintMaskOutline = PaintMaskOutline> extends
1051
1051
  interface PaintBinaryMask<T extends PaintMaskOutline = PaintMaskOutline> extends BasePaintMask<T>, BinaryMask {
1052
1052
  }
1053
1053
  type PaintMask = PaintAlphaMask<any> | PaintBinaryMask<any>;
1054
+ type PaintBrush = PaintMask | PaintRect;
1055
+ interface PaintRect {
1056
+ type: null;
1057
+ readonly outlineType: PaintMaskOutline.RECT;
1058
+ w: number;
1059
+ h: number;
1060
+ centerOffsetX: number;
1061
+ centerOffsetY: number;
1062
+ data: null;
1063
+ }
1054
1064
 
1055
1065
  /**
1056
1066
  * Blends a solid color into a target pixel buffer using an alpha mask.
@@ -1707,8 +1717,8 @@ declare class AlphaMaskPaintBuffer {
1707
1717
  paintAlphaMask(brush: PaintAlphaMask, startX: number, startY: number, endX: number, endY: number): boolean;
1708
1718
  paintBinaryMask(brush: PaintBinaryMask, alpha: number, x: number, y: number): boolean;
1709
1719
  paintBinaryMask(brush: PaintBinaryMask, alpha: number, startX: number, startY: number, endX: number, endY: number): boolean;
1710
- paintRect(alpha: number, brushWidth: number, brushHeight: number, x: number, y: number): boolean;
1711
- paintRect(alpha: number, brushWidth: number, brushHeight: number, startX: number, startY: number, endX: number, endY: number): boolean;
1720
+ paintRect(alpha: number, brush: PaintRect, x: number, y: number): boolean;
1721
+ paintRect(alpha: number, brush: PaintRect, startX: number, startY: number, endX: number, endY: number): boolean;
1712
1722
  clear(): void;
1713
1723
  }
1714
1724
 
@@ -1723,8 +1733,8 @@ declare class BinaryMaskPaintBuffer {
1723
1733
  constructor(config: PixelEngineConfig, tilePool: TilePool<BinaryMaskTile>);
1724
1734
  paintBinaryMask(brush: PaintBinaryMask, x: number, y: number): boolean;
1725
1735
  paintBinaryMask(brush: PaintBinaryMask, startX: number, startY: number, endX: number, endY: number): boolean;
1726
- paintRect(brushWidth: number, brushHeight: number, x: number, y: number): boolean;
1727
- paintRect(brushWidth: number, brushHeight: number, startX: number, startY: number, endX: number, endY: number): boolean;
1736
+ paintRect(brush: PaintRect, x: number, y: number): boolean;
1737
+ paintRect(brush: PaintRect, startX: number, startY: number, endX: number, endY: number): boolean;
1728
1738
  clear(): void;
1729
1739
  }
1730
1740
 
@@ -1738,8 +1748,8 @@ declare class ColorPaintBuffer {
1738
1748
  paintAlphaMask(color: Color32, brush: PaintAlphaMask, startX: number, startY: number, endX: number, endY: number): boolean;
1739
1749
  paintBinaryMask(color: Color32, brush: PaintBinaryMask, x: number, y: number): boolean;
1740
1750
  paintBinaryMask(color: Color32, brush: PaintBinaryMask, startX: number, startY: number, endX: number, endY: number): boolean;
1741
- paintRect(color: Color32, brushWidth: number, brushHeight: number, x: number, y: number): boolean;
1742
- paintRect(color: Color32, brushWidth: number, brushHeight: number, startX: number, startY: number, endX: number, endY: number): boolean;
1751
+ paintRect(color: Color32, brush: PaintRect, x: number, y: number): boolean;
1752
+ paintRect(color: Color32, brush: PaintRect, startX: number, startY: number, endX: number, endY: number): boolean;
1743
1753
  clear(): void;
1744
1754
  }
1745
1755
 
@@ -1794,16 +1804,18 @@ declare function makePaintAlphaMask(mask: AlphaMask): PaintAlphaMask;
1794
1804
 
1795
1805
  declare function makeRectFalloffPaintAlphaMask(width: number, height: number, fallOff?: (d: number) => number): PaintAlphaMask;
1796
1806
 
1807
+ declare function makePaintRect(w: number, h: number): PaintRect;
1808
+
1797
1809
  type PaintCursorRenderer = ReturnType<typeof makePaintCursorRenderer>;
1798
1810
  declare function makePaintCursorRenderer<T extends HTMLCanvasElement | OffscreenCanvas = OffscreenCanvas>(reusableCanvasFactory?: () => ReusableCanvasFactory<T>): {
1799
- update: (paintMask?: PaintMask, scale?: number, color?: Color32, alphaThreshold?: number) => void;
1811
+ update: (paintMask?: PaintBrush, scale?: number, color?: Color32, alphaThreshold?: number) => void;
1800
1812
  getBounds: (centerX: number, centerY: number) => Rect;
1801
1813
  getBoundsScaled: (centerX: number, centerY: number) => Rect;
1802
1814
  draw: (drawCtx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, centerX: number, centerY: number) => void;
1803
1815
  getSettings: () => {
1804
1816
  color: Color32;
1805
1817
  scale: number;
1806
- currentMask: PaintMask;
1818
+ currentBrush: PaintBrush;
1807
1819
  };
1808
1820
  };
1809
1821
 
@@ -1973,4 +1985,4 @@ declare const makeBinaryMaskTile: TileFactory<BinaryMaskTile>;
1973
1985
 
1974
1986
  declare function makePixelTile(id: number, tx: number, ty: number, tileSize: number, tileArea: number): PixelTile;
1975
1987
 
1976
- export { type AlphaMask, AlphaMaskPaintBuffer, type AlphaMaskPaintBufferCanvasRenderer, type AlphaMaskPaintBufferManager, type AlphaMaskRect, type AlphaMaskTile, type ApplyMaskToPixelDataOptions, BASE_FAST_BLEND_MODE_FUNCTIONS, BASE_PERFECT_BLEND_MODE_FUNCTIONS, type Base64EncodedUInt8Array, BaseBlendMode, type BaseBlendModes, type BaseMask, type BasePixelBlendOptions, type BatchedQueue, type BatchedQueueFn, type BinaryMask, BinaryMaskPaintBuffer, type BinaryMaskPaintBufferCanvasRenderer, type BinaryMaskPaintBufferManager, type BinaryMaskRect, type BinaryMaskTile, type BlendColor32, type BlendModeRegistry, CANVAS_COMPOSITE_MAP, type CanvasBlendModeIndex, type CanvasCompositeOperation, type CanvasContext, type CanvasFrameRenderer, type CanvasObjectFactory, type CanvasPixelDataRenderer, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, ColorPaintBuffer, type ColorPaintBufferCanvasRenderer, type ColorPaintBufferManager, type DidChangeFn, type DrawPixelLayer, type DrawScreenLayer, _errors as ERRORS, type FloodFillResult, type HistoryAction, type HistoryActionFactory, HistoryManager, type HistoryMutator, type ImageDataLike, type IndexedImage, type InvertMask, type Mask, type MaskOffset, type MaskRect, MaskType, type MergeAlphaMasksOptions, type MutableAlphaMask, type MutableBinaryMask, type MutableMask, type MutablePixelData32, type NullableBinaryMaskRect, type NullableMaskRect, type PaintAlphaMask, type PaintBinaryMask, type PaintCursorRenderer, type PaintMask, PaintMaskOutline, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, type PixelCanvas, type PixelData, type PixelData32, PixelEngineConfig, type PixelMutateOptions, type PixelPatchTiles, type PixelRect, type PixelTile, PixelWriter, type PixelWriterOptions, type RGBA, type Rect, type RequiredBlendModes, type ReusableCanvas, type ReusableCanvasFactory, type ReusableImageData, type ReusablePixelData, type SerializedImageData, type Tile, type TileFactory, TilePool, TileType, UnsupportedFormatError, _macro_imageDataToUint32Array, applyAlphaMaskToPixelData, applyBinaryMaskToAlphaMask, applyBinaryMaskToPixelData, applyMaskToPixelData, applyPatchTiles, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendColorPixelDataMask, blendColorPixelDataPaintAlphaMask, blendColorPixelDataPaintBinaryMask, blendColorPixelDataPaintMask, blendPixel, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, blendPixelDataMask, blendPixelDataPaintBuffer, clearPixelDataFast, color32ToCssRGBA, color32ToHex, colorBurnFast, colorBurnPerfect, colorDistance, colorDodgeFast, colorDodgePerfect, commitColorPaintBuffer, commitMaskPaintBuffer, copyImageData, copyImageDataLike, copyMask, copyPixelData, darkenFast, darkenPerfect, darkerFast, darkerPerfect, deserializeImageData, deserializeNullableImageData, deserializeRawImageData, destinationAtopFast, destinationAtopPerfect, destinationInFast, destinationInPerfect, destinationOutFast, destinationOutPerfect, destinationOverFast, destinationOverPerfect, differenceFast, differencePerfect, divideFast, dividePerfect, eachTileInBounds, exclusionFast, exclusionPerfect, extractImageData, extractImageDataBuffer, extractMask, extractMaskBuffer, extractPixelData, extractPixelDataBuffer, fileInputChangeToImageData, fileToImageData, fillPixelData, fillPixelDataBinaryMask, fillPixelDataFast, floodFillSelection, forEachLinePoint, getImageDataFromClipboard, getIndexedImageColor, getIndexedImageColorCounts, getRectsBounds, getSupportedPixelFormats, hardLightFast, hardLightPerfect, hardMixFast, hardMixPerfect, imageDataToAlphaMaskBuffer, imageDataToDataUrl, imageDataToImgBlob, imageDataToUint32Array, imgBlobToImageData, indexedImageToAverageColor, indexedImageToImageData, invertAlphaMask, invertBinaryMask, invertImageData, invertPixelData, lerpColor32, lerpColor32Fast, lightenFast, lightenPerfect, lighterFast, lighterPerfect, linearBurnFast, linearBurnPerfect, linearDodgeFast, linearDodgePerfect, linearLightFast, linearLightPerfect, makeAlphaMask, makeAlphaMaskPaintBufferCanvasRenderer, makeAlphaMaskPaintBufferCommitter, makeAlphaMaskPaintBufferManager, makeAlphaMaskTile, makeBatchedQueue, makeBinaryMask, makeBinaryMaskFromAlphaMask, makeBinaryMaskOutline, makeBinaryMaskPaintBufferCanvasRenderer, makeBinaryMaskPaintBufferCommitter, makeBinaryMaskPaintBufferManager, makeBinaryMaskTile, makeBlendModeRegistry, makeCanvasFrameRenderer, makeCanvasPixelDataRenderer, makeCircleBinaryMaskOutline, makeCirclePaintAlphaMask, makeCirclePaintBinaryMask, makeColorPaintBufferCanvasRenderer, makeColorPaintBufferCommitter, makeColorPaintBufferManager, makeFastBlendModeRegistry, makeFullPixelMutator, makeHistoryAction, makeImageDataLike, makeIndexedImage, makeIndexedImageFromImageData, makeIndexedImageFromImageDataRaw, makePaintAlphaMask, makePaintBinaryMask, makePaintCursorRenderer, makePerfectBlendModeRegistry, makePixelCanvas, makePixelData, makePixelTile, makeRectBinaryMaskOutline, makeRectFalloffPaintAlphaMask, makeRenderQueue, makeReusableCanvas, makeReusableImageData, makeReusableOffscreenCanvas, makeReusablePixelData, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyMask, mutatorBlendAlphaMask, mutatorBlendBinaryMask, mutatorBlendColor, mutatorBlendColorPaintAlphaMask, mutatorBlendColorPaintBinaryMask, mutatorBlendColorPaintMask, mutatorBlendColorPaintRect, mutatorBlendMask, mutatorBlendPixel, mutatorBlendPixelData, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorFillRect, mutatorInvert, overlayFast, overlayPerfect, overwriteBase, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, reflectPixelDataHorizontal, reflectPixelDataVertical, resampleImageData, resampleIndexedImage, resamplePixelData, resamplePixelDataInPlace, resampleUint32Array, resizeImageData, resizePixelData, rotatePixelData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, setMaskData, setPixelData, softLightFast, softLightPerfect, sourceAtopFast, sourceAtopPerfect, sourceInFast, sourceInPerfect, sourceOutFast, sourceOutPerfect, sourceOverFast, sourceOverPerfect, subtractBinaryMaskRects, subtractFast, subtractPerfect, toBlendModeIndexAndName, trimMaskRectBounds, trimRectBounds, uInt32ArrayToImageData, uInt32ArrayToImageDataLike, uInt32ArrayToPixelData, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageData, writeImageDataBuffer, writeImageDataToClipboard, writeImgBlobToClipboard, writePaintBufferToPixelData, writePixelData, writePixelDataBuffer, xorFast, xorPerfect };
1988
+ export { type AlphaMask, AlphaMaskPaintBuffer, type AlphaMaskPaintBufferCanvasRenderer, type AlphaMaskPaintBufferManager, type AlphaMaskRect, type AlphaMaskTile, type ApplyMaskToPixelDataOptions, BASE_FAST_BLEND_MODE_FUNCTIONS, BASE_PERFECT_BLEND_MODE_FUNCTIONS, type Base64EncodedUInt8Array, BaseBlendMode, type BaseBlendModes, type BaseMask, type BasePixelBlendOptions, type BatchedQueue, type BatchedQueueFn, type BinaryMask, BinaryMaskPaintBuffer, type BinaryMaskPaintBufferCanvasRenderer, type BinaryMaskPaintBufferManager, type BinaryMaskRect, type BinaryMaskTile, type BlendColor32, type BlendModeRegistry, CANVAS_COMPOSITE_MAP, type CanvasBlendModeIndex, type CanvasCompositeOperation, type CanvasContext, type CanvasFrameRenderer, type CanvasObjectFactory, type CanvasPixelDataRenderer, type Color32, type ColorBlendMaskOptions, type ColorBlendOptions, ColorPaintBuffer, type ColorPaintBufferCanvasRenderer, type ColorPaintBufferManager, type DidChangeFn, type DrawPixelLayer, type DrawScreenLayer, _errors as ERRORS, type FloodFillResult, type HistoryAction, type HistoryActionFactory, HistoryManager, type HistoryMutator, type ImageDataLike, type IndexedImage, type InvertMask, type Mask, type MaskOffset, type MaskRect, MaskType, type MergeAlphaMasksOptions, type MutableAlphaMask, type MutableBinaryMask, type MutableMask, type MutablePixelData32, type NullableBinaryMaskRect, type NullableMaskRect, type PaintAlphaMask, type PaintBinaryMask, type PaintBrush, type PaintCursorRenderer, type PaintMask, PaintMaskOutline, type PaintRect, PixelAccumulator, type PixelBlendMaskOptions, type PixelBlendOptions, type PixelCanvas, type PixelData, type PixelData32, PixelEngineConfig, type PixelMutateOptions, type PixelPatchTiles, type PixelRect, type PixelTile, PixelWriter, type PixelWriterOptions, type RGBA, type Rect, type RequiredBlendModes, type ReusableCanvas, type ReusableCanvasFactory, type ReusableImageData, type ReusablePixelData, type SerializedImageData, type Tile, type TileFactory, TilePool, TileType, UnsupportedFormatError, _macro_imageDataToUint32Array, applyAlphaMaskToPixelData, applyBinaryMaskToAlphaMask, applyBinaryMaskToPixelData, applyMaskToPixelData, applyPatchTiles, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendColorPixelDataAlphaMask, blendColorPixelDataBinaryMask, blendColorPixelDataMask, blendColorPixelDataPaintAlphaMask, blendColorPixelDataPaintBinaryMask, blendColorPixelDataPaintMask, blendPixel, blendPixelData, blendPixelDataAlphaMask, blendPixelDataBinaryMask, blendPixelDataMask, blendPixelDataPaintBuffer, clearPixelDataFast, color32ToCssRGBA, color32ToHex, colorBurnFast, colorBurnPerfect, colorDistance, colorDodgeFast, colorDodgePerfect, commitColorPaintBuffer, commitMaskPaintBuffer, copyImageData, copyImageDataLike, copyMask, copyPixelData, darkenFast, darkenPerfect, darkerFast, darkerPerfect, deserializeImageData, deserializeNullableImageData, deserializeRawImageData, destinationAtopFast, destinationAtopPerfect, destinationInFast, destinationInPerfect, destinationOutFast, destinationOutPerfect, destinationOverFast, destinationOverPerfect, differenceFast, differencePerfect, divideFast, dividePerfect, eachTileInBounds, exclusionFast, exclusionPerfect, extractImageData, extractImageDataBuffer, extractMask, extractMaskBuffer, extractPixelData, extractPixelDataBuffer, fileInputChangeToImageData, fileToImageData, fillPixelData, fillPixelDataBinaryMask, fillPixelDataFast, floodFillSelection, forEachLinePoint, getImageDataFromClipboard, getIndexedImageColor, getIndexedImageColorCounts, getRectsBounds, getSupportedPixelFormats, hardLightFast, hardLightPerfect, hardMixFast, hardMixPerfect, imageDataToAlphaMaskBuffer, imageDataToDataUrl, imageDataToImgBlob, imageDataToUint32Array, imgBlobToImageData, indexedImageToAverageColor, indexedImageToImageData, invertAlphaMask, invertBinaryMask, invertImageData, invertPixelData, lerpColor32, lerpColor32Fast, lightenFast, lightenPerfect, lighterFast, lighterPerfect, linearBurnFast, linearBurnPerfect, linearDodgeFast, linearDodgePerfect, linearLightFast, linearLightPerfect, makeAlphaMask, makeAlphaMaskPaintBufferCanvasRenderer, makeAlphaMaskPaintBufferCommitter, makeAlphaMaskPaintBufferManager, makeAlphaMaskTile, makeBatchedQueue, makeBinaryMask, makeBinaryMaskFromAlphaMask, makeBinaryMaskOutline, makeBinaryMaskPaintBufferCanvasRenderer, makeBinaryMaskPaintBufferCommitter, makeBinaryMaskPaintBufferManager, makeBinaryMaskTile, makeBlendModeRegistry, makeCanvasFrameRenderer, makeCanvasPixelDataRenderer, makeCircleBinaryMaskOutline, makeCirclePaintAlphaMask, makeCirclePaintBinaryMask, makeColorPaintBufferCanvasRenderer, makeColorPaintBufferCommitter, makeColorPaintBufferManager, makeFastBlendModeRegistry, makeFullPixelMutator, makeHistoryAction, makeImageDataLike, makeIndexedImage, makeIndexedImageFromImageData, makeIndexedImageFromImageDataRaw, makePaintAlphaMask, makePaintBinaryMask, makePaintCursorRenderer, makePaintRect, makePerfectBlendModeRegistry, makePixelCanvas, makePixelData, makePixelTile, makeRectBinaryMaskOutline, makeRectFalloffPaintAlphaMask, makeRenderQueue, makeReusableCanvas, makeReusableImageData, makeReusableOffscreenCanvas, makeReusablePixelData, merge2BinaryMaskRects, mergeAlphaMasks, mergeBinaryMaskRects, mergeBinaryMasks, multiplyFast, multiplyPerfect, mutatorApplyAlphaMask, mutatorApplyBinaryMask, mutatorApplyMask, mutatorBlendAlphaMask, mutatorBlendBinaryMask, mutatorBlendColor, mutatorBlendColorPaintAlphaMask, mutatorBlendColorPaintBinaryMask, mutatorBlendColorPaintMask, mutatorBlendColorPaintRect, mutatorBlendMask, mutatorBlendPixel, mutatorBlendPixelData, mutatorClear, mutatorFill, mutatorFillBinaryMask, mutatorFillRect, mutatorInvert, overlayFast, overlayPerfect, overwriteBase, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, reflectPixelDataHorizontal, reflectPixelDataVertical, resampleImageData, resampleIndexedImage, resamplePixelData, resamplePixelDataInPlace, resampleUint32Array, resizeImageData, resizePixelData, rotatePixelData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, setMaskData, setPixelData, softLightFast, softLightPerfect, sourceAtopFast, sourceAtopPerfect, sourceInFast, sourceInPerfect, sourceOutFast, sourceOutPerfect, sourceOverFast, sourceOverPerfect, subtractBinaryMaskRects, subtractFast, subtractPerfect, toBlendModeIndexAndName, trimMaskRectBounds, trimRectBounds, uInt32ArrayToImageData, uInt32ArrayToImageDataLike, uInt32ArrayToPixelData, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageData, writeImageDataBuffer, writeImageDataToClipboard, writeImgBlobToClipboard, writePaintBufferToPixelData, writePixelData, writePixelDataBuffer, xorFast, xorPerfect };
@@ -5184,7 +5184,7 @@ var AlphaMaskPaintBuffer = class {
5184
5184
  });
5185
5185
  return changed;
5186
5186
  }
5187
- paintRect(alpha, brushWidth, brushHeight, x0, y0, x1 = x0, y1 = y0) {
5187
+ paintRect(alpha, brush, x0, y0, x1 = x0, y1 = y0) {
5188
5188
  const scratch = this.scratchBounds;
5189
5189
  const lookup = this.lookup;
5190
5190
  const tilePool = this.tilePool;
@@ -5192,8 +5192,10 @@ var AlphaMaskPaintBuffer = class {
5192
5192
  const tileShift = config.tileShift;
5193
5193
  const tileMask = config.tileMask;
5194
5194
  const target = config.target;
5195
- const centerOffsetX = -(brushWidth - 1 >> 1);
5196
- const centerOffsetY = -(brushHeight - 1 >> 1);
5195
+ const brushWidth = brush.w;
5196
+ const brushHeight = brush.h;
5197
+ const centerOffsetX = brush.centerOffsetX;
5198
+ const centerOffsetY = brush.centerOffsetY;
5197
5199
  const trimRectBoundsFn = this.trimRectBoundsFn;
5198
5200
  const eachTileInBoundsFn = this.eachTileInBoundsFn;
5199
5201
  let changed = false;
@@ -5293,7 +5295,7 @@ var BinaryMaskPaintBuffer = class {
5293
5295
  });
5294
5296
  return changed;
5295
5297
  }
5296
- paintRect(brushWidth, brushHeight, x0, y0, x1 = x0, y1 = y0) {
5298
+ paintRect(brush, x0, y0, x1 = x0, y1 = y0) {
5297
5299
  const scratch = this.scratchBounds;
5298
5300
  const lookup = this.lookup;
5299
5301
  const tilePool = this.tilePool;
@@ -5301,8 +5303,10 @@ var BinaryMaskPaintBuffer = class {
5301
5303
  const tileShift = config.tileShift;
5302
5304
  const tileMask = config.tileMask;
5303
5305
  const target = config.target;
5304
- const centerOffsetX = -(brushWidth - 1 >> 1);
5305
- const centerOffsetY = -(brushHeight - 1 >> 1);
5306
+ const brushWidth = brush.w;
5307
+ const brushHeight = brush.h;
5308
+ const centerOffsetX = brush.centerOffsetX;
5309
+ const centerOffsetY = brush.centerOffsetY;
5306
5310
  const trimRectBoundsFn = this.trimRectBoundsFn;
5307
5311
  const eachTileInBoundsFn = this.eachTileInBoundsFn;
5308
5312
  let changed = false;
@@ -5453,7 +5457,7 @@ var ColorPaintBuffer = class {
5453
5457
  });
5454
5458
  return changed;
5455
5459
  }
5456
- paintRect(color, brushWidth, brushHeight, x0, y0, x1 = x0, y1 = y0) {
5460
+ paintRect(color, brush, x0, y0, x1 = x0, y1 = y0) {
5457
5461
  const alphaIsZero = color >>> 24 === 0;
5458
5462
  if (alphaIsZero) return false;
5459
5463
  const scratch = this.scratchBounds;
@@ -5463,8 +5467,10 @@ var ColorPaintBuffer = class {
5463
5467
  const tileShift = config.tileShift;
5464
5468
  const tileMask = config.tileMask;
5465
5469
  const target = config.target;
5466
- const centerOffsetX = -(brushWidth - 1 >> 1);
5467
- const centerOffsetY = -(brushHeight - 1 >> 1);
5470
+ const brushWidth = brush.w;
5471
+ const brushHeight = brush.h;
5472
+ const centerOffsetX = brush.centerOffsetX;
5473
+ const centerOffsetY = brush.centerOffsetY;
5468
5474
  let changed = false;
5469
5475
  forEachLinePoint(x0, y0, x1, y1, (px, py) => {
5470
5476
  const topLeftX = Math.floor(px + centerOffsetX);
@@ -5887,6 +5893,19 @@ function makeRectFalloffPaintAlphaMask(width, height, fallOff = (d) => d) {
5887
5893
  };
5888
5894
  }
5889
5895
 
5896
+ // src/Paint/PaintRect.ts
5897
+ function makePaintRect(w, h) {
5898
+ return {
5899
+ type: null,
5900
+ outlineType: 2 /* RECT */,
5901
+ data: null,
5902
+ w,
5903
+ h,
5904
+ centerOffsetX: -(w - 1 >> 1),
5905
+ centerOffsetY: -(h - 1 >> 1)
5906
+ };
5907
+ }
5908
+
5890
5909
  // src/PixelData/ReusablePixelData.ts
5891
5910
  function makeReusablePixelData() {
5892
5911
  const pixelData = {
@@ -5916,31 +5935,34 @@ function makePaintCursorRenderer(reusableCanvasFactory) {
5916
5935
  const getPixelData = makeReusablePixelData();
5917
5936
  let _color = packColor(0, 255, 255, 255);
5918
5937
  let _scale = 1;
5919
- let currentMask = {
5920
- type: 1 /* BINARY */,
5938
+ let currentBrush = {
5939
+ type: null,
5921
5940
  outlineType: 2 /* RECT */,
5922
5941
  w: 1,
5923
5942
  h: 1,
5924
5943
  centerOffsetX: -(10 - 1 >> 1),
5925
- centerOffsetY: -(10 - 1 >> 1)
5944
+ centerOffsetY: -(10 - 1 >> 1),
5945
+ data: null
5926
5946
  };
5927
5947
  let outline;
5928
5948
  function update(paintMask, scale, color, alphaThreshold = 127) {
5929
- currentMask = paintMask ?? currentMask;
5949
+ currentBrush = paintMask ?? currentBrush;
5930
5950
  _scale = scale ?? _scale;
5931
5951
  _color = color ?? _color;
5932
- updateBuffer(currentMask.w * _scale + 2 * _scale, currentMask.h * _scale + 2 * _scale);
5933
- if (currentMask.type === 1 /* BINARY */) {
5934
- if (currentMask.outlineType === 1 /* CIRCLE */) {
5935
- outline = makeCircleBinaryMaskOutline(currentMask.w, _scale);
5936
- } else if (currentMask.outlineType === 2 /* RECT */) {
5937
- outline = makeRectBinaryMaskOutline(currentMask.w, currentMask.h, _scale);
5938
- } else if (currentMask.outlineType === 0 /* MASKED */) {
5939
- outline = makeBinaryMaskOutline(currentMask, _scale);
5952
+ updateBuffer(currentBrush.w * _scale + 2 * _scale, currentBrush.h * _scale + 2 * _scale);
5953
+ if (currentBrush.type === 1 /* BINARY */) {
5954
+ if (currentBrush.outlineType === 1 /* CIRCLE */) {
5955
+ outline = makeCircleBinaryMaskOutline(currentBrush.w, _scale);
5956
+ } else if (currentBrush.outlineType === 2 /* RECT */) {
5957
+ outline = makeRectBinaryMaskOutline(currentBrush.w, currentBrush.h, _scale);
5958
+ } else if (currentBrush.outlineType === 0 /* MASKED */) {
5959
+ outline = makeBinaryMaskOutline(currentBrush, _scale);
5940
5960
  }
5941
- } else if (currentMask.type === 0 /* ALPHA */) {
5942
- const mask = makeBinaryMaskFromAlphaMask(currentMask, alphaThreshold);
5961
+ } else if (currentBrush.type === 0 /* ALPHA */) {
5962
+ const mask = makeBinaryMaskFromAlphaMask(currentBrush, alphaThreshold);
5943
5963
  outline = makeBinaryMaskOutline(mask, _scale);
5964
+ } else {
5965
+ outline = makeRectBinaryMaskOutline(currentBrush.w, currentBrush.h, _scale);
5944
5966
  }
5945
5967
  const pixelData = getPixelData(outline.w, outline.h);
5946
5968
  fillPixelDataBinaryMask(pixelData, _color, outline);
@@ -5953,10 +5975,10 @@ function makePaintCursorRenderer(reusableCanvasFactory) {
5953
5975
  h: 0
5954
5976
  };
5955
5977
  function getBounds(centerX, centerY) {
5956
- boundsScratch.x = centerX + currentMask.centerOffsetX;
5957
- boundsScratch.y = centerY + currentMask.centerOffsetY;
5958
- boundsScratch.w = currentMask.w;
5959
- boundsScratch.h = currentMask.h;
5978
+ boundsScratch.x = centerX + currentBrush.centerOffsetX;
5979
+ boundsScratch.y = centerY + currentBrush.centerOffsetY;
5980
+ boundsScratch.w = currentBrush.w;
5981
+ boundsScratch.h = currentBrush.h;
5960
5982
  return boundsScratch;
5961
5983
  }
5962
5984
  const boundsScaledScratch = {
@@ -5966,22 +5988,22 @@ function makePaintCursorRenderer(reusableCanvasFactory) {
5966
5988
  h: 0
5967
5989
  };
5968
5990
  function getOutlineBoundsScaled(centerX, centerY) {
5969
- boundsScaledScratch.x = centerX * _scale + currentMask.centerOffsetX * _scale - 1;
5970
- boundsScaledScratch.y = centerY * _scale + currentMask.centerOffsetY * _scale - 1;
5971
- boundsScaledScratch.w = currentMask.w * _scale;
5972
- boundsScaledScratch.h = currentMask.h * _scale;
5991
+ boundsScaledScratch.x = centerX * _scale + currentBrush.centerOffsetX * _scale - 1;
5992
+ boundsScaledScratch.y = centerY * _scale + currentBrush.centerOffsetY * _scale - 1;
5993
+ boundsScaledScratch.w = currentBrush.w * _scale;
5994
+ boundsScaledScratch.h = currentBrush.h * _scale;
5973
5995
  return boundsScaledScratch;
5974
5996
  }
5975
5997
  function draw(drawCtx, centerX, centerY) {
5976
- const dx = centerX * _scale + currentMask.centerOffsetX * _scale - 1;
5977
- const dy = centerY * _scale + currentMask.centerOffsetY * _scale - 1;
5998
+ const dx = centerX * _scale + currentBrush.centerOffsetX * _scale - 1;
5999
+ const dy = centerY * _scale + currentBrush.centerOffsetY * _scale - 1;
5978
6000
  drawCtx.drawImage(canvas, Math.floor(dx), Math.floor(dy));
5979
6001
  }
5980
6002
  function getSettings() {
5981
6003
  return {
5982
6004
  color: _color,
5983
6005
  scale: _scale,
5984
- currentMask
6006
+ currentBrush
5985
6007
  };
5986
6008
  }
5987
6009
  return {
@@ -6635,6 +6657,7 @@ export {
6635
6657
  makePaintAlphaMask,
6636
6658
  makePaintBinaryMask,
6637
6659
  makePaintCursorRenderer,
6660
+ makePaintRect,
6638
6661
  makePerfectBlendModeRegistry,
6639
6662
  makePixelCanvas,
6640
6663
  makePixelData,