pixel-data-js 0.27.0 → 0.28.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/README.md +12 -2
- package/dist/index.prod.cjs +2222 -1045
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +542 -417
- package/dist/index.prod.js +2167 -1024
- package/dist/index.prod.js.map +1 -1
- package/package.json +11 -11
- package/src/Algorithm/floodFillSelection.ts +8 -6
- package/src/Algorithm/forEachLinePoint.ts +6 -6
- package/src/{Internal/resample32.ts → Algorithm/resampleUint32Array.ts} +11 -21
- package/src/BlendModes/blend-modes-fast.ts +169 -0
- package/src/BlendModes/blend-modes-perfect.ts +207 -0
- package/src/BlendModes/blend-modes.ts +9 -0
- package/src/Canvas/CanvasFrameRenderer.ts +20 -28
- package/src/Canvas/CanvasPixelDataRenderer.ts +23 -0
- package/src/Canvas/PixelCanvas.ts +2 -7
- package/src/Canvas/ReusableCanvas.ts +4 -12
- package/src/Canvas/_canvas-types.ts +26 -0
- package/src/History/PixelAccumulator.ts +17 -17
- package/src/History/PixelEngineConfig.ts +3 -3
- package/src/History/PixelMutator/mutatorApplyAlphaMask.ts +4 -3
- package/src/History/PixelMutator/mutatorApplyBinaryMask.ts +4 -3
- package/src/History/PixelMutator/mutatorApplyMask.ts +4 -3
- package/src/History/PixelMutator/mutatorBlendAlphaMask.ts +6 -4
- package/src/History/PixelMutator/mutatorBlendBinaryMask.ts +6 -4
- package/src/History/PixelMutator/mutatorBlendColor.ts +2 -2
- package/src/History/PixelMutator/mutatorBlendColorPaintAlphaMask.ts +2 -1
- package/src/History/PixelMutator/mutatorBlendColorPaintBinaryMask.ts +2 -1
- package/src/History/PixelMutator/mutatorBlendColorPaintMask.ts +3 -1
- package/src/History/PixelMutator/mutatorBlendColorPaintRect.ts +3 -3
- package/src/History/PixelMutator/mutatorBlendMask.ts +6 -4
- package/src/History/PixelMutator/mutatorBlendPixelData.ts +5 -4
- package/src/History/PixelMutator/mutatorClear.ts +4 -3
- package/src/History/PixelMutator/mutatorFill.ts +5 -4
- package/src/History/PixelMutator/mutatorFillBinaryMask.ts +2 -1
- package/src/History/PixelMutator/mutatorInvert.ts +2 -2
- package/src/History/PixelMutator.ts +1 -1
- package/src/History/PixelPatchTiles.ts +7 -7
- package/src/History/PixelWriter.ts +12 -63
- package/src/ImageData/ImageDataLike.ts +1 -1
- package/src/ImageData/_ImageData-types.ts +13 -0
- package/src/ImageData/copyImageData.ts +1 -1
- package/src/ImageData/extractImageDataBuffer.ts +3 -2
- package/src/ImageData/imageDataToUint32Array.ts +18 -0
- package/src/ImageData/resampleImageData.ts +3 -3
- package/src/ImageData/resizeImageData.ts +1 -1
- package/src/ImageData/serialization.ts +1 -1
- package/src/ImageData/uInt32ArrayToImageData.ts +1 -1
- package/src/ImageData/writeImageData.ts +2 -2
- package/src/ImageData/writeImageDataBuffer.ts +2 -2
- package/src/IndexedImage/IndexedImage.ts +56 -98
- package/src/IndexedImage/_indexedImage-types.ts +18 -0
- package/src/IndexedImage/getIndexedImageColorCounts.ts +3 -3
- package/src/IndexedImage/indexedImageToAverageColor.ts +1 -1
- package/src/IndexedImage/indexedImageToImageData.ts +4 -6
- package/src/IndexedImage/resampleIndexedImage.ts +7 -15
- package/src/Input/fileToImageData.ts +1 -1
- package/src/Internal/_errors.ts +2 -0
- package/src/Internal/macros.ts +14 -0
- package/src/Mask/AlphaMask.ts +1 -1
- package/src/Mask/BinaryMask/makeBinaryMaskFromAlphaMask.ts +23 -0
- package/src/Mask/BinaryMask/makeBinaryMaskOutline.ts +88 -0
- package/src/Mask/BinaryMask/makeCircleBinaryMaskOutline.ts +104 -0
- package/src/Mask/BinaryMask/makeRectBinaryMaskOutline.ts +34 -0
- package/src/Mask/BinaryMask.ts +1 -1
- package/src/Mask/_mask-types.ts +73 -0
- package/src/Mask/applyBinaryMaskToAlphaMask.ts +2 -1
- package/src/Mask/copyMask.ts +1 -1
- package/src/Mask/extractMask.ts +2 -1
- package/src/Mask/extractMaskBuffer.ts +1 -1
- package/src/Mask/mergeAlphaMasks.ts +6 -3
- package/src/Mask/mergeBinaryMasks.ts +2 -1
- package/src/Mask/setMaskData.ts +1 -1
- package/src/MaskRect/merge2BinaryMaskRects.ts +2 -2
- package/src/MaskRect/mergeBinaryMaskRects.ts +1 -1
- package/src/MaskRect/subtractBinaryMaskRects.ts +1 -1
- package/src/Paint/AlphaMaskPaintBuffer.ts +339 -0
- package/src/Paint/AlphaMaskPaintBufferCanvasRenderer.ts +78 -0
- package/src/Paint/BinaryMaskPaintBuffer.ts +254 -0
- package/src/Paint/BinaryMaskPaintBufferCanvasRenderer.ts +67 -0
- package/src/Paint/{PaintBuffer.ts → ColorPaintBuffer.ts} +148 -77
- package/src/Paint/{PaintBufferCanvasRenderer.ts → ColorPaintBufferCanvasRenderer.ts} +6 -5
- package/src/Paint/PaintCursorRenderer.ts +117 -0
- package/src/Paint/_paint-types.ts +22 -0
- package/src/Paint/eachTileInBounds.ts +45 -0
- package/src/Paint/makeCirclePaintMask.ts +74 -0
- package/src/Paint/makePaintMask.ts +5 -2
- package/src/Paint/makeRectFalloffPaintAlphaMask.ts +4 -2
- package/src/PixelData/PixelData.ts +15 -19
- package/src/PixelData/ReusablePixelData.ts +36 -0
- package/src/PixelData/_pixelData-types.ts +17 -0
- package/src/PixelData/applyAlphaMaskToPixelData.ts +80 -43
- package/src/PixelData/applyBinaryMaskToPixelData.ts +10 -8
- package/src/PixelData/applyMaskToPixelData.ts +4 -9
- package/src/PixelData/blendColorPixelData.ts +9 -8
- package/src/PixelData/blendColorPixelDataAlphaMask.ts +9 -7
- package/src/PixelData/blendColorPixelDataBinaryMask.ts +9 -7
- package/src/PixelData/blendColorPixelDataMask.ts +4 -2
- package/src/PixelData/blendColorPixelDataPaintAlphaMask.ts +4 -2
- package/src/PixelData/blendColorPixelDataPaintBinaryMask.ts +4 -2
- package/src/PixelData/blendColorPixelDataPaintMask.ts +5 -2
- package/src/PixelData/blendPixel.ts +6 -5
- package/src/PixelData/blendPixelData.ts +14 -13
- package/src/PixelData/blendPixelDataAlphaMask.ts +15 -13
- package/src/PixelData/blendPixelDataBinaryMask.ts +15 -13
- package/src/PixelData/blendPixelDataMask.ts +5 -3
- package/src/PixelData/blendPixelDataPaintBuffer.ts +5 -4
- package/src/PixelData/clearPixelDataFast.ts +4 -2
- package/src/PixelData/copyPixelData.ts +14 -0
- package/src/PixelData/extractPixelData.ts +8 -7
- package/src/PixelData/extractPixelDataBuffer.ts +9 -8
- package/src/PixelData/fillPixelData.ts +16 -14
- package/src/PixelData/fillPixelDataBinaryMask.ts +10 -8
- package/src/PixelData/fillPixelDataFast.ts +16 -14
- package/src/PixelData/invertPixelData.ts +9 -8
- package/src/PixelData/pixelDataToAlphaMask.ts +9 -8
- package/src/PixelData/reflectPixelData.ts +9 -9
- package/src/PixelData/resamplePixelData.ts +20 -9
- package/src/PixelData/rotatePixelData.ts +8 -7
- package/src/PixelData/uInt32ArrayToPixelData.ts +15 -0
- package/src/PixelData/writePaintBufferToPixelData.ts +5 -5
- package/src/PixelData/writePixelDataBuffer.ts +10 -9
- package/src/Rect/_rect-types.ts +7 -0
- package/src/Rect/getRectsBounds.ts +1 -1
- package/src/Rect/trimMaskRectBounds.ts +2 -1
- package/src/Rect/trimRectBounds.ts +1 -1
- package/src/Tile/MaskTile.ts +40 -0
- package/src/Tile/PixelTile.ts +23 -0
- package/src/{PixelTile/PixelTilePool.ts → Tile/TilePool.ts} +9 -9
- package/src/Tile/_tile-types.ts +33 -0
- package/src/_errors.ts +1 -0
- package/src/_types.ts +2 -118
- package/src/index.ts +46 -21
- package/src/ImageData/imageDataToUInt32Array.ts +0 -13
- package/src/Internal/helpers.ts +0 -5
- package/src/Paint/makeCirclePaintAlphaMask.ts +0 -41
- package/src/Paint/makeCirclePaintBinaryMask.ts +0 -29
- package/src/PixelTile/PixelTile.ts +0 -21
- /package/src/{Internal → Rect}/resolveClipping.ts +0 -0
package/src/_types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BinaryMask } from './Mask/_mask-types'
|
|
2
|
+
|
|
1
3
|
/** ALL values are 0-255 (including alpha which in CSS is 0-1) */
|
|
2
4
|
export type RGBA = { r: number, g: number, b: number, a: number }
|
|
3
5
|
|
|
@@ -15,84 +17,6 @@ export type BlendColor32 = {
|
|
|
15
17
|
isOverwrite?: true
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
export type ImageDataLike = {
|
|
19
|
-
width: number
|
|
20
|
-
height: number
|
|
21
|
-
data: Uint8ClampedArray<ArrayBufferLike>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ImageDataLikeConstructor<T extends ImageDataLike = ImageDataLike> = {
|
|
25
|
-
new(
|
|
26
|
-
data: Uint8ClampedArray,
|
|
27
|
-
width: number,
|
|
28
|
-
height: number,
|
|
29
|
-
): T
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type SerializedImageData = {
|
|
33
|
-
width: number
|
|
34
|
-
height: number
|
|
35
|
-
data: string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type Base64EncodedUInt8Array = string & { readonly __brandBase64UInt8Array: unique symbol }
|
|
39
|
-
|
|
40
|
-
/** Rectangle definition */
|
|
41
|
-
export type Rect = {
|
|
42
|
-
x: number
|
|
43
|
-
y: number
|
|
44
|
-
w: number
|
|
45
|
-
h: number
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Defines how mask values should be interpreted during a draw operation.
|
|
50
|
-
*/
|
|
51
|
-
export enum MaskType {
|
|
52
|
-
/**
|
|
53
|
-
* Values are treated as alpha weights.
|
|
54
|
-
* 0 is skipped, values > 0 are processed.
|
|
55
|
-
*/
|
|
56
|
-
ALPHA,
|
|
57
|
-
/**
|
|
58
|
-
* Values are treated as on/off.
|
|
59
|
-
* 0 is fully transparent (skipped), any other value is fully opaque.
|
|
60
|
-
*/
|
|
61
|
-
BINARY
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface BaseMask {
|
|
65
|
-
readonly type: MaskType
|
|
66
|
-
readonly data: Uint8Array
|
|
67
|
-
readonly w: number
|
|
68
|
-
readonly h: number
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type Mask = BinaryMask | AlphaMask
|
|
72
|
-
|
|
73
|
-
/** Strictly 0 or 1 */
|
|
74
|
-
export interface BinaryMask extends BaseMask {
|
|
75
|
-
readonly type: MaskType.BINARY
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Strictly 0-255 */
|
|
79
|
-
export interface AlphaMask extends BaseMask {
|
|
80
|
-
readonly type: MaskType.ALPHA
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
interface BasePaintMask {
|
|
84
|
-
readonly centerOffsetX: number
|
|
85
|
-
readonly centerOffsetY: number
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface PaintAlphaMask extends BasePaintMask, AlphaMask {
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface PaintBinaryMask extends BasePaintMask, BinaryMask {
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type PaintMask = PaintAlphaMask | PaintBinaryMask
|
|
95
|
-
|
|
96
20
|
/**
|
|
97
21
|
* Configuration for pixel manipulation operations.
|
|
98
22
|
* Designed to be used by spreading a Rect object ({x, y, w, h}) directly.
|
|
@@ -138,7 +62,6 @@ export interface MaskOffset {
|
|
|
138
62
|
}
|
|
139
63
|
|
|
140
64
|
export interface InvertMask {
|
|
141
|
-
|
|
142
65
|
/**
|
|
143
66
|
* If true the inverse of the mask will be applied
|
|
144
67
|
* @default false
|
|
@@ -158,7 +81,6 @@ export interface ApplyMaskToPixelDataOptions extends PixelRect, Alpha, MaskOffse
|
|
|
158
81
|
}
|
|
159
82
|
|
|
160
83
|
export interface MergeAlphaMasksOptions extends PixelRect, Alpha, MaskOffset, InvertMask {
|
|
161
|
-
|
|
162
84
|
}
|
|
163
85
|
|
|
164
86
|
export interface PixelMutateOptions extends PixelRect, MaskOffset, InvertMask {
|
|
@@ -209,41 +131,3 @@ export interface ColorBlendOptions extends PixelRect, Alpha {
|
|
|
209
131
|
|
|
210
132
|
export interface ColorBlendMaskOptions extends ColorBlendOptions, MaskOffset, InvertMask {
|
|
211
133
|
}
|
|
212
|
-
|
|
213
|
-
export interface ColorBlendPaintMaskOptions extends Omit<ColorBlendOptions, 'w' | 'h'> {
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export type MaskRect<T extends MaskType> = Rect & {
|
|
217
|
-
type: T
|
|
218
|
-
data: Uint8Array
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export type BinaryMaskRect = MaskRect<MaskType.BINARY>
|
|
222
|
-
|
|
223
|
-
export type AlphaMaskRect = MaskRect<MaskType.ALPHA>
|
|
224
|
-
|
|
225
|
-
export type NullableBinaryMaskRect = Rect & ({
|
|
226
|
-
type: MaskType.BINARY
|
|
227
|
-
data: Uint8Array
|
|
228
|
-
} | {
|
|
229
|
-
type?: null
|
|
230
|
-
data?: null
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
export type NullableMaskRect = Rect & ({
|
|
234
|
-
type: MaskType
|
|
235
|
-
data: Uint8Array
|
|
236
|
-
} | {
|
|
237
|
-
type?: null
|
|
238
|
-
data?: null
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
export interface IPixelData32 {
|
|
242
|
-
readonly data32: Uint32Array
|
|
243
|
-
readonly width: number
|
|
244
|
-
readonly height: number
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export interface IPixelData<T extends ImageDataLike = ImageData> extends IPixelData32 {
|
|
248
|
-
readonly imageData: T
|
|
249
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
//
|
|
1
|
+
// generated by `npm run re-index`
|
|
2
|
+
|
|
3
|
+
export * from './_errors'
|
|
4
|
+
export * from './_types'
|
|
2
5
|
|
|
3
6
|
export * from './Algorithm/floodFillSelection'
|
|
4
7
|
export * from './Algorithm/forEachLinePoint'
|
|
8
|
+
export * from './Algorithm/resampleUint32Array'
|
|
5
9
|
|
|
6
|
-
export * from './BlendModes/BlendModeRegistry'
|
|
7
10
|
export * from './BlendModes/blend-modes-fast'
|
|
8
11
|
export * from './BlendModes/blend-modes-perfect'
|
|
9
12
|
export * from './BlendModes/blend-modes'
|
|
13
|
+
export * from './BlendModes/BlendModeRegistry'
|
|
10
14
|
export * from './BlendModes/toBlendModeIndexAndName'
|
|
11
15
|
|
|
16
|
+
export * from './Canvas/_canvas-types'
|
|
17
|
+
export * from './Canvas/canvas-blend-modes'
|
|
12
18
|
export * from './Canvas/CanvasFrameRenderer'
|
|
19
|
+
export * from './Canvas/CanvasPixelDataRenderer'
|
|
13
20
|
export * from './Canvas/PixelCanvas'
|
|
14
21
|
export * from './Canvas/ReusableCanvas'
|
|
15
|
-
export * from './Canvas/canvas-blend-modes'
|
|
16
22
|
|
|
17
23
|
export * from './Clipboard/getImageDataFromClipboard'
|
|
18
24
|
export * from './Clipboard/writeImageDataToClipboard'
|
|
19
25
|
export * from './Clipboard/writeImgBlobToClipboard'
|
|
20
26
|
|
|
27
|
+
export * from './color'
|
|
28
|
+
|
|
21
29
|
export * from './History/HistoryAction'
|
|
22
30
|
export * from './History/HistoryManager'
|
|
23
31
|
export * from './History/PixelAccumulator'
|
|
@@ -45,25 +53,27 @@ export * from './History/PixelMutator/mutatorInvert'
|
|
|
45
53
|
export * from './History/PixelPatchTiles'
|
|
46
54
|
export * from './History/PixelWriter'
|
|
47
55
|
|
|
48
|
-
export * from './ImageData/
|
|
49
|
-
export * from './ImageData/ReusableImageData'
|
|
56
|
+
export * from './ImageData/_ImageData-types'
|
|
50
57
|
export * from './ImageData/copyImageData'
|
|
51
58
|
export * from './ImageData/extractImageDataBuffer'
|
|
59
|
+
export * from './ImageData/ImageDataLike'
|
|
52
60
|
export * from './ImageData/imageDataToAlphaMaskBuffer'
|
|
53
61
|
export * from './ImageData/imageDataToDataUrl'
|
|
54
62
|
export * from './ImageData/imageDataToImgBlob'
|
|
55
|
-
export * from './ImageData/
|
|
63
|
+
export * from './ImageData/imageDataToUint32Array'
|
|
56
64
|
export * from './ImageData/imgBlobToImageData'
|
|
57
65
|
export * from './ImageData/invertImageData'
|
|
58
66
|
export * from './ImageData/resampleImageData'
|
|
59
67
|
export * from './ImageData/resizeImageData'
|
|
68
|
+
export * from './ImageData/ReusableImageData'
|
|
60
69
|
export * from './ImageData/serialization'
|
|
61
70
|
export * from './ImageData/uInt32ArrayToImageData'
|
|
62
71
|
export * from './ImageData/writeImageData'
|
|
63
72
|
export * from './ImageData/writeImageDataBuffer'
|
|
64
73
|
|
|
65
|
-
export * from './IndexedImage/
|
|
74
|
+
export * from './IndexedImage/_indexedImage-types'
|
|
66
75
|
export * from './IndexedImage/getIndexedImageColorCounts'
|
|
76
|
+
export * from './IndexedImage/IndexedImage'
|
|
67
77
|
export * from './IndexedImage/indexedImageToAverageColor'
|
|
68
78
|
export * from './IndexedImage/indexedImageToImageData'
|
|
69
79
|
export * from './IndexedImage/resampleIndexedImage'
|
|
@@ -72,12 +82,16 @@ export * from './Input/fileInputChangeToImageData'
|
|
|
72
82
|
export * from './Input/fileToImageData'
|
|
73
83
|
export * from './Input/getSupportedRasterFormats'
|
|
74
84
|
|
|
75
|
-
export * from './
|
|
76
|
-
export * from './Internal/resolveClipping'
|
|
77
|
-
|
|
85
|
+
export * from './Mask/_mask-types'
|
|
78
86
|
export * from './Mask/AlphaMask'
|
|
79
|
-
export * from './Mask/BinaryMask'
|
|
80
87
|
export * from './Mask/applyBinaryMaskToAlphaMask'
|
|
88
|
+
export * from './Mask/BinaryMask'
|
|
89
|
+
|
|
90
|
+
export * from './Mask/BinaryMask/makeBinaryMaskFromAlphaMask'
|
|
91
|
+
export * from './Mask/BinaryMask/makeBinaryMaskOutline'
|
|
92
|
+
export * from './Mask/BinaryMask/makeCircleBinaryMaskOutline'
|
|
93
|
+
export * from './Mask/BinaryMask/makeRectBinaryMaskOutline'
|
|
94
|
+
|
|
81
95
|
export * from './Mask/copyMask'
|
|
82
96
|
export * from './Mask/extractMask'
|
|
83
97
|
export * from './Mask/extractMaskBuffer'
|
|
@@ -90,14 +104,20 @@ export * from './MaskRect/merge2BinaryMaskRects'
|
|
|
90
104
|
export * from './MaskRect/mergeBinaryMaskRects'
|
|
91
105
|
export * from './MaskRect/subtractBinaryMaskRects'
|
|
92
106
|
|
|
93
|
-
export * from './Paint/
|
|
94
|
-
export * from './Paint/
|
|
95
|
-
export * from './Paint/
|
|
96
|
-
export * from './Paint/
|
|
107
|
+
export * from './Paint/_paint-types'
|
|
108
|
+
export * from './Paint/AlphaMaskPaintBuffer'
|
|
109
|
+
export * from './Paint/AlphaMaskPaintBufferCanvasRenderer'
|
|
110
|
+
export * from './Paint/BinaryMaskPaintBuffer'
|
|
111
|
+
export * from './Paint/BinaryMaskPaintBufferCanvasRenderer'
|
|
112
|
+
export * from './Paint/ColorPaintBuffer'
|
|
113
|
+
export * from './Paint/ColorPaintBufferCanvasRenderer'
|
|
114
|
+
export * from './Paint/eachTileInBounds'
|
|
115
|
+
export * from './Paint/makeCirclePaintMask'
|
|
97
116
|
export * from './Paint/makePaintMask'
|
|
98
117
|
export * from './Paint/makeRectFalloffPaintAlphaMask'
|
|
118
|
+
export * from './Paint/PaintCursorRenderer'
|
|
99
119
|
|
|
100
|
-
export * from './PixelData/
|
|
120
|
+
export * from './PixelData/_pixelData-types'
|
|
101
121
|
export * from './PixelData/applyAlphaMaskToPixelData'
|
|
102
122
|
export * from './PixelData/applyBinaryMaskToPixelData'
|
|
103
123
|
export * from './PixelData/applyMaskToPixelData'
|
|
@@ -115,25 +135,30 @@ export * from './PixelData/blendPixelDataBinaryMask'
|
|
|
115
135
|
export * from './PixelData/blendPixelDataMask'
|
|
116
136
|
export * from './PixelData/blendPixelDataPaintBuffer'
|
|
117
137
|
export * from './PixelData/clearPixelDataFast'
|
|
138
|
+
export * from './PixelData/copyPixelData'
|
|
118
139
|
export * from './PixelData/extractPixelData'
|
|
119
140
|
export * from './PixelData/extractPixelDataBuffer'
|
|
120
141
|
export * from './PixelData/fillPixelData'
|
|
121
142
|
export * from './PixelData/fillPixelDataBinaryMask'
|
|
122
143
|
export * from './PixelData/fillPixelDataFast'
|
|
123
144
|
export * from './PixelData/invertPixelData'
|
|
145
|
+
export * from './PixelData/PixelData'
|
|
124
146
|
export * from './PixelData/pixelDataToAlphaMask'
|
|
125
147
|
export * from './PixelData/reflectPixelData'
|
|
126
148
|
export * from './PixelData/resamplePixelData'
|
|
149
|
+
export * from './PixelData/ReusablePixelData'
|
|
127
150
|
export * from './PixelData/rotatePixelData'
|
|
151
|
+
export * from './PixelData/uInt32ArrayToPixelData'
|
|
128
152
|
export * from './PixelData/writePaintBufferToPixelData'
|
|
129
153
|
export * from './PixelData/writePixelDataBuffer'
|
|
130
154
|
|
|
131
|
-
export * from './
|
|
132
|
-
export * from './PixelTile/PixelTilePool'
|
|
133
|
-
|
|
155
|
+
export * from './Rect/_rect-types'
|
|
134
156
|
export * from './Rect/getRectsBounds'
|
|
157
|
+
export * from './Rect/resolveClipping'
|
|
135
158
|
export * from './Rect/trimMaskRectBounds'
|
|
136
159
|
export * from './Rect/trimRectBounds'
|
|
137
160
|
|
|
138
|
-
export * from './
|
|
139
|
-
export * from './
|
|
161
|
+
export * from './Tile/_tile-types'
|
|
162
|
+
export * from './Tile/MaskTile'
|
|
163
|
+
export * from './Tile/PixelTile'
|
|
164
|
+
export * from './Tile/TilePool'
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ImageDataLike } from '../_types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* converts {@link ImageData} to a faster Uint32Array
|
|
5
|
-
*/
|
|
6
|
-
export function imageDataToUInt32Array(imageData: ImageDataLike): Uint32Array {
|
|
7
|
-
return new Uint32Array(
|
|
8
|
-
imageData.data.buffer,
|
|
9
|
-
imageData.data.byteOffset,
|
|
10
|
-
// Shift right by 2 is a fast bitwise division by 4.
|
|
11
|
-
imageData.data.byteLength >> 2,
|
|
12
|
-
)
|
|
13
|
-
}
|
package/src/Internal/helpers.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { MaskType, type PaintAlphaMask } from '../_types'
|
|
2
|
-
|
|
3
|
-
export function makeCirclePaintAlphaMask(size: number, fallOff: (d: number) => number = (d) => d): PaintAlphaMask {
|
|
4
|
-
const area = size * size
|
|
5
|
-
const data = new Uint8Array(area)
|
|
6
|
-
const radius = size / 2
|
|
7
|
-
const invR = 1 / radius
|
|
8
|
-
|
|
9
|
-
const centerOffset = -Math.ceil(radius - 0.5)
|
|
10
|
-
|
|
11
|
-
for (let y = 0; y < size; y++) {
|
|
12
|
-
const rowOffset = y * size
|
|
13
|
-
const dy = y - radius + 0.5
|
|
14
|
-
const dy2 = dy * dy
|
|
15
|
-
|
|
16
|
-
for (let x = 0; x < size; x++) {
|
|
17
|
-
const dx = x - radius + 0.5
|
|
18
|
-
const distSqr = dx * dx + dy2
|
|
19
|
-
|
|
20
|
-
if (distSqr <= (radius * radius)) {
|
|
21
|
-
const dist = Math.sqrt(distSqr) * invR
|
|
22
|
-
|
|
23
|
-
// Pass 1.0 at center, 0.0 at edge
|
|
24
|
-
const strength = fallOff(1 - dist)
|
|
25
|
-
if (strength > 0) {
|
|
26
|
-
const intensity = (strength * 255) | 0
|
|
27
|
-
data[rowOffset + x] = Math.max(0, Math.min(255, intensity))
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
type: MaskType.ALPHA,
|
|
35
|
-
data,
|
|
36
|
-
w: size,
|
|
37
|
-
h: size,
|
|
38
|
-
centerOffsetX: centerOffset,
|
|
39
|
-
centerOffsetY: centerOffset
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MaskType, type PaintBinaryMask } from '../_types'
|
|
2
|
-
|
|
3
|
-
export function makeCirclePaintBinaryMask(size: number): PaintBinaryMask {
|
|
4
|
-
const area = size * size
|
|
5
|
-
const data = new Uint8Array(area)
|
|
6
|
-
const radius = size / 2
|
|
7
|
-
|
|
8
|
-
const centerOffset = -Math.ceil(radius - 0.5)
|
|
9
|
-
|
|
10
|
-
for (let y = 0; y < size; y++) {
|
|
11
|
-
for (let x = 0; x < size; x++) {
|
|
12
|
-
const dx = x - radius + 0.5
|
|
13
|
-
const dy = y - radius + 0.5
|
|
14
|
-
const distSqr = dx * dx + dy * dy
|
|
15
|
-
if (distSqr <= (radius * radius)) {
|
|
16
|
-
data[y * size + x] = 1
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
type: MaskType.BINARY,
|
|
23
|
-
data,
|
|
24
|
-
w: size,
|
|
25
|
-
h: size,
|
|
26
|
-
centerOffsetX: centerOffset,
|
|
27
|
-
centerOffsetY: centerOffset,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { IPixelData } from '../_types'
|
|
2
|
-
|
|
3
|
-
export class PixelTile implements IPixelData {
|
|
4
|
-
readonly data32: Uint32Array
|
|
5
|
-
readonly width: number
|
|
6
|
-
readonly height: number
|
|
7
|
-
readonly imageData: ImageData
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
public id: number,
|
|
11
|
-
public tx: number,
|
|
12
|
-
public ty: number,
|
|
13
|
-
tileSize: number,
|
|
14
|
-
tileArea: number,
|
|
15
|
-
) {
|
|
16
|
-
this.width = this.height = tileSize
|
|
17
|
-
this.data32 = new Uint32Array(tileArea)
|
|
18
|
-
const data8 = new Uint8ClampedArray(this.data32.buffer) as Uint8ClampedArray<ArrayBuffer>
|
|
19
|
-
this.imageData = new ImageData(data8, tileSize, tileSize)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
File without changes
|