pixel-data-js 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.prod.cjs +78 -36
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +27 -10
- package/dist/index.prod.js +76 -36
- package/dist/index.prod.js.map +1 -1
- package/package.json +1 -1
- package/src/ImageData/copyImageData.ts +4 -2
- package/src/ImageData/extractImageData.ts +1 -2
- package/src/ImageData/extractImageDataBuffer.ts +2 -4
- package/src/ImageData/writeImageData.ts +4 -5
- package/src/ImageData/writeImageDataBuffer.ts +2 -4
- package/src/Paint/AlphaMaskPaintBuffer.ts +8 -10
- package/src/Paint/BinaryMaskPaintBuffer.ts +8 -10
- package/src/Paint/ColorPaintBuffer.ts +8 -10
- package/src/Paint/PaintRect.ts +11 -0
- package/src/Paint/_paint-types.ts +6 -0
- package/src/PixelData/extractPixelDataBuffer.ts +2 -4
- package/src/PixelData/fillPixelData.ts +1 -2
- package/src/PixelData/fillPixelDataFast.ts +1 -2
- package/src/PixelData/writePixelData.ts +55 -0
- package/src/index.ts +2 -0
package/dist/index.prod.d.ts
CHANGED
|
@@ -1051,6 +1051,12 @@ 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
|
+
interface PaintRect {
|
|
1055
|
+
w: number;
|
|
1056
|
+
h: number;
|
|
1057
|
+
centerOffsetX: number;
|
|
1058
|
+
centerOffsetY: number;
|
|
1059
|
+
}
|
|
1054
1060
|
|
|
1055
1061
|
/**
|
|
1056
1062
|
* Blends a solid color into a target pixel buffer using an alpha mask.
|
|
@@ -1268,7 +1274,7 @@ declare const mutatorInvert: (writer: PixelWriter<any>, deps?: Deps) => {
|
|
|
1268
1274
|
invert(opts?: PixelMutateOptions): boolean;
|
|
1269
1275
|
};
|
|
1270
1276
|
|
|
1271
|
-
declare function copyImageData(
|
|
1277
|
+
declare function copyImageData(source: ImageDataLike): ImageData;
|
|
1272
1278
|
declare function copyImageDataLike({ data, width, height }: ImageDataLike): ImageDataLike;
|
|
1273
1279
|
|
|
1274
1280
|
/**
|
|
@@ -1426,14 +1432,14 @@ declare function uInt32ArrayToImageData(data: Uint32Array, width: number, height
|
|
|
1426
1432
|
declare function uInt32ArrayToImageDataLike(data: Uint32Array, width: number, height: number): ImageDataLike;
|
|
1427
1433
|
|
|
1428
1434
|
/**
|
|
1429
|
-
* Writes image data from a source to a target
|
|
1435
|
+
* Writes image data from a source to a target.
|
|
1430
1436
|
*
|
|
1431
1437
|
* @param target - The destination ImageData to write to.
|
|
1432
1438
|
* @param source - The source ImageData to read from.
|
|
1433
1439
|
* @param x - The x-coordinate in the target where drawing starts.
|
|
1434
1440
|
* @param y - The y-coordinate in the target where drawing starts.
|
|
1435
1441
|
*/
|
|
1436
|
-
declare function writeImageData(target: ImageData, source: ImageData, x
|
|
1442
|
+
declare function writeImageData(target: ImageData, source: ImageData, x?: number, y?: number): void;
|
|
1437
1443
|
|
|
1438
1444
|
/**
|
|
1439
1445
|
* Copies a pixel buffer into a specific region of an {@link ImageData} object.
|
|
@@ -1707,8 +1713,8 @@ declare class AlphaMaskPaintBuffer {
|
|
|
1707
1713
|
paintAlphaMask(brush: PaintAlphaMask, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1708
1714
|
paintBinaryMask(brush: PaintBinaryMask, alpha: number, x: number, y: number): boolean;
|
|
1709
1715
|
paintBinaryMask(brush: PaintBinaryMask, alpha: number, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1710
|
-
paintRect(alpha: number,
|
|
1711
|
-
paintRect(alpha: number,
|
|
1716
|
+
paintRect(alpha: number, brush: PaintRect, x: number, y: number): boolean;
|
|
1717
|
+
paintRect(alpha: number, brush: PaintRect, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1712
1718
|
clear(): void;
|
|
1713
1719
|
}
|
|
1714
1720
|
|
|
@@ -1723,8 +1729,8 @@ declare class BinaryMaskPaintBuffer {
|
|
|
1723
1729
|
constructor(config: PixelEngineConfig, tilePool: TilePool<BinaryMaskTile>);
|
|
1724
1730
|
paintBinaryMask(brush: PaintBinaryMask, x: number, y: number): boolean;
|
|
1725
1731
|
paintBinaryMask(brush: PaintBinaryMask, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1726
|
-
paintRect(
|
|
1727
|
-
paintRect(
|
|
1732
|
+
paintRect(brush: PaintRect, x: number, y: number): boolean;
|
|
1733
|
+
paintRect(brush: PaintRect, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1728
1734
|
clear(): void;
|
|
1729
1735
|
}
|
|
1730
1736
|
|
|
@@ -1738,8 +1744,8 @@ declare class ColorPaintBuffer {
|
|
|
1738
1744
|
paintAlphaMask(color: Color32, brush: PaintAlphaMask, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1739
1745
|
paintBinaryMask(color: Color32, brush: PaintBinaryMask, x: number, y: number): boolean;
|
|
1740
1746
|
paintBinaryMask(color: Color32, brush: PaintBinaryMask, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1741
|
-
paintRect(color: Color32,
|
|
1742
|
-
paintRect(color: Color32,
|
|
1747
|
+
paintRect(color: Color32, brush: PaintRect, x: number, y: number): boolean;
|
|
1748
|
+
paintRect(color: Color32, brush: PaintRect, startX: number, startY: number, endX: number, endY: number): boolean;
|
|
1743
1749
|
clear(): void;
|
|
1744
1750
|
}
|
|
1745
1751
|
|
|
@@ -1794,6 +1800,8 @@ declare function makePaintAlphaMask(mask: AlphaMask): PaintAlphaMask;
|
|
|
1794
1800
|
|
|
1795
1801
|
declare function makeRectFalloffPaintAlphaMask(width: number, height: number, fallOff?: (d: number) => number): PaintAlphaMask;
|
|
1796
1802
|
|
|
1803
|
+
declare function makePaintRect(w: number, h: number): PaintRect;
|
|
1804
|
+
|
|
1797
1805
|
type PaintCursorRenderer = ReturnType<typeof makePaintCursorRenderer>;
|
|
1798
1806
|
declare function makePaintCursorRenderer<T extends HTMLCanvasElement | OffscreenCanvas = OffscreenCanvas>(reusableCanvasFactory?: () => ReusableCanvasFactory<T>): {
|
|
1799
1807
|
update: (paintMask?: PaintMask, scale?: number, color?: Color32, alphaThreshold?: number) => void;
|
|
@@ -1939,6 +1947,15 @@ declare function writePixelDataBuffer(target: PixelData32, data: Uint32Array, x:
|
|
|
1939
1947
|
*/
|
|
1940
1948
|
declare function writePaintBufferToPixelData(target: PixelData, paintBuffer: ColorPaintBuffer, writePixelDataBufferFn?: typeof writePixelDataBuffer): void;
|
|
1941
1949
|
|
|
1950
|
+
/**
|
|
1951
|
+
* Writes PixelData from a source to a target.
|
|
1952
|
+
* @param target - The destination to write to.
|
|
1953
|
+
* @param source - The source to read from.
|
|
1954
|
+
* @param x - The x-coordinate in the target where drawing starts.
|
|
1955
|
+
* @param y - The y-coordinate in the target where drawing starts.
|
|
1956
|
+
*/
|
|
1957
|
+
declare function writePixelData(target: PixelData32, source: PixelData32, x?: number, y?: number): void;
|
|
1958
|
+
|
|
1942
1959
|
declare function getRectsBounds<T extends Rect>(rects: T[]): T;
|
|
1943
1960
|
|
|
1944
1961
|
/**
|
|
@@ -1964,4 +1981,4 @@ declare const makeBinaryMaskTile: TileFactory<BinaryMaskTile>;
|
|
|
1964
1981
|
|
|
1965
1982
|
declare function makePixelTile(id: number, tx: number, ty: number, tileSize: number, tileArea: number): PixelTile;
|
|
1966
1983
|
|
|
1967
|
-
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, writePixelDataBuffer, xorFast, xorPerfect };
|
|
1984
|
+
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, 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 };
|
package/dist/index.prod.js
CHANGED
|
@@ -99,8 +99,7 @@ function extractImageDataBuffer(imageData, _x, _y, _w, _h) {
|
|
|
99
99
|
w: _w,
|
|
100
100
|
h: _h
|
|
101
101
|
};
|
|
102
|
-
if (w <= 0) return new Uint8ClampedArray(0);
|
|
103
|
-
if (h <= 0) return new Uint8ClampedArray(0);
|
|
102
|
+
if (w <= 0 || h <= 0) return new Uint8ClampedArray(0);
|
|
104
103
|
const srcW = imageData.width;
|
|
105
104
|
const srcH = imageData.height;
|
|
106
105
|
const src = imageData.data;
|
|
@@ -124,8 +123,7 @@ function extractImageDataBuffer(imageData, _x, _y, _w, _h) {
|
|
|
124
123
|
}
|
|
125
124
|
copyW = Math.min(copyW, srcW - srcX);
|
|
126
125
|
copyH = Math.min(copyH, srcH - srcY);
|
|
127
|
-
if (copyW <= 0) return out;
|
|
128
|
-
if (copyH <= 0) return out;
|
|
126
|
+
if (copyW <= 0 || copyH <= 0) return out;
|
|
129
127
|
const isAligned = src.byteOffset % 4 === 0;
|
|
130
128
|
if (isAligned) {
|
|
131
129
|
const srcLen32 = src.byteLength / 4;
|
|
@@ -3622,8 +3620,7 @@ function fillPixelData(dst, color, _x, _y, _w, _h) {
|
|
|
3622
3620
|
}
|
|
3623
3621
|
fillW = Math.min(fillW, dstW - dstX);
|
|
3624
3622
|
fillH = Math.min(fillH, dstH - dstY);
|
|
3625
|
-
if (fillW <= 0) return false;
|
|
3626
|
-
if (fillH <= 0) return false;
|
|
3623
|
+
if (fillW <= 0 || fillH <= 0) return false;
|
|
3627
3624
|
const dst32 = dst.data;
|
|
3628
3625
|
let hasChanged = false;
|
|
3629
3626
|
if (dstX === 0 && fillW === dstW) {
|
|
@@ -3874,12 +3871,9 @@ function makeFullPixelMutator(writer) {
|
|
|
3874
3871
|
}
|
|
3875
3872
|
|
|
3876
3873
|
// src/ImageData/copyImageData.ts
|
|
3877
|
-
function copyImageData({
|
|
3878
|
-
data
|
|
3879
|
-
width,
|
|
3880
|
-
height
|
|
3881
|
-
}) {
|
|
3882
|
-
return new ImageData(data.slice(), width, height);
|
|
3874
|
+
function copyImageData(source) {
|
|
3875
|
+
const dataCopy = new Uint8ClampedArray(source.data);
|
|
3876
|
+
return new ImageData(dataCopy, source.width, source.height);
|
|
3883
3877
|
}
|
|
3884
3878
|
function copyImageDataLike({
|
|
3885
3879
|
data,
|
|
@@ -3906,8 +3900,7 @@ function extractImageData(imageData, _x, _y, _w, _h) {
|
|
|
3906
3900
|
w: _w,
|
|
3907
3901
|
h: _h
|
|
3908
3902
|
};
|
|
3909
|
-
if (w <= 0) return null;
|
|
3910
|
-
if (h <= 0) return null;
|
|
3903
|
+
if (w <= 0 || h <= 0) return null;
|
|
3911
3904
|
const result = new ImageData(w, h);
|
|
3912
3905
|
const buffer = extractImageDataBuffer(imageData, x, y, w, h);
|
|
3913
3906
|
result.data.set(buffer);
|
|
@@ -4064,7 +4057,7 @@ function uInt32ArrayToImageDataLike(data, width, height) {
|
|
|
4064
4057
|
}
|
|
4065
4058
|
|
|
4066
4059
|
// src/ImageData/writeImageData.ts
|
|
4067
|
-
function writeImageData(target, source, x, y) {
|
|
4060
|
+
function writeImageData(target, source, x = 0, y = 0) {
|
|
4068
4061
|
const dstW = target.width;
|
|
4069
4062
|
const dstH = target.height;
|
|
4070
4063
|
const dst = target.data;
|
|
@@ -4089,8 +4082,7 @@ function writeImageData(target, source, x, y) {
|
|
|
4089
4082
|
}
|
|
4090
4083
|
copyW = Math.min(copyW, dstW - dstX);
|
|
4091
4084
|
copyH = Math.min(copyH, dstH - dstY);
|
|
4092
|
-
if (copyW <= 0) return;
|
|
4093
|
-
if (copyH <= 0) return;
|
|
4085
|
+
if (copyW <= 0 || copyH <= 0) return;
|
|
4094
4086
|
const isDstAligned = dst.byteOffset % 4 === 0;
|
|
4095
4087
|
const isSrcAligned = src.byteOffset % 4 === 0;
|
|
4096
4088
|
if (isDstAligned && isSrcAligned) {
|
|
@@ -4132,8 +4124,7 @@ function writeImageDataBuffer(target, data, _x, _y, _w, _h) {
|
|
|
4132
4124
|
w = _w;
|
|
4133
4125
|
h = _h;
|
|
4134
4126
|
}
|
|
4135
|
-
if (w <= 0) return;
|
|
4136
|
-
if (h <= 0) return;
|
|
4127
|
+
if (w <= 0 || h <= 0) return;
|
|
4137
4128
|
const dstW = target.width;
|
|
4138
4129
|
const dstH = target.height;
|
|
4139
4130
|
const dst = target.data;
|
|
@@ -4155,8 +4146,7 @@ function writeImageDataBuffer(target, data, _x, _y, _w, _h) {
|
|
|
4155
4146
|
}
|
|
4156
4147
|
copyW = Math.min(copyW, dstW - dstX);
|
|
4157
4148
|
copyH = Math.min(copyH, dstH - dstY);
|
|
4158
|
-
if (copyW <= 0) return;
|
|
4159
|
-
if (copyH <= 0) return;
|
|
4149
|
+
if (copyW <= 0 || copyH <= 0) return;
|
|
4160
4150
|
const isDstAligned = dst.byteOffset % 4 === 0;
|
|
4161
4151
|
const isSrcAligned = data.byteOffset % 4 === 0;
|
|
4162
4152
|
if (isDstAligned && isSrcAligned) {
|
|
@@ -5194,7 +5184,7 @@ var AlphaMaskPaintBuffer = class {
|
|
|
5194
5184
|
});
|
|
5195
5185
|
return changed;
|
|
5196
5186
|
}
|
|
5197
|
-
paintRect(alpha,
|
|
5187
|
+
paintRect(alpha, brush, x0, y0, x1 = x0, y1 = y0) {
|
|
5198
5188
|
const scratch = this.scratchBounds;
|
|
5199
5189
|
const lookup = this.lookup;
|
|
5200
5190
|
const tilePool = this.tilePool;
|
|
@@ -5202,8 +5192,10 @@ var AlphaMaskPaintBuffer = class {
|
|
|
5202
5192
|
const tileShift = config.tileShift;
|
|
5203
5193
|
const tileMask = config.tileMask;
|
|
5204
5194
|
const target = config.target;
|
|
5205
|
-
const
|
|
5206
|
-
const
|
|
5195
|
+
const brushWidth = brush.w;
|
|
5196
|
+
const brushHeight = brush.h;
|
|
5197
|
+
const centerOffsetX = brush.centerOffsetX;
|
|
5198
|
+
const centerOffsetY = brush.centerOffsetY;
|
|
5207
5199
|
const trimRectBoundsFn = this.trimRectBoundsFn;
|
|
5208
5200
|
const eachTileInBoundsFn = this.eachTileInBoundsFn;
|
|
5209
5201
|
let changed = false;
|
|
@@ -5303,7 +5295,7 @@ var BinaryMaskPaintBuffer = class {
|
|
|
5303
5295
|
});
|
|
5304
5296
|
return changed;
|
|
5305
5297
|
}
|
|
5306
|
-
paintRect(
|
|
5298
|
+
paintRect(brush, x0, y0, x1 = x0, y1 = y0) {
|
|
5307
5299
|
const scratch = this.scratchBounds;
|
|
5308
5300
|
const lookup = this.lookup;
|
|
5309
5301
|
const tilePool = this.tilePool;
|
|
@@ -5311,8 +5303,10 @@ var BinaryMaskPaintBuffer = class {
|
|
|
5311
5303
|
const tileShift = config.tileShift;
|
|
5312
5304
|
const tileMask = config.tileMask;
|
|
5313
5305
|
const target = config.target;
|
|
5314
|
-
const
|
|
5315
|
-
const
|
|
5306
|
+
const brushWidth = brush.w;
|
|
5307
|
+
const brushHeight = brush.h;
|
|
5308
|
+
const centerOffsetX = brush.centerOffsetX;
|
|
5309
|
+
const centerOffsetY = brush.centerOffsetY;
|
|
5316
5310
|
const trimRectBoundsFn = this.trimRectBoundsFn;
|
|
5317
5311
|
const eachTileInBoundsFn = this.eachTileInBoundsFn;
|
|
5318
5312
|
let changed = false;
|
|
@@ -5463,7 +5457,7 @@ var ColorPaintBuffer = class {
|
|
|
5463
5457
|
});
|
|
5464
5458
|
return changed;
|
|
5465
5459
|
}
|
|
5466
|
-
paintRect(color,
|
|
5460
|
+
paintRect(color, brush, x0, y0, x1 = x0, y1 = y0) {
|
|
5467
5461
|
const alphaIsZero = color >>> 24 === 0;
|
|
5468
5462
|
if (alphaIsZero) return false;
|
|
5469
5463
|
const scratch = this.scratchBounds;
|
|
@@ -5473,8 +5467,10 @@ var ColorPaintBuffer = class {
|
|
|
5473
5467
|
const tileShift = config.tileShift;
|
|
5474
5468
|
const tileMask = config.tileMask;
|
|
5475
5469
|
const target = config.target;
|
|
5476
|
-
const
|
|
5477
|
-
const
|
|
5470
|
+
const brushWidth = brush.w;
|
|
5471
|
+
const brushHeight = brush.h;
|
|
5472
|
+
const centerOffsetX = brush.centerOffsetX;
|
|
5473
|
+
const centerOffsetY = brush.centerOffsetY;
|
|
5478
5474
|
let changed = false;
|
|
5479
5475
|
forEachLinePoint(x0, y0, x1, y1, (px, py) => {
|
|
5480
5476
|
const topLeftX = Math.floor(px + centerOffsetX);
|
|
@@ -5897,6 +5893,16 @@ function makeRectFalloffPaintAlphaMask(width, height, fallOff = (d) => d) {
|
|
|
5897
5893
|
};
|
|
5898
5894
|
}
|
|
5899
5895
|
|
|
5896
|
+
// src/Paint/PaintRect.ts
|
|
5897
|
+
function makePaintRect(w, h) {
|
|
5898
|
+
return {
|
|
5899
|
+
w,
|
|
5900
|
+
h,
|
|
5901
|
+
centerOffsetX: -(w - 1 >> 1),
|
|
5902
|
+
centerOffsetY: -(h - 1 >> 1)
|
|
5903
|
+
};
|
|
5904
|
+
}
|
|
5905
|
+
|
|
5900
5906
|
// src/PixelData/ReusablePixelData.ts
|
|
5901
5907
|
function makeReusablePixelData() {
|
|
5902
5908
|
const pixelData = {
|
|
@@ -6147,8 +6153,7 @@ function fillPixelDataFast(dst, color, _x, _y, _w, _h) {
|
|
|
6147
6153
|
}
|
|
6148
6154
|
fillW = Math.min(fillW, dstW - dstX);
|
|
6149
6155
|
fillH = Math.min(fillH, dstH - dstY);
|
|
6150
|
-
if (fillW <= 0) return;
|
|
6151
|
-
if (fillH <= 0) return;
|
|
6156
|
+
if (fillW <= 0 || fillH <= 0) return;
|
|
6152
6157
|
const dst32 = dst.data;
|
|
6153
6158
|
const dw = dst.w;
|
|
6154
6159
|
if (fillW === dw && fillH === dst.h && dstX === 0 && dstY === 0) {
|
|
@@ -6194,8 +6199,7 @@ function extractPixelDataBuffer(source, _x, _y, _w, _h) {
|
|
|
6194
6199
|
const srcW = source.w;
|
|
6195
6200
|
const srcH = source.h;
|
|
6196
6201
|
const srcData = source.data;
|
|
6197
|
-
if (w <= 0) return new Uint32Array(0);
|
|
6198
|
-
if (h <= 0) return new Uint32Array(0);
|
|
6202
|
+
if (w <= 0 || h <= 0) return new Uint32Array(0);
|
|
6199
6203
|
const dstData = new Uint32Array(w * h);
|
|
6200
6204
|
let srcX = x;
|
|
6201
6205
|
let srcY = y;
|
|
@@ -6215,8 +6219,7 @@ function extractPixelDataBuffer(source, _x, _y, _w, _h) {
|
|
|
6215
6219
|
}
|
|
6216
6220
|
copyW = Math.min(copyW, srcW - srcX);
|
|
6217
6221
|
copyH = Math.min(copyH, srcH - srcY);
|
|
6218
|
-
if (copyW <= 0) return dstData;
|
|
6219
|
-
if (copyH <= 0) return dstData;
|
|
6222
|
+
if (copyW <= 0 || copyH <= 0) return dstData;
|
|
6220
6223
|
for (let row = 0; row < copyH; row++) {
|
|
6221
6224
|
const srcStart = (srcY + row) * srcW + srcX;
|
|
6222
6225
|
const dstStart = (dstY + row) * w + dstX;
|
|
@@ -6462,6 +6465,41 @@ function writePaintBufferToPixelData(target, paintBuffer, writePixelDataBufferFn
|
|
|
6462
6465
|
}
|
|
6463
6466
|
}
|
|
6464
6467
|
}
|
|
6468
|
+
|
|
6469
|
+
// src/PixelData/writePixelData.ts
|
|
6470
|
+
function writePixelData(target, source, x = 0, y = 0) {
|
|
6471
|
+
const dstW = target.w;
|
|
6472
|
+
const dstH = target.h;
|
|
6473
|
+
const dst = target.data;
|
|
6474
|
+
const srcW = source.w;
|
|
6475
|
+
const srcH = source.h;
|
|
6476
|
+
const src = source.data;
|
|
6477
|
+
let dstX = x;
|
|
6478
|
+
let dstY = y;
|
|
6479
|
+
let srcX = 0;
|
|
6480
|
+
let srcY = 0;
|
|
6481
|
+
let copyW = srcW;
|
|
6482
|
+
let copyH = srcH;
|
|
6483
|
+
if (dstX < 0) {
|
|
6484
|
+
srcX = -dstX;
|
|
6485
|
+
copyW += dstX;
|
|
6486
|
+
dstX = 0;
|
|
6487
|
+
}
|
|
6488
|
+
if (dstY < 0) {
|
|
6489
|
+
srcY = -dstY;
|
|
6490
|
+
copyH += dstY;
|
|
6491
|
+
dstY = 0;
|
|
6492
|
+
}
|
|
6493
|
+
copyW = Math.min(copyW, dstW - dstX);
|
|
6494
|
+
copyH = Math.min(copyH, dstH - dstY);
|
|
6495
|
+
if (copyW <= 0 || copyH <= 0) return;
|
|
6496
|
+
for (let row = 0; row < copyH; row++) {
|
|
6497
|
+
const dstStart = (dstY + row) * dstW + dstX;
|
|
6498
|
+
const srcStart = (srcY + row) * srcW + srcX;
|
|
6499
|
+
const chunk = src.subarray(srcStart, srcStart + copyW);
|
|
6500
|
+
dst.set(chunk, dstStart);
|
|
6501
|
+
}
|
|
6502
|
+
}
|
|
6465
6503
|
export {
|
|
6466
6504
|
AlphaMaskPaintBuffer,
|
|
6467
6505
|
BASE_FAST_BLEND_MODE_FUNCTIONS,
|
|
@@ -6613,6 +6651,7 @@ export {
|
|
|
6613
6651
|
makePaintAlphaMask,
|
|
6614
6652
|
makePaintBinaryMask,
|
|
6615
6653
|
makePaintCursorRenderer,
|
|
6654
|
+
makePaintRect,
|
|
6616
6655
|
makePerfectBlendModeRegistry,
|
|
6617
6656
|
makePixelCanvas,
|
|
6618
6657
|
makePixelData,
|
|
@@ -6706,6 +6745,7 @@ export {
|
|
|
6706
6745
|
writeImageDataToClipboard,
|
|
6707
6746
|
writeImgBlobToClipboard,
|
|
6708
6747
|
writePaintBufferToPixelData,
|
|
6748
|
+
writePixelData,
|
|
6709
6749
|
writePixelDataBuffer,
|
|
6710
6750
|
xorFast,
|
|
6711
6751
|
xorPerfect
|