@leafer-draw/miniapp 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() {
@@ -8301,7 +8301,7 @@ let UI = UI_1 = class UI extends Leaf {
8301
8301
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8302
8302
  } else drawer.rect(x, y, width, height);
8303
8303
  }
8304
- drawImagePlaceholder(_image, canvas, renderOptions) {
8304
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
8305
8305
  Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8306
8306
  }
8307
8307
  animate(keyframe, _options, _type, _isTemp) {
@@ -9559,30 +9559,31 @@ function fill(fill, ui, canvas, renderOptions) {
9559
9559
  }
9560
9560
 
9561
9561
  function fills(fills, ui, canvas, renderOptions) {
9562
- let item;
9562
+ let item, originPaint, countImage;
9563
9563
  for (let i = 0, len = fills.length; i < len; i++) {
9564
- item = fills[i];
9564
+ item = fills[i], originPaint = item.originPaint;
9565
9565
  if (item.image) {
9566
+ countImage ? countImage++ : countImage = 1;
9566
9567
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
9567
9568
  if (!item.style) {
9568
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
9569
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
9569
9570
  continue;
9570
9571
  }
9571
9572
  }
9572
9573
  canvas.fillStyle = item.style;
9573
- if (item.transform || item.scaleFixed) {
9574
+ if (item.transform || originPaint.scaleFixed) {
9574
9575
  canvas.save();
9575
9576
  if (item.transform) canvas.transform(item.transform);
9576
- if (item.scaleFixed) {
9577
+ if (originPaint.scaleFixed) {
9577
9578
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
9578
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9579
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
9579
9580
  }
9580
- if (item.blendMode) canvas.blendMode = item.blendMode;
9581
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
9581
9582
  fillPathOrText(ui, canvas, renderOptions);
9582
9583
  canvas.restore();
9583
9584
  } else {
9584
- if (item.blendMode) {
9585
- canvas.saveBlendMode(item.blendMode);
9585
+ if (originPaint.blendMode) {
9586
+ canvas.saveBlendMode(originPaint.blendMode);
9586
9587
  fillPathOrText(ui, canvas, renderOptions);
9587
9588
  canvas.restoreBlendMode();
9588
9589
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -9735,8 +9736,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
9735
9736
  const {strokeStyle: strokeStyle} = item;
9736
9737
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
9737
9738
  } else canvas.strokeStyle = item.style;
9738
- if (item.blendMode) {
9739
- canvas.saveBlendMode(item.blendMode);
9739
+ if (item.originPaint.blendMode) {
9740
+ canvas.saveBlendMode(item.originPaint.blendMode);
9740
9741
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
9741
9742
  canvas.restoreBlendMode();
9742
9743
  } else {
@@ -9833,62 +9834,63 @@ function compute(attrName, ui) {
9833
9834
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
9834
9835
  isTransparent = true;
9835
9836
  }
9836
- }
9837
- if (attrName === "fill") {
9838
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9839
- stintSet(data, "__isTransparentFill", isTransparent);
9837
+ if (attrName === "fill") {
9838
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
9839
+ stintSet(data, "__isTransparentFill", isTransparent);
9840
+ } else {
9841
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9842
+ stintSet(data, "__isTransparentStroke", isTransparent);
9843
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9844
+ }
9840
9845
  } else {
9841
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
9842
- stintSet(data, "__isTransparentStroke", isTransparent);
9843
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
9846
+ data.__removePaint(attrName, false);
9844
9847
  }
9845
9848
  }
9846
9849
 
9847
9850
  function getLeafPaint(attrName, paint, ui) {
9848
9851
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
9849
- let data;
9852
+ let leafPaint;
9850
9853
  const {boxBounds: boxBounds} = ui.__layout;
9851
9854
  switch (paint.type) {
9852
9855
  case "image":
9853
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9856
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9854
9857
  break;
9855
9858
 
9856
9859
  case "linear":
9857
- data = PaintGradient.linearGradient(paint, boxBounds);
9860
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
9858
9861
  break;
9859
9862
 
9860
9863
  case "radial":
9861
- data = PaintGradient.radialGradient(paint, boxBounds);
9864
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
9862
9865
  break;
9863
9866
 
9864
9867
  case "angular":
9865
- data = PaintGradient.conicGradient(paint, boxBounds);
9868
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
9866
9869
  break;
9867
9870
 
9868
9871
  case "solid":
9869
9872
  const {type: type, color: color, opacity: opacity} = paint;
9870
- data = {
9873
+ leafPaint = {
9871
9874
  type: type,
9872
9875
  style: ColorConvert.string(color, opacity)
9873
9876
  };
9874
9877
  break;
9875
9878
 
9876
9879
  default:
9877
- if (!isUndefined(paint.r)) data = {
9880
+ if (!isUndefined(paint.r)) leafPaint = {
9878
9881
  type: "solid",
9879
9882
  style: ColorConvert.string(paint)
9880
9883
  };
9881
9884
  }
9882
- if (data) {
9883
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
9885
+ if (leafPaint) {
9886
+ leafPaint.originPaint = paint;
9887
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
9884
9888
  if (paint.style) {
9885
9889
  if (paint.style.strokeWidth === 0) return undefined;
9886
- data.strokeStyle = paint.style;
9890
+ leafPaint.strokeStyle = paint.style;
9887
9891
  }
9888
- if (paint.editing) data.editing = paint.editing;
9889
- if (paint.blendMode) data.blendMode = paint.blendMode;
9890
9892
  }
9891
- return data;
9893
+ return leafPaint;
9892
9894
  }
9893
9895
 
9894
9896
  const PaintModule = {
@@ -10021,10 +10023,6 @@ const tempScaleData = {};
10021
10023
  const tempImage = {};
10022
10024
 
10023
10025
  function createData(leafPaint, image, paint, box) {
10024
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
10025
- if (changeful) leafPaint.changeful = changeful;
10026
- if (sync) leafPaint.sync = sync;
10027
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
10028
10026
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
10029
10027
  }
10030
10028
 
@@ -10251,14 +10249,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
10251
10249
 
10252
10250
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10253
10251
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
10254
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
10252
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
10255
10253
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
10256
10254
  return false;
10257
10255
  } else {
10258
10256
  if (drawImage) {
10259
10257
  if (data.repeat) {
10260
10258
  drawImage = false;
10261
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10259
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10262
10260
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10263
10261
  }
10264
10262
  }
@@ -10270,16 +10268,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10270
10268
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
10271
10269
  return true;
10272
10270
  } else {
10273
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10271
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10274
10272
  return false;
10275
10273
  }
10276
10274
  }
10277
10275
  }
10278
10276
 
10279
10277
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
10280
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10278
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10281
10279
  let {width: width, height: height} = image, clipUI;
10282
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
10280
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
10283
10281
  canvas.save();
10284
10282
  clipUI && canvas.clipUI(ui);
10285
10283
  blendMode && (canvas.blendMode = blendMode);
@@ -10294,7 +10292,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
10294
10292
  }
10295
10293
 
10296
10294
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
10297
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
10295
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
10298
10296
  if (canvas) {
10299
10297
  const {pixelRatio: pixelRatio} = canvas;
10300
10298
  scaleData.scaleX *= pixelRatio;