pixel-data-js 0.5.2 → 0.8.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.dev.cjs +871 -257
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +814 -231
- package/dist/index.dev.js.map +1 -1
- package/dist/index.prod.cjs +871 -257
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +171 -100
- package/dist/index.prod.js +814 -231
- package/dist/index.prod.js.map +1 -1
- package/package.json +1 -1
- package/src/Algorithm/floodFillSelection.ts +1 -1
- package/src/{blend-modes.ts → BlendModes/blend-modes-fast.ts} +215 -217
- package/src/BlendModes/blend-modes-perfect.ts +651 -0
- package/src/BlendModes/blend-modes.ts +31 -0
- package/src/IndexedImage/IndexedImage.ts +32 -49
- package/src/IndexedImage/indexedImageToAverageColor.ts +65 -0
- package/src/PixelData/PixelData.ts +31 -0
- package/src/PixelData/applyMaskToPixelData.ts +1 -1
- package/src/PixelData/blendColorPixelData.ts +4 -3
- package/src/PixelData/blendPixelData.ts +4 -3
- package/src/PixelData/clearPixelData.ts +1 -1
- package/src/PixelData/fillPixelData.ts +1 -1
- package/src/PixelData/invertPixelData.ts +1 -1
- package/src/PixelData/pixelDataToAlphaMask.ts +1 -1
- package/src/PixelData/reflectPixelData.ts +42 -0
- package/src/PixelData/rotatePixelData.ts +56 -0
- package/src/_types.ts +3 -3
- package/src/index.ts +7 -2
- package/src/PixelData.ts +0 -20
package/dist/index.prod.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ interface PixelBlendOptions extends PixelOptions {
|
|
|
133
133
|
sy?: number;
|
|
134
134
|
/**
|
|
135
135
|
* The blending algorithm to use for blending pixels.
|
|
136
|
-
* @default {@link
|
|
136
|
+
* @default {@link sourceOverFast}
|
|
137
137
|
*/
|
|
138
138
|
blendFn?: BlendColor32;
|
|
139
139
|
}
|
|
@@ -143,7 +143,7 @@ interface PixelBlendOptions extends PixelOptions {
|
|
|
143
143
|
interface ColorBlendOptions extends PixelOptions {
|
|
144
144
|
/**
|
|
145
145
|
* The blending algorithm to use for blending pixels.
|
|
146
|
-
* @default {@link
|
|
146
|
+
* @default {@link sourceOverFast}
|
|
147
147
|
*/
|
|
148
148
|
blendFn?: BlendColor32;
|
|
149
149
|
}
|
|
@@ -156,91 +156,6 @@ type SelectionRect = Rect & ({
|
|
|
156
156
|
maskType?: null;
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
declare const overwriteColor32: BlendColor32;
|
|
160
|
-
declare const sourceOverColor32: BlendColor32;
|
|
161
|
-
/** Math.min(src, dst) */
|
|
162
|
-
declare const darkenColor32: BlendColor32;
|
|
163
|
-
/** (src * dst) / 255 */
|
|
164
|
-
declare const multiplyColor32: BlendColor32;
|
|
165
|
-
/** 255 - (255-src)/dst */
|
|
166
|
-
declare const colorBurnColor32: BlendColor32;
|
|
167
|
-
/** src + dst - 255 */
|
|
168
|
-
declare const linearBurnColor32: BlendColor32;
|
|
169
|
-
declare const darkerColor32: BlendColor32;
|
|
170
|
-
/** Math.max(src, dst) */
|
|
171
|
-
declare const lightenColor32: BlendColor32;
|
|
172
|
-
/**
|
|
173
|
-
* 255 - ((255 - src) * (255 - dst))
|
|
174
|
-
*/
|
|
175
|
-
declare const screenColor32: BlendColor32;
|
|
176
|
-
/** src === 255 ? 255 : Math.min(255, (dst << 8) / (255 - src)) */
|
|
177
|
-
declare const colorDodgeColor32: BlendColor32;
|
|
178
|
-
/** src + dst */
|
|
179
|
-
declare const linearDodgeColor32: BlendColor32;
|
|
180
|
-
declare const lighterColor32: BlendColor32;
|
|
181
|
-
/** src < 128 ? (2 * src * dst) : (255 - 2 * (255 - src) * (255 - dst)) */
|
|
182
|
-
declare const overlayColor32: BlendColor32;
|
|
183
|
-
/** ((255 - dst) * ((src * dst) >> 8) + dst * (255 - (((255 - src) * (255 - dst)) >> 8))) >> 8 */
|
|
184
|
-
declare const softLightColor32: BlendColor32;
|
|
185
|
-
/** If src < 128 (50% gray), Multiply; otherwise, Screen */
|
|
186
|
-
declare const hardLightColor32: BlendColor32;
|
|
187
|
-
/**
|
|
188
|
-
* If src < 128: Burn(dst, 2 * src)
|
|
189
|
-
* If src >= 128: Dodge(dst, 2 * (src - 128))
|
|
190
|
-
*/
|
|
191
|
-
declare const vividLightColor32: BlendColor32;
|
|
192
|
-
/** dst + 2 * src - 255 (Clamped to 0-255) */
|
|
193
|
-
declare const linearLightColor32: BlendColor32;
|
|
194
|
-
/** src < 128 ? min(dst, 2 * src) : max(dst, 2 * (src - 128)) */
|
|
195
|
-
declare const pinLightColor32: BlendColor32;
|
|
196
|
-
/** (Vivid Light logic forced to 0 or 255) */
|
|
197
|
-
declare const hardMixColor32: BlendColor32;
|
|
198
|
-
/** Math.abs(src - dst) */
|
|
199
|
-
declare const differenceColor32: BlendColor32;
|
|
200
|
-
/** dst + src - ((dst * src) >> 7) */
|
|
201
|
-
declare const exclusionColor32: BlendColor32;
|
|
202
|
-
/** Math.max(0, dst - src) */
|
|
203
|
-
declare const subtractColor32: BlendColor32;
|
|
204
|
-
/** sr === 0 ? 255 : Math.min(255, (dr << 8) / sr) */
|
|
205
|
-
declare const divideColor32: BlendColor32;
|
|
206
|
-
declare enum BlendMode {
|
|
207
|
-
overwrite = 0,
|
|
208
|
-
sourceOver = 1,
|
|
209
|
-
darken = 2,
|
|
210
|
-
multiply = 3,
|
|
211
|
-
colorBurn = 4,
|
|
212
|
-
linearBurn = 5,
|
|
213
|
-
darkerColor = 6,
|
|
214
|
-
lighten = 7,
|
|
215
|
-
screen = 8,
|
|
216
|
-
colorDodge = 9,
|
|
217
|
-
linearDodge = 10,
|
|
218
|
-
lighterColor = 11,
|
|
219
|
-
overlay = 12,
|
|
220
|
-
softLight = 13,
|
|
221
|
-
hardLight = 14,
|
|
222
|
-
vividLight = 15,
|
|
223
|
-
linearLight = 16,
|
|
224
|
-
pinLight = 17,
|
|
225
|
-
hardMix = 18,
|
|
226
|
-
difference = 19,
|
|
227
|
-
exclusion = 20,
|
|
228
|
-
subtract = 21,
|
|
229
|
-
divide = 22
|
|
230
|
-
}
|
|
231
|
-
declare const BLENDER_REGISTRY: readonly [readonly [BlendMode.overwrite, BlendColor32], readonly [BlendMode.sourceOver, BlendColor32], readonly [BlendMode.darken, BlendColor32], readonly [BlendMode.multiply, BlendColor32], readonly [BlendMode.colorBurn, BlendColor32], readonly [BlendMode.linearBurn, BlendColor32], readonly [BlendMode.darkerColor, BlendColor32], readonly [BlendMode.lighten, BlendColor32], readonly [BlendMode.screen, BlendColor32], readonly [BlendMode.colorDodge, BlendColor32], readonly [BlendMode.linearDodge, BlendColor32], readonly [BlendMode.lighterColor, BlendColor32], readonly [BlendMode.overlay, BlendColor32], readonly [BlendMode.softLight, BlendColor32], readonly [BlendMode.hardLight, BlendColor32], readonly [BlendMode.vividLight, BlendColor32], readonly [BlendMode.linearLight, BlendColor32], readonly [BlendMode.pinLight, BlendColor32], readonly [BlendMode.hardMix, BlendColor32], readonly [BlendMode.difference, BlendColor32], readonly [BlendMode.exclusion, BlendColor32], readonly [BlendMode.subtract, BlendColor32], readonly [BlendMode.divide, BlendColor32]];
|
|
232
|
-
type RegisteredBlender = typeof BLENDER_REGISTRY[number][1];
|
|
233
|
-
type BlendModeIndex = number & {
|
|
234
|
-
readonly __brandBlendModeIndex: unique symbol;
|
|
235
|
-
};
|
|
236
|
-
declare const COLOR_32_BLEND_MODES: BlendColor32[];
|
|
237
|
-
declare const COLOR_32_BLEND_TO_INDEX: {
|
|
238
|
-
get: (blend: RegisteredBlender) => BlendModeIndex;
|
|
239
|
-
};
|
|
240
|
-
declare const INDEX_TO_COLOR_32_BLEND: {
|
|
241
|
-
get: (index: BlendModeIndex) => RegisteredBlender;
|
|
242
|
-
};
|
|
243
|
-
|
|
244
159
|
/**
|
|
245
160
|
* Packs RGBA into a 32-bit integer compatible with
|
|
246
161
|
* Little-Endian Uint32Array views on ImageData.
|
|
@@ -284,10 +199,11 @@ declare function color32ToCssRGBA(color: Color32): string;
|
|
|
284
199
|
|
|
285
200
|
declare class PixelData {
|
|
286
201
|
readonly imageData: ImageDataLike;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
202
|
+
data32: Uint32Array;
|
|
203
|
+
width: number;
|
|
204
|
+
height: number;
|
|
290
205
|
constructor(imageData: ImageDataLike);
|
|
206
|
+
copy(): PixelData;
|
|
291
207
|
}
|
|
292
208
|
|
|
293
209
|
type FloodFillImageDataOptions = {
|
|
@@ -335,6 +251,158 @@ type FloodFillResult = {
|
|
|
335
251
|
*/
|
|
336
252
|
declare function floodFillSelection(img: ImageDataLike | PixelData, startX: number, startY: number, { contiguous, tolerance, bounds, }?: FloodFillImageDataOptions): FloodFillResult | null;
|
|
337
253
|
|
|
254
|
+
declare enum BlendMode {
|
|
255
|
+
overwrite = 0,
|
|
256
|
+
sourceOver = 1,
|
|
257
|
+
darken = 2,
|
|
258
|
+
multiply = 3,
|
|
259
|
+
colorBurn = 4,
|
|
260
|
+
linearBurn = 5,
|
|
261
|
+
darkerColor = 6,
|
|
262
|
+
lighten = 7,
|
|
263
|
+
screen = 8,
|
|
264
|
+
colorDodge = 9,
|
|
265
|
+
linearDodge = 10,
|
|
266
|
+
lighterColor = 11,
|
|
267
|
+
overlay = 12,
|
|
268
|
+
softLight = 13,
|
|
269
|
+
hardLight = 14,
|
|
270
|
+
vividLight = 15,
|
|
271
|
+
linearLight = 16,
|
|
272
|
+
pinLight = 17,
|
|
273
|
+
hardMix = 18,
|
|
274
|
+
difference = 19,
|
|
275
|
+
exclusion = 20,
|
|
276
|
+
subtract = 21,
|
|
277
|
+
divide = 22
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
declare const overwriteFast: BlendColor32;
|
|
281
|
+
declare const sourceOverFast: BlendColor32;
|
|
282
|
+
declare const darkenFast: BlendColor32;
|
|
283
|
+
/** (src * dst) / 255 */
|
|
284
|
+
declare const multiplyFast: BlendColor32;
|
|
285
|
+
/** 255 - (255-src)/dst */
|
|
286
|
+
declare const colorBurnFast: BlendColor32;
|
|
287
|
+
/** src + dst - 255 */
|
|
288
|
+
declare const linearBurnFast: BlendColor32;
|
|
289
|
+
declare const darkerFast: BlendColor32;
|
|
290
|
+
/** Math.max(src, dst) */
|
|
291
|
+
declare const lightenFast: BlendColor32;
|
|
292
|
+
/**
|
|
293
|
+
* 255 - ((255 - src) * (255 - dst))
|
|
294
|
+
*/
|
|
295
|
+
declare const screenFast: BlendColor32;
|
|
296
|
+
/** src === 255 ? 255 : Math.min(255, (dst << 8) / (255 - src)) */
|
|
297
|
+
declare const colorDodgeFast: BlendColor32;
|
|
298
|
+
/** src + dst */
|
|
299
|
+
declare const linearDodgeFast: BlendColor32;
|
|
300
|
+
declare const lighterFast: BlendColor32;
|
|
301
|
+
/** src < 128 ? (2 * src * dst) : (255 - 2 * (255 - src) * (255 - dst)) */
|
|
302
|
+
declare const overlayFast: BlendColor32;
|
|
303
|
+
/** ((255 - dst) * ((src * dst) >> 8) + dst * (255 - (((255 - src) * (255 - dst)) >> 8))) >> 8 */
|
|
304
|
+
declare const softLightFast: BlendColor32;
|
|
305
|
+
/** If src < 128 (50% gray), Multiply; otherwise, Screen */
|
|
306
|
+
declare const hardLightFast: BlendColor32;
|
|
307
|
+
/**
|
|
308
|
+
* If src < 128: Burn(dst, 2 * src)
|
|
309
|
+
* If src >= 128: Dodge(dst, 2 * (src - 128))
|
|
310
|
+
*/
|
|
311
|
+
declare const vividLightFast: BlendColor32;
|
|
312
|
+
/** dst + 2 * src - 255 (Clamped to 0-255) */
|
|
313
|
+
declare const linearLightFast: BlendColor32;
|
|
314
|
+
/** src < 128 ? min(dst, 2 * src) : max(dst, 2 * (src - 128)) */
|
|
315
|
+
declare const pinLightFast: BlendColor32;
|
|
316
|
+
/** (Vivid Light logic forced to 0 or 255) */
|
|
317
|
+
declare const hardMixFast: BlendColor32;
|
|
318
|
+
/** Math.abs(src - dst) */
|
|
319
|
+
declare const differenceFast: BlendColor32;
|
|
320
|
+
/** dst + src - ((dst * src) >> 7) */
|
|
321
|
+
declare const exclusionFast: BlendColor32;
|
|
322
|
+
/** Math.max(0, dst - src) */
|
|
323
|
+
declare const subtractFast: BlendColor32;
|
|
324
|
+
/** sr === 0 ? 255 : Math.min(255, (dr << 8) / sr) */
|
|
325
|
+
declare const divideFast: BlendColor32;
|
|
326
|
+
declare const FAST_BLENDER_REGISTRY: readonly [readonly [BlendMode.overwrite, BlendColor32], readonly [BlendMode.sourceOver, BlendColor32], readonly [BlendMode.darken, BlendColor32], readonly [BlendMode.multiply, BlendColor32], readonly [BlendMode.colorBurn, BlendColor32], readonly [BlendMode.linearBurn, BlendColor32], readonly [BlendMode.darkerColor, BlendColor32], readonly [BlendMode.lighten, BlendColor32], readonly [BlendMode.screen, BlendColor32], readonly [BlendMode.colorDodge, BlendColor32], readonly [BlendMode.linearDodge, BlendColor32], readonly [BlendMode.lighterColor, BlendColor32], readonly [BlendMode.overlay, BlendColor32], readonly [BlendMode.softLight, BlendColor32], readonly [BlendMode.hardLight, BlendColor32], readonly [BlendMode.vividLight, BlendColor32], readonly [BlendMode.linearLight, BlendColor32], readonly [BlendMode.pinLight, BlendColor32], readonly [BlendMode.hardMix, BlendColor32], readonly [BlendMode.difference, BlendColor32], readonly [BlendMode.exclusion, BlendColor32], readonly [BlendMode.subtract, BlendColor32], readonly [BlendMode.divide, BlendColor32]];
|
|
327
|
+
type RegisteredFastBlender = typeof FAST_BLENDER_REGISTRY[number][1];
|
|
328
|
+
type FastBlendModeIndex = number & {
|
|
329
|
+
readonly __brandBlendModeIndex: unique symbol;
|
|
330
|
+
};
|
|
331
|
+
declare const FAST_BLEND_MODES: BlendColor32[];
|
|
332
|
+
declare const FAST_BLEND_TO_INDEX: {
|
|
333
|
+
get: (blend: RegisteredFastBlender) => FastBlendModeIndex;
|
|
334
|
+
};
|
|
335
|
+
declare const INDEX_TO_FAST_BLEND: {
|
|
336
|
+
get: (index: FastBlendModeIndex) => RegisteredFastBlender;
|
|
337
|
+
};
|
|
338
|
+
type FastBlendModes = {
|
|
339
|
+
[K in keyof typeof BlendMode]: RegisteredFastBlender;
|
|
340
|
+
};
|
|
341
|
+
declare const FAST_BLEND_MODE_BY_NAME: FastBlendModes;
|
|
342
|
+
|
|
343
|
+
declare const overwritePerfect: BlendColor32;
|
|
344
|
+
declare const sourceOverPerfect: BlendColor32;
|
|
345
|
+
declare const darkenPerfect: BlendColor32;
|
|
346
|
+
/** (src * dst) / 255 */
|
|
347
|
+
declare const multiplyPerfect: BlendColor32;
|
|
348
|
+
/** 255 - (255-src)/dst */
|
|
349
|
+
declare const colorBurnPerfect: BlendColor32;
|
|
350
|
+
/** src + dst - 255 */
|
|
351
|
+
declare const linearBurnPerfect: BlendColor32;
|
|
352
|
+
declare const darkerPerfect: BlendColor32;
|
|
353
|
+
/** Math.max(src, dst) */
|
|
354
|
+
declare const lightenPerfect: BlendColor32;
|
|
355
|
+
/**
|
|
356
|
+
* 255 - ((255 - src) * (255 - dst))
|
|
357
|
+
*/
|
|
358
|
+
declare const screenPerfect: BlendColor32;
|
|
359
|
+
/** src === 255 ? 255 : Math.min(255, (dst << 8) / (255 - src)) */
|
|
360
|
+
declare const colorDodgePerfect: BlendColor32;
|
|
361
|
+
/** src + dst */
|
|
362
|
+
declare const linearDodgePerfect: BlendColor32;
|
|
363
|
+
declare const lighterPerfect: BlendColor32;
|
|
364
|
+
/** src < 128 ? (2 * src * dst) : (255 - 2 * (255 - src) * (255 - dst)) */
|
|
365
|
+
declare const overlayPerfect: BlendColor32;
|
|
366
|
+
/** ((255 - dst) * ((src * dst) >> 8) + dst * (255 - (((255 - src) * (255 - dst)) >> 8))) >> 8 */
|
|
367
|
+
declare const softLightPerfect: BlendColor32;
|
|
368
|
+
/** If src < 128 (50% gray), Multiply; otherwise, Screen */
|
|
369
|
+
declare const hardLightPerfect: BlendColor32;
|
|
370
|
+
/**
|
|
371
|
+
* If src < 128: Burn(dst, 2 * src)
|
|
372
|
+
* If src >= 128: Dodge(dst, 2 * (src - 128))
|
|
373
|
+
*/
|
|
374
|
+
declare const vividLightPerfect: BlendColor32;
|
|
375
|
+
/** dst + 2 * src - 255 (Clamped to 0-255) */
|
|
376
|
+
declare const linearLightPerfect: BlendColor32;
|
|
377
|
+
/** src < 128 ? min(dst, 2 * src) : max(dst, 2 * (src - 128)) */
|
|
378
|
+
declare const pinLightPerfect: BlendColor32;
|
|
379
|
+
/** (Vivid Light logic forced to 0 or 255) */
|
|
380
|
+
declare const hardMixPerfect: BlendColor32;
|
|
381
|
+
/** Math.abs(src - dst) */
|
|
382
|
+
declare const differencePerfect: BlendColor32;
|
|
383
|
+
/** dst + src - ((dst * src) >> 7) */
|
|
384
|
+
declare const exclusionPerfect: BlendColor32;
|
|
385
|
+
/** Math.max(0, dst - src) */
|
|
386
|
+
declare const subtractPerfect: BlendColor32;
|
|
387
|
+
/** sr === 0 ? 255 : Math.min(255, (dr << 8) / sr) */
|
|
388
|
+
declare const dividePerfect: BlendColor32;
|
|
389
|
+
declare const PERFECT_BLENDER_REGISTRY: readonly [readonly [BlendMode.overwrite, BlendColor32], readonly [BlendMode.sourceOver, BlendColor32], readonly [BlendMode.darken, BlendColor32], readonly [BlendMode.multiply, BlendColor32], readonly [BlendMode.colorBurn, BlendColor32], readonly [BlendMode.linearBurn, BlendColor32], readonly [BlendMode.darkerColor, BlendColor32], readonly [BlendMode.lighten, BlendColor32], readonly [BlendMode.screen, BlendColor32], readonly [BlendMode.colorDodge, BlendColor32], readonly [BlendMode.linearDodge, BlendColor32], readonly [BlendMode.lighterColor, BlendColor32], readonly [BlendMode.overlay, BlendColor32], readonly [BlendMode.softLight, BlendColor32], readonly [BlendMode.hardLight, BlendColor32], readonly [BlendMode.vividLight, BlendColor32], readonly [BlendMode.linearLight, BlendColor32], readonly [BlendMode.pinLight, BlendColor32], readonly [BlendMode.hardMix, BlendColor32], readonly [BlendMode.difference, BlendColor32], readonly [BlendMode.exclusion, BlendColor32], readonly [BlendMode.subtract, BlendColor32], readonly [BlendMode.divide, BlendColor32]];
|
|
390
|
+
type RegisteredPerfectBlender = typeof PERFECT_BLENDER_REGISTRY[number][1];
|
|
391
|
+
type PerfectBlendModeIndex = number & {
|
|
392
|
+
readonly __brandBlendModeIndex: unique symbol;
|
|
393
|
+
};
|
|
394
|
+
declare const PERFECT_BLEND_MODES: BlendColor32[];
|
|
395
|
+
declare const PERFECT_BLEND_TO_INDEX: {
|
|
396
|
+
get: (blend: RegisteredPerfectBlender) => PerfectBlendModeIndex;
|
|
397
|
+
};
|
|
398
|
+
declare const INDEX_TO_PERFECT_BLEND: {
|
|
399
|
+
get: (index: PerfectBlendModeIndex) => RegisteredPerfectBlender;
|
|
400
|
+
};
|
|
401
|
+
type PerfectBlendModes = {
|
|
402
|
+
[K in keyof typeof BlendMode]: RegisteredPerfectBlender;
|
|
403
|
+
};
|
|
404
|
+
declare const PERFECT_BLEND_MODE_BY_NAME: PerfectBlendModes;
|
|
405
|
+
|
|
338
406
|
type PixelCanvas = {
|
|
339
407
|
readonly canvas: HTMLCanvasElement;
|
|
340
408
|
readonly ctx: CanvasRenderingContext2D;
|
|
@@ -589,30 +657,33 @@ type IndexedImage = {
|
|
|
589
657
|
/** The height of the image in pixels. */
|
|
590
658
|
height: number;
|
|
591
659
|
/**
|
|
592
|
-
*
|
|
660
|
+
* A flat array of indices where each value points to a color in the palette.
|
|
593
661
|
* Accessible via the formula: `index = x + (y * width)`.
|
|
594
662
|
*/
|
|
595
663
|
data: Int32Array;
|
|
596
664
|
/**
|
|
597
|
-
* A
|
|
598
|
-
* Every 4 bytes represent one color: `[r, g, b, a]`.
|
|
665
|
+
* A palette of packed 32-bit colors (ABGR).
|
|
599
666
|
*/
|
|
600
|
-
palette:
|
|
667
|
+
palette: Int32Array;
|
|
601
668
|
/**
|
|
602
669
|
* The specific index in the palette that represents a fully transparent pixel.
|
|
603
|
-
* All pixels with an alpha value of 0 are normalized to this index.
|
|
604
670
|
*/
|
|
605
671
|
transparentPalletIndex: number;
|
|
606
672
|
};
|
|
607
673
|
/**
|
|
608
674
|
* Converts standard ImageData into an IndexedImage format.
|
|
609
|
-
* This process normalizes all transparent pixels into a single palette entry
|
|
610
|
-
* and maps all unique RGBA colors to sequential integer IDs.
|
|
611
|
-
* @param imageData - The raw ImageData from a canvas or image source.
|
|
612
|
-
* @returns An IndexedImage object containing the index grid and color palette.
|
|
613
675
|
*/
|
|
614
676
|
declare function makeIndexedImage(imageData: ImageData): IndexedImage;
|
|
615
677
|
|
|
678
|
+
/**
|
|
679
|
+
* Calculates the area-weighted average color of an IndexedImage.
|
|
680
|
+
* This accounts for how often each palette index appears in the pixel data.
|
|
681
|
+
* @param indexedImage - The IndexedImage containing pixel indices and the palette.
|
|
682
|
+
* @param includeTransparent - Whether to include the transparent pixels in the average.
|
|
683
|
+
* @returns The average RGBA color of the image.
|
|
684
|
+
*/
|
|
685
|
+
declare function indexedImageToAverageColor(indexedImage: IndexedImage, includeTransparent?: boolean): Color32;
|
|
686
|
+
|
|
616
687
|
/**
|
|
617
688
|
* A convenience wrapper that extracts the first {@link File} from an
|
|
618
689
|
* {@link HTMLInputElement} change event and converts it into {@link ImageData}.
|
|
@@ -819,4 +890,4 @@ declare function pixelDataToAlphaMask(pixelData: PixelData): AlphaMask;
|
|
|
819
890
|
*/
|
|
820
891
|
declare function trimRectBounds<T extends Rect | SelectionRect>(target: T, bounds: Rect): void;
|
|
821
892
|
|
|
822
|
-
export { type AlphaMask, type AnyMask, type ApplyMaskOptions, type Base64EncodedUInt8Array, type BinaryMask, type BlendColor32, BlendMode, type
|
|
893
|
+
export { type AlphaMask, type AnyMask, type ApplyMaskOptions, type Base64EncodedUInt8Array, type BinaryMask, type BlendColor32, BlendMode, type Color32, type ColorBlendOptions, FAST_BLENDER_REGISTRY, FAST_BLEND_MODES, FAST_BLEND_MODE_BY_NAME, FAST_BLEND_TO_INDEX, type FastBlendModeIndex, type FastBlendModes, type FloodFillImageDataOptions, type FloodFillResult, INDEX_TO_FAST_BLEND, INDEX_TO_PERFECT_BLEND, type ImageDataLike, type IndexedImage, MaskType, PERFECT_BLENDER_REGISTRY, PERFECT_BLEND_MODES, PERFECT_BLEND_MODE_BY_NAME, PERFECT_BLEND_TO_INDEX, type PerfectBlendModeIndex, type PerfectBlendModes, type PixelBlendOptions, type PixelCanvas, PixelData, type PixelOptions, type RGBA, type Rect, type RegisteredFastBlender, type RegisteredPerfectBlender, type ReusableCanvas, type SelectionRect, type SerializedImageData, UnsupportedFormatError, applyMaskToPixelData, base64DecodeArrayBuffer, base64EncodeArrayBuffer, blendColorPixelData, blendPixelData, clearPixelData, color32ToCssRGBA, color32ToHex, colorBurnFast, colorBurnPerfect, colorDistance, colorDodgeFast, colorDodgePerfect, copyImageData, copyImageDataLike, copyMask, darkenFast, darkenPerfect, darkerFast, darkerPerfect, deserializeImageData, deserializeNullableImageData, deserializeRawImageData, differenceFast, differencePerfect, divideFast, dividePerfect, exclusionFast, exclusionPerfect, extractImageDataPixels, extractMask, fileInputChangeToImageData, fileToImageData, fillPixelData, floodFillSelection, getImageDataFromClipboard, getSupportedPixelFormats, hardLightFast, hardLightPerfect, hardMixFast, hardMixPerfect, imageDataToAlphaMask, imageDataToDataUrl, imageDataToImgBlob, imgBlobToImageData, indexedImageToAverageColor, invertAlphaMask, invertBinaryMask, invertImageData, invertPixelData, lerpColor32, lerpColor32Fast, lightenFast, lightenPerfect, lighterFast, lighterPerfect, linearBurnFast, linearBurnPerfect, linearDodgeFast, linearDodgePerfect, linearLightFast, linearLightPerfect, makeIndexedImage, makePixelCanvas, makeReusableCanvas, mergeMasks, multiplyFast, multiplyPerfect, overlayFast, overlayPerfect, overwriteFast, overwritePerfect, packColor, packRGBA, pinLightFast, pinLightPerfect, pixelDataToAlphaMask, resizeImageData, screenFast, screenPerfect, serializeImageData, serializeNullableImageData, softLightFast, softLightPerfect, sourceOverFast, sourceOverPerfect, subtractFast, subtractPerfect, trimRectBounds, unpackAlpha, unpackBlue, unpackColor, unpackColorTo, unpackGreen, unpackRed, vividLightFast, vividLightPerfect, writeImageDataPixels, writeImageDataToClipboard, writeImgBlobToClipboard };
|