pixel-data-js 0.19.2 → 0.21.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 +32 -9
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +32 -9
- package/dist/index.dev.js.map +1 -1
- package/dist/index.prod.cjs +32 -9
- package/dist/index.prod.cjs.map +1 -1
- package/dist/index.prod.d.ts +17 -10
- package/dist/index.prod.js +32 -9
- package/dist/index.prod.js.map +1 -1
- package/package.json +1 -1
- package/src/History/PixelMutator/mutatorClear.ts +4 -3
- package/src/History/PixelMutator/mutatorFill.ts +4 -3
- package/src/PixelData/clearPixelData.ts +2 -2
- package/src/PixelData/fillPixelData.ts +36 -10
- package/src/_types.ts +8 -0
package/dist/index.dev.cjs
CHANGED
|
@@ -3249,21 +3249,24 @@ var mutatorBlendPixelData = ((writer, deps = defaults11) => {
|
|
|
3249
3249
|
|
|
3250
3250
|
// src/PixelData/fillPixelData.ts
|
|
3251
3251
|
var SCRATCH_RECT = makeClippedRect();
|
|
3252
|
-
function fillPixelData(dst, color, _x, _y, _w, _h) {
|
|
3252
|
+
function fillPixelData(dst, color, _x, _y, _w, _h, _mask) {
|
|
3253
3253
|
let x;
|
|
3254
3254
|
let y;
|
|
3255
3255
|
let w;
|
|
3256
3256
|
let h;
|
|
3257
|
+
let mask;
|
|
3257
3258
|
if (typeof _x === "object") {
|
|
3258
3259
|
x = _x.x ?? 0;
|
|
3259
3260
|
y = _x.y ?? 0;
|
|
3260
3261
|
w = _x.w ?? dst.width;
|
|
3261
3262
|
h = _x.h ?? dst.height;
|
|
3263
|
+
mask = _x.mask;
|
|
3262
3264
|
} else if (typeof _x === "number") {
|
|
3263
3265
|
x = _x;
|
|
3264
3266
|
y = _y;
|
|
3265
3267
|
w = _w;
|
|
3266
3268
|
h = _h;
|
|
3269
|
+
mask = _mask;
|
|
3267
3270
|
} else {
|
|
3268
3271
|
x = 0;
|
|
3269
3272
|
y = 0;
|
|
@@ -3284,10 +3287,28 @@ function fillPixelData(dst, color, _x, _y, _w, _h) {
|
|
|
3284
3287
|
dst32.fill(color);
|
|
3285
3288
|
return;
|
|
3286
3289
|
}
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3290
|
+
if (mask) {
|
|
3291
|
+
for (let iy = 0; iy < actualH; iy++) {
|
|
3292
|
+
const currentY = finalY + iy;
|
|
3293
|
+
const maskY = currentY - y;
|
|
3294
|
+
const maskOffset = maskY * w;
|
|
3295
|
+
for (let ix = 0; ix < actualW; ix++) {
|
|
3296
|
+
const currentX = finalX + ix;
|
|
3297
|
+
const maskX = currentX - x;
|
|
3298
|
+
const maskIndex = maskOffset + maskX;
|
|
3299
|
+
const isMasked = mask[maskIndex];
|
|
3300
|
+
if (isMasked) {
|
|
3301
|
+
const dstIndex = currentY * dw + currentX;
|
|
3302
|
+
dst32[dstIndex] = color;
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
} else {
|
|
3307
|
+
for (let iy = 0; iy < actualH; iy++) {
|
|
3308
|
+
const start = (finalY + iy) * dw + finalX;
|
|
3309
|
+
const end = start + actualW;
|
|
3310
|
+
dst32.fill(color, start, end);
|
|
3311
|
+
}
|
|
3291
3312
|
}
|
|
3292
3313
|
}
|
|
3293
3314
|
|
|
@@ -3305,10 +3326,11 @@ var mutatorClear = ((writer, deps = defaults12) => {
|
|
|
3305
3326
|
x = 0,
|
|
3306
3327
|
y = 0,
|
|
3307
3328
|
w = writer.target.width,
|
|
3308
|
-
h = writer.target.height
|
|
3329
|
+
h = writer.target.height,
|
|
3330
|
+
mask = void 0
|
|
3309
3331
|
} = rect;
|
|
3310
3332
|
writer.accumulator.storeRegionBeforeState(x, y, w, h);
|
|
3311
|
-
fillPixelData2(writer.target, 0, x, y, w, h);
|
|
3333
|
+
fillPixelData2(writer.target, 0, x, y, w, h, mask);
|
|
3312
3334
|
}
|
|
3313
3335
|
};
|
|
3314
3336
|
});
|
|
@@ -3327,10 +3349,11 @@ var mutatorFill = ((writer, deps = defaults13) => {
|
|
|
3327
3349
|
x = 0,
|
|
3328
3350
|
y = 0,
|
|
3329
3351
|
w = writer.target.width,
|
|
3330
|
-
h = writer.target.height
|
|
3352
|
+
h = writer.target.height,
|
|
3353
|
+
mask = void 0
|
|
3331
3354
|
} = rect;
|
|
3332
3355
|
writer.accumulator.storeRegionBeforeState(x, y, w, h);
|
|
3333
|
-
fillPixelData2(writer.target, color, x, y, w, h);
|
|
3356
|
+
fillPixelData2(writer.target, color, x, y, w, h, mask);
|
|
3334
3357
|
}
|
|
3335
3358
|
};
|
|
3336
3359
|
});
|