pixel-data-js 0.34.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.
@@ -6163,6 +6163,9 @@ function makeRectFalloffPaintAlphaMask(width, height, fallOff = (d) => d) {
6163
6163
  // src/Paint/PaintRect.ts
6164
6164
  function makePaintRect(w, h) {
6165
6165
  return {
6166
+ type: null,
6167
+ outlineType: 2 /* RECT */,
6168
+ data: null,
6166
6169
  w,
6167
6170
  h,
6168
6171
  centerOffsetX: -(w - 1 >> 1),
@@ -6199,31 +6202,34 @@ function makePaintCursorRenderer(reusableCanvasFactory) {
6199
6202
  const getPixelData = makeReusablePixelData();
6200
6203
  let _color = packColor(0, 255, 255, 255);
6201
6204
  let _scale = 1;
6202
- let currentMask = {
6203
- type: 1 /* BINARY */,
6205
+ let currentBrush = {
6206
+ type: null,
6204
6207
  outlineType: 2 /* RECT */,
6205
6208
  w: 1,
6206
6209
  h: 1,
6207
6210
  centerOffsetX: -(10 - 1 >> 1),
6208
- centerOffsetY: -(10 - 1 >> 1)
6211
+ centerOffsetY: -(10 - 1 >> 1),
6212
+ data: null
6209
6213
  };
6210
6214
  let outline;
6211
6215
  function update(paintMask, scale, color, alphaThreshold = 127) {
6212
- currentMask = paintMask ?? currentMask;
6216
+ currentBrush = paintMask ?? currentBrush;
6213
6217
  _scale = scale ?? _scale;
6214
6218
  _color = color ?? _color;
6215
- updateBuffer(currentMask.w * _scale + 2 * _scale, currentMask.h * _scale + 2 * _scale);
6216
- if (currentMask.type === 1 /* BINARY */) {
6217
- if (currentMask.outlineType === 1 /* CIRCLE */) {
6218
- outline = makeCircleBinaryMaskOutline(currentMask.w, _scale);
6219
- } else if (currentMask.outlineType === 2 /* RECT */) {
6220
- outline = makeRectBinaryMaskOutline(currentMask.w, currentMask.h, _scale);
6221
- } else if (currentMask.outlineType === 0 /* MASKED */) {
6222
- outline = makeBinaryMaskOutline(currentMask, _scale);
6219
+ updateBuffer(currentBrush.w * _scale + 2 * _scale, currentBrush.h * _scale + 2 * _scale);
6220
+ if (currentBrush.type === 1 /* BINARY */) {
6221
+ if (currentBrush.outlineType === 1 /* CIRCLE */) {
6222
+ outline = makeCircleBinaryMaskOutline(currentBrush.w, _scale);
6223
+ } else if (currentBrush.outlineType === 2 /* RECT */) {
6224
+ outline = makeRectBinaryMaskOutline(currentBrush.w, currentBrush.h, _scale);
6225
+ } else if (currentBrush.outlineType === 0 /* MASKED */) {
6226
+ outline = makeBinaryMaskOutline(currentBrush, _scale);
6223
6227
  }
6224
- } else if (currentMask.type === 0 /* ALPHA */) {
6225
- const mask = makeBinaryMaskFromAlphaMask(currentMask, alphaThreshold);
6228
+ } else if (currentBrush.type === 0 /* ALPHA */) {
6229
+ const mask = makeBinaryMaskFromAlphaMask(currentBrush, alphaThreshold);
6226
6230
  outline = makeBinaryMaskOutline(mask, _scale);
6231
+ } else {
6232
+ outline = makeRectBinaryMaskOutline(currentBrush.w, currentBrush.h, _scale);
6227
6233
  }
6228
6234
  const pixelData = getPixelData(outline.w, outline.h);
6229
6235
  fillPixelDataBinaryMask(pixelData, _color, outline);
@@ -6236,10 +6242,10 @@ function makePaintCursorRenderer(reusableCanvasFactory) {
6236
6242
  h: 0
6237
6243
  };
6238
6244
  function getBounds(centerX, centerY) {
6239
- boundsScratch.x = centerX + currentMask.centerOffsetX;
6240
- boundsScratch.y = centerY + currentMask.centerOffsetY;
6241
- boundsScratch.w = currentMask.w;
6242
- boundsScratch.h = currentMask.h;
6245
+ boundsScratch.x = centerX + currentBrush.centerOffsetX;
6246
+ boundsScratch.y = centerY + currentBrush.centerOffsetY;
6247
+ boundsScratch.w = currentBrush.w;
6248
+ boundsScratch.h = currentBrush.h;
6243
6249
  return boundsScratch;
6244
6250
  }
6245
6251
  const boundsScaledScratch = {
@@ -6249,22 +6255,22 @@ function makePaintCursorRenderer(reusableCanvasFactory) {
6249
6255
  h: 0
6250
6256
  };
6251
6257
  function getOutlineBoundsScaled(centerX, centerY) {
6252
- boundsScaledScratch.x = centerX * _scale + currentMask.centerOffsetX * _scale - 1;
6253
- boundsScaledScratch.y = centerY * _scale + currentMask.centerOffsetY * _scale - 1;
6254
- boundsScaledScratch.w = currentMask.w * _scale;
6255
- boundsScaledScratch.h = currentMask.h * _scale;
6258
+ boundsScaledScratch.x = centerX * _scale + currentBrush.centerOffsetX * _scale - 1;
6259
+ boundsScaledScratch.y = centerY * _scale + currentBrush.centerOffsetY * _scale - 1;
6260
+ boundsScaledScratch.w = currentBrush.w * _scale;
6261
+ boundsScaledScratch.h = currentBrush.h * _scale;
6256
6262
  return boundsScaledScratch;
6257
6263
  }
6258
6264
  function draw(drawCtx, centerX, centerY) {
6259
- const dx = centerX * _scale + currentMask.centerOffsetX * _scale - 1;
6260
- const dy = centerY * _scale + currentMask.centerOffsetY * _scale - 1;
6265
+ const dx = centerX * _scale + currentBrush.centerOffsetX * _scale - 1;
6266
+ const dy = centerY * _scale + currentBrush.centerOffsetY * _scale - 1;
6261
6267
  drawCtx.drawImage(canvas, Math.floor(dx), Math.floor(dy));
6262
6268
  }
6263
6269
  function getSettings() {
6264
6270
  return {
6265
6271
  color: _color,
6266
6272
  scale: _scale,
6267
- currentMask
6273
+ currentBrush
6268
6274
  };
6269
6275
  }
6270
6276
  return {