leafer-draw 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
  const debug$4 = Debug.get("LeaferCanvas");
6841
6841
 
@@ -8354,7 +8354,7 @@ let UI = UI_1 = class UI extends Leaf {
8354
8354
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8355
8355
  } else drawer.rect(x, y, width, height);
8356
8356
  }
8357
- drawImagePlaceholder(_image, canvas, renderOptions) {
8357
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
8358
8358
  Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8359
8359
  }
8360
8360
  animate(keyframe, _options, _type, _isTemp) {
@@ -9612,30 +9612,31 @@ function fill(fill, ui, canvas, renderOptions) {
9612
9612
  }
9613
9613
 
9614
9614
  function fills(fills, ui, canvas, renderOptions) {
9615
- let item;
9615
+ let item, originPaint, countImage;
9616
9616
  for (let i = 0, len = fills.length; i < len; i++) {
9617
- item = fills[i];
9617
+ item = fills[i], originPaint = item.originPaint;
9618
9618
  if (item.image) {
9619
+ countImage ? countImage++ : countImage = 1;
9619
9620
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
9620
9621
  if (!item.style) {
9621
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
9622
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
9622
9623
  continue;
9623
9624
  }
9624
9625
  }
9625
9626
  canvas.fillStyle = item.style;
9626
- if (item.transform || item.scaleFixed) {
9627
+ if (item.transform || originPaint.scaleFixed) {
9627
9628
  canvas.save();
9628
9629
  if (item.transform) canvas.transform(item.transform);
9629
- if (item.scaleFixed) {
9630
+ if (originPaint.scaleFixed) {
9630
9631
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
9631
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9632
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9632
9633
  }
9633
- if (item.blendMode) canvas.blendMode = item.blendMode;
9634
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
9634
9635
  fillPathOrText(ui, canvas, renderOptions);
9635
9636
  canvas.restore();
9636
9637
  } else {
9637
- if (item.blendMode) {
9638
- canvas.saveBlendMode(item.blendMode);
9638
+ if (originPaint.blendMode) {
9639
+ canvas.saveBlendMode(originPaint.blendMode);
9639
9640
  fillPathOrText(ui, canvas, renderOptions);
9640
9641
  canvas.restoreBlendMode();
9641
9642
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -9788,8 +9789,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
9788
9789
  const {strokeStyle: strokeStyle} = item;
9789
9790
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
9790
9791
  } else canvas.strokeStyle = item.style;
9791
- if (item.blendMode) {
9792
- canvas.saveBlendMode(item.blendMode);
9792
+ if (item.originPaint.blendMode) {
9793
+ canvas.saveBlendMode(item.originPaint.blendMode);
9793
9794
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
9794
9795
  canvas.restoreBlendMode();
9795
9796
  } else {
@@ -9886,62 +9887,63 @@ function compute(attrName, ui) {
9886
9887
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
9887
9888
  isTransparent = true;
9888
9889
  }
9889
- }
9890
- if (attrName === "fill") {
9891
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9892
- stintSet(data, "__isTransparentFill", isTransparent);
9890
+ if (attrName === "fill") {
9891
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9892
+ stintSet(data, "__isTransparentFill", isTransparent);
9893
+ } else {
9894
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9895
+ stintSet(data, "__isTransparentStroke", isTransparent);
9896
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9897
+ }
9893
9898
  } else {
9894
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9895
- stintSet(data, "__isTransparentStroke", isTransparent);
9896
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9899
+ data.__removePaint(attrName, false);
9897
9900
  }
9898
9901
  }
9899
9902
 
9900
9903
  function getLeafPaint(attrName, paint, ui) {
9901
9904
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
9902
- let data;
9905
+ let leafPaint;
9903
9906
  const {boxBounds: boxBounds} = ui.__layout;
9904
9907
  switch (paint.type) {
9905
9908
  case "image":
9906
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9909
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9907
9910
  break;
9908
9911
 
9909
9912
  case "linear":
9910
- data = PaintGradient.linearGradient(paint, boxBounds);
9913
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
9911
9914
  break;
9912
9915
 
9913
9916
  case "radial":
9914
- data = PaintGradient.radialGradient(paint, boxBounds);
9917
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
9915
9918
  break;
9916
9919
 
9917
9920
  case "angular":
9918
- data = PaintGradient.conicGradient(paint, boxBounds);
9921
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
9919
9922
  break;
9920
9923
 
9921
9924
  case "solid":
9922
9925
  const {type: type, color: color, opacity: opacity} = paint;
9923
- data = {
9926
+ leafPaint = {
9924
9927
  type: type,
9925
9928
  style: ColorConvert.string(color, opacity)
9926
9929
  };
9927
9930
  break;
9928
9931
 
9929
9932
  default:
9930
- if (!isUndefined(paint.r)) data = {
9933
+ if (!isUndefined(paint.r)) leafPaint = {
9931
9934
  type: "solid",
9932
9935
  style: ColorConvert.string(paint)
9933
9936
  };
9934
9937
  }
9935
- if (data) {
9936
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
9938
+ if (leafPaint) {
9939
+ leafPaint.originPaint = paint;
9940
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
9937
9941
  if (paint.style) {
9938
9942
  if (paint.style.strokeWidth === 0) return undefined;
9939
- data.strokeStyle = paint.style;
9943
+ leafPaint.strokeStyle = paint.style;
9940
9944
  }
9941
- if (paint.editing) data.editing = paint.editing;
9942
- if (paint.blendMode) data.blendMode = paint.blendMode;
9943
9945
  }
9944
- return data;
9946
+ return leafPaint;
9945
9947
  }
9946
9948
 
9947
9949
  const PaintModule = {
@@ -10074,10 +10076,6 @@ const tempScaleData = {};
10074
10076
  const tempImage = {};
10075
10077
 
10076
10078
  function createData(leafPaint, image, paint, box) {
10077
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
10078
- if (changeful) leafPaint.changeful = changeful;
10079
- if (sync) leafPaint.sync = sync;
10080
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
10081
10079
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
10082
10080
  }
10083
10081
 
@@ -10304,14 +10302,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
10304
10302
 
10305
10303
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10306
10304
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
10307
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
10305
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
10308
10306
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
10309
10307
  return false;
10310
10308
  } else {
10311
10309
  if (drawImage) {
10312
10310
  if (data.repeat) {
10313
10311
  drawImage = false;
10314
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10312
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10315
10313
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10316
10314
  }
10317
10315
  }
@@ -10323,16 +10321,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10323
10321
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
10324
10322
  return true;
10325
10323
  } else {
10326
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10324
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10327
10325
  return false;
10328
10326
  }
10329
10327
  }
10330
10328
  }
10331
10329
 
10332
10330
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
10333
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10331
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10334
10332
  let {width: width, height: height} = image, clipUI;
10335
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
10333
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
10336
10334
  canvas.save();
10337
10335
  clipUI && canvas.clipUI(ui);
10338
10336
  blendMode && (canvas.blendMode = blendMode);
@@ -10347,7 +10345,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
10347
10345
  }
10348
10346
 
10349
10347
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
10350
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
10348
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
10351
10349
  if (canvas) {
10352
10350
  const {pixelRatio: pixelRatio} = canvas;
10353
10351
  scaleData.scaleX *= pixelRatio;