@leafer-editor/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.
- package/dist/worker.js +41 -43
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +41 -43
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +17 -17
package/dist/worker.module.js
CHANGED
|
@@ -6835,7 +6835,7 @@ class LeafLevelList {
|
|
|
6835
6835
|
}
|
|
6836
6836
|
}
|
|
6837
6837
|
|
|
6838
|
-
const version = "1.10.
|
|
6838
|
+
const version = "1.10.1";
|
|
6839
6839
|
|
|
6840
6840
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6841
6841
|
get allowBackgroundColor() {
|
|
@@ -8344,7 +8344,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
8344
8344
|
drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
|
|
8345
8345
|
} else drawer.rect(x, y, width, height);
|
|
8346
8346
|
}
|
|
8347
|
-
drawImagePlaceholder(
|
|
8347
|
+
drawImagePlaceholder(_paint, canvas, renderOptions) {
|
|
8348
8348
|
Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
|
|
8349
8349
|
}
|
|
8350
8350
|
animate(keyframe, _options, _type, _isTemp) {
|
|
@@ -11097,30 +11097,31 @@ function fill(fill, ui, canvas, renderOptions) {
|
|
|
11097
11097
|
}
|
|
11098
11098
|
|
|
11099
11099
|
function fills(fills, ui, canvas, renderOptions) {
|
|
11100
|
-
let item;
|
|
11100
|
+
let item, originPaint, countImage;
|
|
11101
11101
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
11102
|
-
item = fills[i];
|
|
11102
|
+
item = fills[i], originPaint = item.originPaint;
|
|
11103
11103
|
if (item.image) {
|
|
11104
|
+
countImage ? countImage++ : countImage = 1;
|
|
11104
11105
|
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
11105
11106
|
if (!item.style) {
|
|
11106
|
-
if (
|
|
11107
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
11107
11108
|
continue;
|
|
11108
11109
|
}
|
|
11109
11110
|
}
|
|
11110
11111
|
canvas.fillStyle = item.style;
|
|
11111
|
-
if (item.transform ||
|
|
11112
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
11112
11113
|
canvas.save();
|
|
11113
11114
|
if (item.transform) canvas.transform(item.transform);
|
|
11114
|
-
if (
|
|
11115
|
+
if (originPaint.scaleFixed) {
|
|
11115
11116
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
11116
|
-
if (
|
|
11117
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
11117
11118
|
}
|
|
11118
|
-
if (
|
|
11119
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
11119
11120
|
fillPathOrText(ui, canvas, renderOptions);
|
|
11120
11121
|
canvas.restore();
|
|
11121
11122
|
} else {
|
|
11122
|
-
if (
|
|
11123
|
-
canvas.saveBlendMode(
|
|
11123
|
+
if (originPaint.blendMode) {
|
|
11124
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
11124
11125
|
fillPathOrText(ui, canvas, renderOptions);
|
|
11125
11126
|
canvas.restoreBlendMode();
|
|
11126
11127
|
} else fillPathOrText(ui, canvas, renderOptions);
|
|
@@ -11273,8 +11274,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
|
|
|
11273
11274
|
const {strokeStyle: strokeStyle} = item;
|
|
11274
11275
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
11275
11276
|
} else canvas.strokeStyle = item.style;
|
|
11276
|
-
if (item.blendMode) {
|
|
11277
|
-
canvas.saveBlendMode(item.blendMode);
|
|
11277
|
+
if (item.originPaint.blendMode) {
|
|
11278
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
11278
11279
|
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
11279
11280
|
canvas.restoreBlendMode();
|
|
11280
11281
|
} else {
|
|
@@ -11371,62 +11372,63 @@ function compute(attrName, ui) {
|
|
|
11371
11372
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
11372
11373
|
isTransparent = true;
|
|
11373
11374
|
}
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11375
|
+
if (attrName === "fill") {
|
|
11376
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
11377
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
11378
|
+
} else {
|
|
11379
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
11380
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
11381
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
11382
|
+
}
|
|
11378
11383
|
} else {
|
|
11379
|
-
|
|
11380
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
11381
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
11384
|
+
data.__removePaint(attrName, false);
|
|
11382
11385
|
}
|
|
11383
11386
|
}
|
|
11384
11387
|
|
|
11385
11388
|
function getLeafPaint(attrName, paint, ui) {
|
|
11386
11389
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
11387
|
-
let
|
|
11390
|
+
let leafPaint;
|
|
11388
11391
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
11389
11392
|
switch (paint.type) {
|
|
11390
11393
|
case "image":
|
|
11391
|
-
|
|
11394
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
11392
11395
|
break;
|
|
11393
11396
|
|
|
11394
11397
|
case "linear":
|
|
11395
|
-
|
|
11398
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
11396
11399
|
break;
|
|
11397
11400
|
|
|
11398
11401
|
case "radial":
|
|
11399
|
-
|
|
11402
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
11400
11403
|
break;
|
|
11401
11404
|
|
|
11402
11405
|
case "angular":
|
|
11403
|
-
|
|
11406
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
11404
11407
|
break;
|
|
11405
11408
|
|
|
11406
11409
|
case "solid":
|
|
11407
11410
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
11408
|
-
|
|
11411
|
+
leafPaint = {
|
|
11409
11412
|
type: type,
|
|
11410
11413
|
style: ColorConvert.string(color, opacity)
|
|
11411
11414
|
};
|
|
11412
11415
|
break;
|
|
11413
11416
|
|
|
11414
11417
|
default:
|
|
11415
|
-
if (!isUndefined(paint.r))
|
|
11418
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
11416
11419
|
type: "solid",
|
|
11417
11420
|
style: ColorConvert.string(paint)
|
|
11418
11421
|
};
|
|
11419
11422
|
}
|
|
11420
|
-
if (
|
|
11421
|
-
|
|
11423
|
+
if (leafPaint) {
|
|
11424
|
+
leafPaint.originPaint = paint;
|
|
11425
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
11422
11426
|
if (paint.style) {
|
|
11423
11427
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
11424
|
-
|
|
11428
|
+
leafPaint.strokeStyle = paint.style;
|
|
11425
11429
|
}
|
|
11426
|
-
if (paint.editing) data.editing = paint.editing;
|
|
11427
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
11428
11430
|
}
|
|
11429
|
-
return
|
|
11431
|
+
return leafPaint;
|
|
11430
11432
|
}
|
|
11431
11433
|
|
|
11432
11434
|
const PaintModule = {
|
|
@@ -11559,10 +11561,6 @@ const tempScaleData = {};
|
|
|
11559
11561
|
const tempImage = {};
|
|
11560
11562
|
|
|
11561
11563
|
function createData(leafPaint, image, paint, box) {
|
|
11562
|
-
const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
|
|
11563
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
11564
|
-
if (sync) leafPaint.sync = sync;
|
|
11565
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
11566
11564
|
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
11567
11565
|
}
|
|
11568
11566
|
|
|
@@ -11789,14 +11787,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
11789
11787
|
|
|
11790
11788
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
11791
11789
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
11792
|
-
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
11790
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
11793
11791
|
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
11794
11792
|
return false;
|
|
11795
11793
|
} else {
|
|
11796
11794
|
if (drawImage) {
|
|
11797
11795
|
if (data.repeat) {
|
|
11798
11796
|
drawImage = false;
|
|
11799
|
-
} else if (!(
|
|
11797
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
11800
11798
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
11801
11799
|
}
|
|
11802
11800
|
}
|
|
@@ -11808,16 +11806,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
11808
11806
|
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
11809
11807
|
return true;
|
|
11810
11808
|
} else {
|
|
11811
|
-
if (!paint.style ||
|
|
11809
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
11812
11810
|
return false;
|
|
11813
11811
|
}
|
|
11814
11812
|
}
|
|
11815
11813
|
}
|
|
11816
11814
|
|
|
11817
11815
|
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
11818
|
-
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
11816
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
11819
11817
|
let {width: width, height: height} = image, clipUI;
|
|
11820
|
-
if (transform && !transform.onlyScale ||
|
|
11818
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
11821
11819
|
canvas.save();
|
|
11822
11820
|
clipUI && canvas.clipUI(ui);
|
|
11823
11821
|
blendMode && (canvas.blendMode = blendMode);
|
|
@@ -11832,7 +11830,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
|
|
|
11832
11830
|
}
|
|
11833
11831
|
|
|
11834
11832
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
11835
|
-
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
11833
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
11836
11834
|
if (canvas) {
|
|
11837
11835
|
const {pixelRatio: pixelRatio} = canvas;
|
|
11838
11836
|
scaleData.scaleX *= pixelRatio;
|