@leafer-draw/worker 1.10.0 → 1.10.1

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.
@@ -6835,7 +6835,7 @@ class LeafLevelList {
6835
6835
  }
6836
6836
  }
6837
6837
 
6838
- const version = "1.10.0";
6838
+ const version = "1.10.1";
6839
6839
 
6840
6840
  class LeaferCanvas extends LeaferCanvasBase {
6841
6841
  get allowBackgroundColor() {
@@ -8148,7 +8148,7 @@ let UI = UI_1 = class UI extends Leaf {
8148
8148
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8149
8149
  } else drawer.rect(x, y, width, height);
8150
8150
  }
8151
- drawImagePlaceholder(_image, canvas, renderOptions) {
8151
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
8152
8152
  Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8153
8153
  }
8154
8154
  animate(keyframe, _options, _type, _isTemp) {
@@ -9406,30 +9406,31 @@ function fill(fill, ui, canvas, renderOptions) {
9406
9406
  }
9407
9407
 
9408
9408
  function fills(fills, ui, canvas, renderOptions) {
9409
- let item;
9409
+ let item, originPaint, countImage;
9410
9410
  for (let i = 0, len = fills.length; i < len; i++) {
9411
- item = fills[i];
9411
+ item = fills[i], originPaint = item.originPaint;
9412
9412
  if (item.image) {
9413
+ countImage ? countImage++ : countImage = 1;
9413
9414
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
9414
9415
  if (!item.style) {
9415
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
9416
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
9416
9417
  continue;
9417
9418
  }
9418
9419
  }
9419
9420
  canvas.fillStyle = item.style;
9420
- if (item.transform || item.scaleFixed) {
9421
+ if (item.transform || originPaint.scaleFixed) {
9421
9422
  canvas.save();
9422
9423
  if (item.transform) canvas.transform(item.transform);
9423
- if (item.scaleFixed) {
9424
+ if (originPaint.scaleFixed) {
9424
9425
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
9425
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9426
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9426
9427
  }
9427
- if (item.blendMode) canvas.blendMode = item.blendMode;
9428
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
9428
9429
  fillPathOrText(ui, canvas, renderOptions);
9429
9430
  canvas.restore();
9430
9431
  } else {
9431
- if (item.blendMode) {
9432
- canvas.saveBlendMode(item.blendMode);
9432
+ if (originPaint.blendMode) {
9433
+ canvas.saveBlendMode(originPaint.blendMode);
9433
9434
  fillPathOrText(ui, canvas, renderOptions);
9434
9435
  canvas.restoreBlendMode();
9435
9436
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -9582,8 +9583,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
9582
9583
  const {strokeStyle: strokeStyle} = item;
9583
9584
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
9584
9585
  } else canvas.strokeStyle = item.style;
9585
- if (item.blendMode) {
9586
- canvas.saveBlendMode(item.blendMode);
9586
+ if (item.originPaint.blendMode) {
9587
+ canvas.saveBlendMode(item.originPaint.blendMode);
9587
9588
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
9588
9589
  canvas.restoreBlendMode();
9589
9590
  } else {
@@ -9680,62 +9681,63 @@ function compute(attrName, ui) {
9680
9681
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
9681
9682
  isTransparent = true;
9682
9683
  }
9683
- }
9684
- if (attrName === "fill") {
9685
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9686
- stintSet(data, "__isTransparentFill", isTransparent);
9684
+ if (attrName === "fill") {
9685
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9686
+ stintSet(data, "__isTransparentFill", isTransparent);
9687
+ } else {
9688
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9689
+ stintSet(data, "__isTransparentStroke", isTransparent);
9690
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9691
+ }
9687
9692
  } else {
9688
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9689
- stintSet(data, "__isTransparentStroke", isTransparent);
9690
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9693
+ data.__removePaint(attrName, false);
9691
9694
  }
9692
9695
  }
9693
9696
 
9694
9697
  function getLeafPaint(attrName, paint, ui) {
9695
9698
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
9696
- let data;
9699
+ let leafPaint;
9697
9700
  const {boxBounds: boxBounds} = ui.__layout;
9698
9701
  switch (paint.type) {
9699
9702
  case "image":
9700
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9703
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9701
9704
  break;
9702
9705
 
9703
9706
  case "linear":
9704
- data = PaintGradient.linearGradient(paint, boxBounds);
9707
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
9705
9708
  break;
9706
9709
 
9707
9710
  case "radial":
9708
- data = PaintGradient.radialGradient(paint, boxBounds);
9711
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
9709
9712
  break;
9710
9713
 
9711
9714
  case "angular":
9712
- data = PaintGradient.conicGradient(paint, boxBounds);
9715
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
9713
9716
  break;
9714
9717
 
9715
9718
  case "solid":
9716
9719
  const {type: type, color: color, opacity: opacity} = paint;
9717
- data = {
9720
+ leafPaint = {
9718
9721
  type: type,
9719
9722
  style: ColorConvert.string(color, opacity)
9720
9723
  };
9721
9724
  break;
9722
9725
 
9723
9726
  default:
9724
- if (!isUndefined(paint.r)) data = {
9727
+ if (!isUndefined(paint.r)) leafPaint = {
9725
9728
  type: "solid",
9726
9729
  style: ColorConvert.string(paint)
9727
9730
  };
9728
9731
  }
9729
- if (data) {
9730
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
9732
+ if (leafPaint) {
9733
+ leafPaint.originPaint = paint;
9734
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
9731
9735
  if (paint.style) {
9732
9736
  if (paint.style.strokeWidth === 0) return undefined;
9733
- data.strokeStyle = paint.style;
9737
+ leafPaint.strokeStyle = paint.style;
9734
9738
  }
9735
- if (paint.editing) data.editing = paint.editing;
9736
- if (paint.blendMode) data.blendMode = paint.blendMode;
9737
9739
  }
9738
- return data;
9740
+ return leafPaint;
9739
9741
  }
9740
9742
 
9741
9743
  const PaintModule = {
@@ -9868,10 +9870,6 @@ const tempScaleData = {};
9868
9870
  const tempImage = {};
9869
9871
 
9870
9872
  function createData(leafPaint, image, paint, box) {
9871
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
9872
- if (changeful) leafPaint.changeful = changeful;
9873
- if (sync) leafPaint.sync = sync;
9874
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
9875
9873
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
9876
9874
  }
9877
9875
 
@@ -10098,14 +10096,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
10098
10096
 
10099
10097
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10100
10098
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
10101
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
10099
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
10102
10100
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
10103
10101
  return false;
10104
10102
  } else {
10105
10103
  if (drawImage) {
10106
10104
  if (data.repeat) {
10107
10105
  drawImage = false;
10108
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10106
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10109
10107
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10110
10108
  }
10111
10109
  }
@@ -10117,16 +10115,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10117
10115
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
10118
10116
  return true;
10119
10117
  } else {
10120
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10118
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10121
10119
  return false;
10122
10120
  }
10123
10121
  }
10124
10122
  }
10125
10123
 
10126
10124
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
10127
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10125
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10128
10126
  let {width: width, height: height} = image, clipUI;
10129
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
10127
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
10130
10128
  canvas.save();
10131
10129
  clipUI && canvas.clipUI(ui);
10132
10130
  blendMode && (canvas.blendMode = blendMode);
@@ -10141,7 +10139,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
10141
10139
  }
10142
10140
 
10143
10141
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
10144
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
10142
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
10145
10143
  if (canvas) {
10146
10144
  const {pixelRatio: pixelRatio} = canvas;
10147
10145
  scaleData.scaleX *= pixelRatio;