leafer-draw 1.6.6 → 1.7.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.
- package/dist/web.cjs +17 -11
- package/dist/web.esm.js +17 -11
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +86 -62
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +86 -62
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +3 -3
package/dist/web.js
CHANGED
|
@@ -46,7 +46,7 @@ var LeaferUI = (function (exports) {
|
|
|
46
46
|
};
|
|
47
47
|
const I$1 = IncrementId;
|
|
48
48
|
|
|
49
|
-
const { round: round$3, pow: pow$1, PI: PI$
|
|
49
|
+
const { round: round$3, pow: pow$1, PI: PI$3 } = Math;
|
|
50
50
|
const MathHelper = {
|
|
51
51
|
within(value, min, max) {
|
|
52
52
|
if (typeof min === 'object')
|
|
@@ -142,9 +142,9 @@ var LeaferUI = (function (exports) {
|
|
|
142
142
|
function randInt(num) {
|
|
143
143
|
return Math.round(Math.random() * num);
|
|
144
144
|
}
|
|
145
|
-
const OneRadian = PI$
|
|
146
|
-
const PI2 = PI$
|
|
147
|
-
const PI_2 = PI$
|
|
145
|
+
const OneRadian = PI$3 / 180;
|
|
146
|
+
const PI2 = PI$3 * 2;
|
|
147
|
+
const PI_2 = PI$3 / 2;
|
|
148
148
|
function getPointData() { return { x: 0, y: 0 }; }
|
|
149
149
|
function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
|
|
150
150
|
function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
|
|
|
439
439
|
const M$6 = MatrixHelper;
|
|
440
440
|
|
|
441
441
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
442
|
-
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2
|
|
442
|
+
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2 } = Math;
|
|
443
443
|
const PointHelper = {
|
|
444
444
|
defaultPoint: getPointData(),
|
|
445
445
|
tempPoint: {},
|
|
@@ -552,10 +552,11 @@ var LeaferUI = (function (exports) {
|
|
|
552
552
|
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
553
553
|
if (toOriginX === undefined)
|
|
554
554
|
toOriginX = originX, toOriginY = originY;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
555
|
+
const a = fromX - originX;
|
|
556
|
+
const b = fromY - originY;
|
|
557
|
+
const c = toX - toOriginX;
|
|
558
|
+
const d = toY - toOriginY;
|
|
559
|
+
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
559
560
|
},
|
|
560
561
|
getAtan2(t, to) {
|
|
561
562
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
@@ -3342,7 +3343,7 @@ var LeaferUI = (function (exports) {
|
|
|
3342
3343
|
const { arcTo } = PathCommandDataHelper;
|
|
3343
3344
|
const PathCorner = {
|
|
3344
3345
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3345
|
-
let command, commandLen;
|
|
3346
|
+
let command, lastCommand, commandLen;
|
|
3346
3347
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3347
3348
|
const len = data.length;
|
|
3348
3349
|
const smooth = [];
|
|
@@ -3380,8 +3381,10 @@ var LeaferUI = (function (exports) {
|
|
|
3380
3381
|
lastY = y;
|
|
3381
3382
|
break;
|
|
3382
3383
|
case Z:
|
|
3383
|
-
|
|
3384
|
-
|
|
3384
|
+
if (lastCommand !== Z) {
|
|
3385
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3386
|
+
smooth.push(Z);
|
|
3387
|
+
}
|
|
3385
3388
|
i += 1;
|
|
3386
3389
|
break;
|
|
3387
3390
|
default:
|
|
@@ -3390,6 +3393,7 @@ var LeaferUI = (function (exports) {
|
|
|
3390
3393
|
smooth.push(data[i + j]);
|
|
3391
3394
|
i += commandLen;
|
|
3392
3395
|
}
|
|
3396
|
+
lastCommand = command;
|
|
3393
3397
|
}
|
|
3394
3398
|
if (command !== Z) {
|
|
3395
3399
|
smooth[1] = startX;
|
|
@@ -3886,12 +3890,12 @@ var LeaferUI = (function (exports) {
|
|
|
3886
3890
|
try {
|
|
3887
3891
|
if (transform && pattern.setTransform) {
|
|
3888
3892
|
pattern.setTransform(transform);
|
|
3889
|
-
transform =
|
|
3893
|
+
transform = undefined;
|
|
3890
3894
|
}
|
|
3891
3895
|
}
|
|
3892
3896
|
catch (_a) { }
|
|
3893
3897
|
if (paint)
|
|
3894
|
-
paint
|
|
3898
|
+
DataHelper.stintSet(paint, 'transform', transform);
|
|
3895
3899
|
return pattern;
|
|
3896
3900
|
}
|
|
3897
3901
|
destroy() {
|
|
@@ -3996,10 +4000,14 @@ var LeaferUI = (function (exports) {
|
|
|
3996
4000
|
}));
|
|
3997
4001
|
}
|
|
3998
4002
|
const pathType = boundsType;
|
|
3999
|
-
function affectStrokeBoundsType(defaultValue) {
|
|
4003
|
+
function affectStrokeBoundsType(defaultValue, useStroke) {
|
|
4000
4004
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
4001
4005
|
set(value) {
|
|
4002
|
-
this.__setAttr(key, value)
|
|
4006
|
+
if (this.__setAttr(key, value)) {
|
|
4007
|
+
doStrokeType(this);
|
|
4008
|
+
if (useStroke)
|
|
4009
|
+
this.__.__useStroke = true;
|
|
4010
|
+
}
|
|
4003
4011
|
}
|
|
4004
4012
|
}));
|
|
4005
4013
|
}
|
|
@@ -5425,6 +5433,8 @@ var LeaferUI = (function (exports) {
|
|
|
5425
5433
|
|
|
5426
5434
|
const LeafRender = {
|
|
5427
5435
|
__render(canvas, options) {
|
|
5436
|
+
if (options.shape)
|
|
5437
|
+
return this.__renderShape(canvas, options);
|
|
5428
5438
|
if (this.__worldOpacity) {
|
|
5429
5439
|
const data = this.__;
|
|
5430
5440
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5434,12 +5444,10 @@ var LeaferUI = (function (exports) {
|
|
|
5434
5444
|
return this.__renderEraser(canvas, options);
|
|
5435
5445
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5436
5446
|
this.__draw(tempCanvas, options, canvas);
|
|
5437
|
-
if (this.__worldFlipped)
|
|
5447
|
+
if (this.__worldFlipped)
|
|
5438
5448
|
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5439
|
-
|
|
5440
|
-
else {
|
|
5449
|
+
else
|
|
5441
5450
|
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5442
|
-
}
|
|
5443
5451
|
tempCanvas.recycle(this.__nowWorld);
|
|
5444
5452
|
}
|
|
5445
5453
|
else {
|
|
@@ -5449,6 +5457,12 @@ var LeaferUI = (function (exports) {
|
|
|
5449
5457
|
Debug.drawBounds(this, canvas, options);
|
|
5450
5458
|
}
|
|
5451
5459
|
},
|
|
5460
|
+
__renderShape(canvas, options) {
|
|
5461
|
+
if (this.__worldOpacity) {
|
|
5462
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5463
|
+
this.__drawShape(canvas, options);
|
|
5464
|
+
}
|
|
5465
|
+
},
|
|
5452
5466
|
__clip(canvas, options) {
|
|
5453
5467
|
if (this.__worldOpacity) {
|
|
5454
5468
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5868,7 +5882,8 @@ var LeaferUI = (function (exports) {
|
|
|
5868
5882
|
__drawFast(_canvas, _options) { }
|
|
5869
5883
|
__draw(_canvas, _options, _originCanvas) { }
|
|
5870
5884
|
__clip(_canvas, _options) { }
|
|
5871
|
-
__renderShape(_canvas, _options
|
|
5885
|
+
__renderShape(_canvas, _options) { }
|
|
5886
|
+
__drawShape(_canvas, _options) { }
|
|
5872
5887
|
__updateWorldOpacity() { }
|
|
5873
5888
|
__updateChange() { }
|
|
5874
5889
|
__drawPath(_canvas) { }
|
|
@@ -6236,7 +6251,7 @@ var LeaferUI = (function (exports) {
|
|
|
6236
6251
|
}
|
|
6237
6252
|
}
|
|
6238
6253
|
|
|
6239
|
-
const version = "1.
|
|
6254
|
+
const version = "1.7.0";
|
|
6240
6255
|
|
|
6241
6256
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6242
6257
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -7177,13 +7192,9 @@ var LeaferUI = (function (exports) {
|
|
|
7177
7192
|
else
|
|
7178
7193
|
return strokeWidth;
|
|
7179
7194
|
}
|
|
7180
|
-
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7181
|
-
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7182
7195
|
get __hasMultiPaint() {
|
|
7183
7196
|
const t = this;
|
|
7184
|
-
|
|
7185
|
-
return true;
|
|
7186
|
-
return t.fill && this.__hasStroke;
|
|
7197
|
+
return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
|
|
7187
7198
|
}
|
|
7188
7199
|
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7189
7200
|
get __hasSurface() { const t = this; return (t.fill || t.stroke); }
|
|
@@ -7474,15 +7485,18 @@ var LeaferUI = (function (exports) {
|
|
|
7474
7485
|
const UIRender = {
|
|
7475
7486
|
__updateChange() {
|
|
7476
7487
|
const data = this.__;
|
|
7488
|
+
if (data.__useStroke) {
|
|
7489
|
+
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7490
|
+
stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
|
|
7491
|
+
stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7492
|
+
}
|
|
7477
7493
|
if (data.__useEffect) {
|
|
7478
7494
|
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7479
7495
|
stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
7480
7496
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7481
7497
|
}
|
|
7482
|
-
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7483
|
-
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7484
7498
|
data.__checkSingle();
|
|
7485
|
-
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7499
|
+
stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
|
|
7486
7500
|
},
|
|
7487
7501
|
__drawFast(canvas, options) {
|
|
7488
7502
|
drawFast(this, canvas, options);
|
|
@@ -7540,18 +7554,15 @@ var LeaferUI = (function (exports) {
|
|
|
7540
7554
|
this.__drawFast(canvas, options);
|
|
7541
7555
|
}
|
|
7542
7556
|
},
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
this.
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
if (stroke && !ignoreStroke)
|
|
7553
|
-
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7554
|
-
}
|
|
7557
|
+
__drawShape(canvas, options) {
|
|
7558
|
+
this.__drawRenderPath(canvas);
|
|
7559
|
+
const data = this.__, { fill, stroke } = data;
|
|
7560
|
+
if (fill && !options.ignoreFill)
|
|
7561
|
+
data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7562
|
+
if (data.__isCanvas)
|
|
7563
|
+
this.__drawAfterFill(canvas, options);
|
|
7564
|
+
if (stroke && !options.ignoreStroke)
|
|
7565
|
+
data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7555
7566
|
},
|
|
7556
7567
|
__drawAfterFill(canvas, options) {
|
|
7557
7568
|
if (this.__.__clipAfterFill) {
|
|
@@ -7676,12 +7687,14 @@ var LeaferUI = (function (exports) {
|
|
|
7676
7687
|
}
|
|
7677
7688
|
}
|
|
7678
7689
|
__updateRenderPath() {
|
|
7679
|
-
|
|
7680
|
-
|
|
7690
|
+
const data = this.__;
|
|
7691
|
+
if (data.path) {
|
|
7681
7692
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
7682
7693
|
if (data.__useArrow)
|
|
7683
7694
|
PathArrow.addArrows(this, !data.cornerRadius);
|
|
7684
7695
|
}
|
|
7696
|
+
else
|
|
7697
|
+
data.__pathForRender && (data.__pathForRender = undefined);
|
|
7685
7698
|
}
|
|
7686
7699
|
__drawRenderPath(canvas) {
|
|
7687
7700
|
canvas.beginPath();
|
|
@@ -7892,13 +7905,13 @@ var LeaferUI = (function (exports) {
|
|
|
7892
7905
|
surfaceType()
|
|
7893
7906
|
], exports.UI.prototype, "fill", void 0);
|
|
7894
7907
|
__decorate([
|
|
7895
|
-
strokeType()
|
|
7908
|
+
strokeType(undefined, true)
|
|
7896
7909
|
], exports.UI.prototype, "stroke", void 0);
|
|
7897
7910
|
__decorate([
|
|
7898
7911
|
strokeType('inside')
|
|
7899
7912
|
], exports.UI.prototype, "strokeAlign", void 0);
|
|
7900
7913
|
__decorate([
|
|
7901
|
-
strokeType(1)
|
|
7914
|
+
strokeType(1, true)
|
|
7902
7915
|
], exports.UI.prototype, "strokeWidth", void 0);
|
|
7903
7916
|
__decorate([
|
|
7904
7917
|
strokeType(false)
|
|
@@ -8325,7 +8338,7 @@ var LeaferUI = (function (exports) {
|
|
|
8325
8338
|
list.push(item);
|
|
8326
8339
|
this.requestRender();
|
|
8327
8340
|
}
|
|
8328
|
-
zoom(_zoomType,
|
|
8341
|
+
zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
|
|
8329
8342
|
return Plugin.need('view');
|
|
8330
8343
|
}
|
|
8331
8344
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
@@ -8370,7 +8383,7 @@ var LeaferUI = (function (exports) {
|
|
|
8370
8383
|
Leafer_1.list.remove(this);
|
|
8371
8384
|
try {
|
|
8372
8385
|
this.stop();
|
|
8373
|
-
this.
|
|
8386
|
+
this.emitLeafer(LeaferEvent.END);
|
|
8374
8387
|
this.__removeListenEvents();
|
|
8375
8388
|
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
8376
8389
|
this.__controllers.length = 0;
|
|
@@ -8498,7 +8511,7 @@ var LeaferUI = (function (exports) {
|
|
|
8498
8511
|
}
|
|
8499
8512
|
__drawContent(canvas, options) {
|
|
8500
8513
|
this.__renderGroup(canvas, options);
|
|
8501
|
-
if (this.__.
|
|
8514
|
+
if (this.__.__useStroke) {
|
|
8502
8515
|
canvas.setWorld(this.__nowWorld);
|
|
8503
8516
|
this.__drawRenderPath(canvas);
|
|
8504
8517
|
}
|
|
@@ -8718,8 +8731,8 @@ var LeaferUI = (function (exports) {
|
|
|
8718
8731
|
for (let i = 1; i < sides; i++) {
|
|
8719
8732
|
lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
|
|
8720
8733
|
}
|
|
8734
|
+
closePath$1(path);
|
|
8721
8735
|
}
|
|
8722
|
-
closePath$1(path);
|
|
8723
8736
|
}
|
|
8724
8737
|
__updateRenderPath() { }
|
|
8725
8738
|
__updateBoxBounds() { }
|
|
@@ -8953,10 +8966,15 @@ var LeaferUI = (function (exports) {
|
|
|
8953
8966
|
const box = this.__box;
|
|
8954
8967
|
if (box)
|
|
8955
8968
|
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8956
|
-
if (this.textEditing && !
|
|
8969
|
+
if (this.textEditing && !options.exporting)
|
|
8957
8970
|
return;
|
|
8958
8971
|
super.__draw(canvas, options, originCanvas);
|
|
8959
8972
|
}
|
|
8973
|
+
__drawShape(canvas, options) {
|
|
8974
|
+
if (options.shape)
|
|
8975
|
+
this.__box && this.__box.__drawShape(canvas, options);
|
|
8976
|
+
super.__drawShape(canvas, options);
|
|
8977
|
+
}
|
|
8960
8978
|
destroy() {
|
|
8961
8979
|
if (this.boxStyle)
|
|
8962
8980
|
this.boxStyle = null;
|
|
@@ -9417,7 +9435,7 @@ var LeaferUI = (function (exports) {
|
|
|
9417
9435
|
};
|
|
9418
9436
|
|
|
9419
9437
|
let origin = {};
|
|
9420
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
|
|
9438
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
|
|
9421
9439
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9422
9440
|
const transform = get$3();
|
|
9423
9441
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -9426,13 +9444,15 @@ var LeaferUI = (function (exports) {
|
|
|
9426
9444
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
9427
9445
|
data.transform = transform;
|
|
9428
9446
|
}
|
|
9429
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
9447
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
|
|
9430
9448
|
const transform = get$3();
|
|
9431
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
9432
|
-
if (scaleX)
|
|
9433
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
9434
9449
|
if (rotation)
|
|
9435
9450
|
rotate(transform, rotation);
|
|
9451
|
+
if (skew)
|
|
9452
|
+
skewHelper(transform, skew.x, skew.y);
|
|
9453
|
+
if (scaleX)
|
|
9454
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
9455
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
9436
9456
|
data.transform = transform;
|
|
9437
9457
|
}
|
|
9438
9458
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -9469,11 +9489,13 @@ var LeaferUI = (function (exports) {
|
|
|
9469
9489
|
const tempScaleData = {};
|
|
9470
9490
|
const tempImage = {};
|
|
9471
9491
|
function createData(leafPaint, image, paint, box) {
|
|
9472
|
-
const { changeful, sync } = paint;
|
|
9492
|
+
const { changeful, sync, editing } = paint;
|
|
9473
9493
|
if (changeful)
|
|
9474
9494
|
leafPaint.changeful = changeful;
|
|
9475
9495
|
if (sync)
|
|
9476
9496
|
leafPaint.sync = sync;
|
|
9497
|
+
if (editing)
|
|
9498
|
+
leafPaint.editing = editing;
|
|
9477
9499
|
leafPaint.data = getPatternData(paint, box, image);
|
|
9478
9500
|
}
|
|
9479
9501
|
function getPatternData(paint, box, image) {
|
|
@@ -9482,7 +9504,7 @@ var LeaferUI = (function (exports) {
|
|
|
9482
9504
|
if (paint.mode === 'strench')
|
|
9483
9505
|
paint.mode = 'stretch';
|
|
9484
9506
|
let { width, height } = image;
|
|
9485
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
9507
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
|
|
9486
9508
|
const sameBox = box.width === width && box.height === height;
|
|
9487
9509
|
const data = { mode };
|
|
9488
9510
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -9516,8 +9538,8 @@ var LeaferUI = (function (exports) {
|
|
|
9516
9538
|
break;
|
|
9517
9539
|
case 'normal':
|
|
9518
9540
|
case 'clip':
|
|
9519
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
9520
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
9541
|
+
if (tempImage.x || tempImage.y || scaleX || rotation || skew)
|
|
9542
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
|
|
9521
9543
|
break;
|
|
9522
9544
|
case 'repeat':
|
|
9523
9545
|
if (!sameBox || scaleX || rotation)
|
|
@@ -9594,11 +9616,11 @@ var LeaferUI = (function (exports) {
|
|
|
9594
9616
|
}
|
|
9595
9617
|
onLoadSuccess(ui, event);
|
|
9596
9618
|
}
|
|
9597
|
-
leafPaint.loadId =
|
|
9619
|
+
leafPaint.loadId = undefined;
|
|
9598
9620
|
}, (error) => {
|
|
9599
9621
|
ignoreRender(ui, false);
|
|
9600
9622
|
onLoadError(ui, event, error);
|
|
9601
|
-
leafPaint.loadId =
|
|
9623
|
+
leafPaint.loadId = undefined;
|
|
9602
9624
|
});
|
|
9603
9625
|
if (ui.placeholderColor) {
|
|
9604
9626
|
if (!ui.placeholderDelay)
|
|
@@ -9664,6 +9686,8 @@ var LeaferUI = (function (exports) {
|
|
|
9664
9686
|
const { image, data } = paint;
|
|
9665
9687
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
9666
9688
|
if (sx) {
|
|
9689
|
+
sx = abs$1(sx);
|
|
9690
|
+
sy = abs$1(sy);
|
|
9667
9691
|
imageMatrix = get$1();
|
|
9668
9692
|
copy$1(imageMatrix, transform);
|
|
9669
9693
|
scale(imageMatrix, 1 / sx, 1 / sy);
|
package/dist/web.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>{const i=s(e),o=t.toDataURL(i,n);return"image/bmp"===i?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:m}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){t.list.forEach(h)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=new t.Bounds(s);i.save(),s.spread(x.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,o),this.renderBounds=n=n||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function b(t,e){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,n){switch(e.__.strokeAlign){case"center":R(t,1,e,n);break;case"inside":L(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,n):L(t,"outside",e,n)}}function R(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?S(t,!0,n,i):P(n,i)}function L(t,e,n,i){const s=i.getSameCanvas(!0,!0);s.font=n.__.__font,R(t,2,n,s),s.blendMode="outside"===e?"destination-out":"destination-in",b(n,s),s.blendMode="normal",k(i,s,n),s.recycle(n.__nowWorld)}function k(e,n,i){i.__worldFlipped||t.Platform.fullImageShadow?e.copyWorldByReset(n,i.__nowWorld):e.copyWorldToInner(n,i.__nowWorld,i.__layout.renderBounds)}function P(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function S(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?P(i,s):s.stroke(),s.restoreBlendMode()):n?P(i,s):s.stroke())}function C(t,e,n){const i=e.__;if(i.__strokeWidth)if(i.__font)B(t,e,n);else switch(i.strokeAlign){case"center":A(t,1,e,n);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),A(t,2,e,n),n.restore()}(t,e,n);break;case"outside":!function(t,e,n){const i=e.__;if(i.__fillAfterStroke)A(t,2,e,n);else{const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),A(t,2,e,o),o.clipUI(i),o.clearWorld(s),k(n,o,e),o.recycle(e.__nowWorld)}}(t,e,n)}}function A(t,n,i,s){const o=i.__;s.setStroke(!o.__isStrokes&&t,o.__strokeWidth*n,o),o.__isStrokes?S(t,!1,i,s):s.stroke(),o.__useArrow&&e.Paint.strokeArrow(t,i,s)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:O,getOuterOf:T,getByMove:I,getIntersectData:W}=t.BoundsHelper;let D;const{stintSet:M}=t.DataHelper,{hasTransparent:z}=e.ColorConvert;function H(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;let s;const{boxBounds:o}=i.__layout;switch(n.type){case"image":s=e.PaintImage.image(i,t,n,o,!D||!D[n.url]);break;case"linear":s=e.PaintGradient.linearGradient(n,o);break;case"radial":s=e.PaintGradient.radialGradient(n,o);break;case"angular":s=e.PaintGradient.conicGradient(n,o);break;case"solid":const{type:a,color:r,opacity:l}=n;s={type:a,style:e.ColorConvert.string(r,l)};break;default:void 0!==n.r&&(s={type:"solid",style:e.ColorConvert.string(n)})}return s&&("string"==typeof s.style&&z(s.style)&&(s.isTransparent=!0),n.blendMode&&(s.blendMode=n.blendMode)),s}const F={compute:function(t,n){const i=n.__,s=[];let o,a,r=i.__input[t];r instanceof Array||(r=[r]),D=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)(e=H(t,r[i],n))&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),a=!0),"fill"===t?(M(i,"__isAlphaPixelFill",o),M(i,"__isTransparentFill",a)):(M(i,"__isAlphaPixelStroke",o),M(i,"__isTransparentStroke",a))},fill:function(t,e,n){n.fillStyle=t,E(e,n)},fills:function(t,n,i){let s;for(let o=0,a=t.length;o<a;o++){if(s=t[o],s.image){if(e.PaintImage.checkImage(n,i,s,!n.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&n.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),E(n,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),E(n,i),i.restoreBlendMode()):E(n,i)}},fillPathOrText:E,fillText:b,stroke:C,strokes:function(t,e,n){C(t,e,n)},strokeText:B,drawTextStroke:P,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=W(i?O(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=T(s,a),o=I(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let G={};const{get:U,rotateOfOuter:j,translate:V,scaleOfOuter:Y,scale:N,rotate:q}=t.MatrixHelper;function X(t,e,n,i,s,o,a){const r=U();V(r,e.x+n,e.y+i),N(r,s,o),a&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Q(t,e,n,i,s,o,a){const r=U();V(r,e.x+n,e.y+i),s&&N(r,s,o),a&&q(r,a),t.transform=r}function K(t,e,n,i,s,o,a,r,l,d){const c=U();if(l)if("center"===d)j(c,{x:n/2,y:i/2},l);else switch(q(c,l),l){case 90:V(c,i,0);break;case 180:V(c,n,i);break;case 270:V(c,0,n)}G.x=e.x+s,G.y=e.y+o,V(c,G.x,G.y),a&&Y(c,G,a,r),t.transform=c}const{get:Z,translate:$}=t.MatrixHelper,J=new t.Bounds,tt={},et={};function nt(t,e,n,i){const{changeful:s,sync:o}=n;s&&(t.changeful=s),o&&(t.sync=o),t.data=it(n,i,e)}function it(e,n,i){e.padding&&(n=J.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:o}=i;const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===o,_={mode:r},m="center"!==l&&(u||0)%180==90;let w,y;switch(t.BoundsHelper.set(et,0,0,m?o:s,m?s:o),r&&"cover"!==r&&"fit"!==r?((c||h)&&(t.MathHelper.getScaleData(c,h,i,tt),w=tt.scaleX,y=tt.scaleY),l&&(w&&t.BoundsHelper.scale(et,w,y,!0),t.AlignHelper.toPoint(l,et,n,et,!0,!0))):g&&!u||(w=y=t.BoundsHelper.getFitScale(n,et,"fit"!==r),t.BoundsHelper.put(n,i,l,w,!1,et),t.BoundsHelper.scale(et,w,y,!0)),d&&t.PointHelper.move(et,d),r){case"stretch":g||(s=n.width,o=n.height);break;case"normal":case"clip":(et.x||et.y||w||u)&&Q(_,n,et.x,et.y,w,y,u);break;case"repeat":(!g||w||u)&&K(_,n,s,o,et.x,et.y,w,y,u,l),f||(_.repeat="repeat");break;default:w&&X(_,n,et.x,et.y,w,y,u)}return _.transform||(n.x||n.y)&&(_.transform=Z(),$(_.transform,n.x,n.y)),w&&"stretch"!==r&&(_.scaleX=w,_.scaleY=y),_.width=s,_.height=o,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let st,ot=new t.Bounds;const{isSame:at}=t.BoundsHelper;function rt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||nt(s,i,n,o),!0}function lt(e,n){ht(e,t.ImageEvent.LOAD,n)}function dt(e,n){ht(e,t.ImageEvent.LOADED,n)}function ct(e,n,i){n.error=i,e.forceUpdate("surface"),ht(e,t.ImageEvent.ERROR,n)}function ht(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ft,scale:pt,copy:gt}=t.MatrixHelper,{ceil:_t,abs:mt}=Math;function wt(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=mt(s),o=mt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=ft(),gt(d,p),pt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(d||(d=ft(),p&>(d,p)),pt(d,1/s,1/o));const w=e.getCanvas(_t(c)||1,_t(h)||1,r.opacity,r.filters),y=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function yt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:vt}=Math;const xt={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return st&&i===st.paint&&at(s,st.boxBounds)?a=st.leafPaint:(a={type:i.type,image:l},l.hasAlphaPixel&&(a.isTransparent=!0),st=l.use>1?{leafPaint:a,paint:i,boxBounds:ot.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(rt(e,n,i,l,a,s),o&&(lt(e,r),dt(e,r))):l.error?o&&ct(e,r,l.error):(o&&(ut(e,!0),lt(e,r)),a.loadId=l.load((()=>{ut(e,!1),e.destroyed||(rt(e,n,i,l,a,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),dt(e,r)),a.loadId=null}),(t=>{ut(e,!1),ct(e,r,t),a.loadId=null})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;if(o)if(d.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=vt(a)*l,n*=vt(r)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(function(t,e,n,i){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,d),!0):(!s.style||s.sync||e.Export.running?wt(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>yt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&wt(n,s,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:wt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r,l;for(let d=0,c=i.length;d<c;d++)s=i[d],o=s.image,l=o&&o.url,l&&(a||(a={}),a[l]=!0,t.ImageManager.recycle(o),o.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),o.unload(i[d].loadId,!r.some((t=>t.url===l)))));return a}return null},createData:nt,getPatternData:it,fillOrFitMode:X,clipMode:Q,repeatMode:K},{toPoint:bt}=t.AroundHelper,{hasTransparent:Et}=e.ColorConvert,Bt={},Rt={};function Lt(t,n,i,s){if(i){let o,a,r,l;for(let t=0,d=i.length;t<d;t++)o=i[t],"string"==typeof o?(r=t/(d-1),a=e.ColorConvert.string(o,s)):(r=o.offset,a=e.ColorConvert.string(o.color,s)),n.addColorStop(r,a),!l&&Et(a)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:kt,getDistance:Pt}=t.PointHelper,{get:St,rotateOfOuter:Ct,scaleOfOuter:At}=t.MatrixHelper,{toPoint:Ot}=t.AroundHelper,Tt={},It={};function Wt(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=kt(e,n);o=St(),s?(At(o,e,a/r*(i||1),1),Ct(o,e,t+90)):(At(o,e,1,a/r*(i||1)),Ct(o,e,t))}return o}const{getDistance:Dt}=t.PointHelper,{toPoint:Mt}=t.AroundHelper,zt={},Ht={};const Ft={linearGradient:function(e,n){let{from:i,to:s,type:o,opacity:a}=e;bt(i||"top",n,Bt),bt(s||"bottom",n,Rt);const r=t.Platform.canvas.createLinearGradient(Bt.x,Bt.y,Rt.x,Rt.y),l={type:o,style:r};return Lt(l,r,e.stops,a),l},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,stretch:r}=e;Ot(i||"center",n,Tt),Ot(s||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Pt(Tt,It)),d={type:o,style:l};Lt(d,l,e.stops,a);const c=Wt(n,Tt,It,r,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,stretch:r}=e;Mt(i||"center",n,zt),Mt(s||"bottom",n,Ht);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,zt.x,zt.y):t.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Dt(zt,Ht)),d={type:o,style:l};Lt(d,l,e.stops,a);const c=Wt(n,zt,Ht,r||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Wt},{copy:Gt,toOffsetOutBounds:Ut}=t.BoundsHelper,jt={},Vt={};function Yt(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Gt(jt,e.bounds),jt.x+=n.x-a.x,jt.y+=n.y-a.y,i){const{matrix:t}=s;jt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),jt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),jt.width*=i,jt.height*=i}e.copyWorld(s.canvas,e.bounds,jt)}else i&&(Gt(jt,n),jt.x-=n.width/2*(i-1),jt.y-=n.height/2*(i-1),jt.width*=i,jt.height*=i),e.copyWorld(s.canvas,a,i?jt:n)}const{toOffsetOutBounds:Nt}=t.BoundsHelper,qt={};const Xt={shadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Ut(c,Vt),l.forEach(((l,_)=>{p.setWorldShadow(Vt.offsetX+l.x*u,Vt.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Vt,o,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,a,"copy"),s=a),d?p.copyWorld(d,a,a,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,a,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Nt(c,qt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(qt.offsetX+l.x*u,qt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,qt,o,i),p.restore(),d?(p.copyWorld(p,c,a,"copy"),p.copyWorld(d,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,a,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Qt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,o);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(a&&(Kt(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Zt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Qt(n,e)||n.__render(s||t,e);Kt(this,a,t,s,i,o)};const Jt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",te=Jt+"_#~&*+\\=|≮≯≈≠=…",ee=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ie=ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),se=ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=ne(Jt),ae=ne(te),re=ne("- —/~|┆·");var le;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(le||(le={}));const{Letter:de,Single:ce,Before:he,After:ue,Symbol:fe,Break:pe}=le;function ge(t){return ie[t]?de:re[t]?pe:se[t]?he:oe[t]?ue:ae[t]?fe:ee.test(t)?ce:de}const _e={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:we}=_e,{Letter:ye,Single:ve,Before:xe,After:be,Symbol:Ee,Break:Be}=le;let Re,Le,ke,Pe,Se,Ce,Ae,Oe,Te,Ie,We,De,Me,ze,He,Fe,Ge,Ue=[];function je(t,e){Te&&!Oe&&(Oe=Te),Re.data.push({char:t,width:e}),ke+=e}function Ve(){Pe+=ke,Re.width=ke,Le.words.push(Re),Re={data:[]},ke=0}function Ye(){ze&&(He.paraNumber++,Le.paraStart=!0,ze=!1),Te&&(Le.startCharSize=Oe,Le.endCharSize=Te,Oe=0),Le.width=Pe,Fe.width?we(Le):Ge&&Ne(),Ue.push(Le),Le={words:[]},Pe=0}function Ne(){Pe>(He.maxWidth||0)&&(He.maxWidth=Pe)}const{top:qe,right:Xe,bottom:Qe,left:Ke}=t.Direction4;function Ze(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const $e={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,o=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(a?(s=c[Ke],a-=c[Xe]+c[Ke]):i.autoSizeAlign||(s=c[Ke]),r?(o=c[qe],r-=c[qe]+c[Qe]):i.autoSizeAlign||(o=c[qe]));const h={bounds:{x:s,y:o,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){He=e,Ue=e.rows,Fe=e.bounds,Ge=!Fe.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Fe;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;ze=!0,We=null,Oe=Ae=Te=ke=Pe=0,Re={data:[]},Le={words:[]},s&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Ce=n[i],"\n"===Ce?(ke&&Ve(),Le.paraEnd=!0,Ye(),ze=!0):(Ie=ge(Ce),Ie===ye&&"none"!==a&&(Ce=me(Ce,a,!ke)),Ae=r.measureText(Ce).width,s&&(s<0&&(Te=Ae),Ae+=s),De=Ie===ve&&(We===ve||We===ye)||We===ve&&Ie!==be,Me=!(Ie!==xe&&Ie!==ve||We!==Ee&&We!==be),Se=ze&&o?l-o:l,t&&l&&Pe+ke+Ae>Se&&(e?(ke&&Ve(),Pe&&Ye()):(Me||(Me=Ie===ye&&We==be),De||Me||Ie===Be||Ie===xe||Ie===ve||ke+Ae>Se?(ke&&Ve(),Pe&&Ye()):Pe&&Ye()))," "===Ce&&!0!==ze&&Pe+ke===0||(Ie===Be?(" "===Ce&&ke&&Ve(),je(Ce,Ae),Ve()):De||Me?(ke&&Ve(),je(Ce,Ae)):je(Ce,Ae)),We=Ie);ke&&Ve(),Pe&&Ye(),Ue.length>0&&(Ue[Ue.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{He.paraNumber++,Pe=r.measureText(t).width,Ue.push({x:o||0,text:t,width:Pe,paraStart:!0}),Ge&&Ne()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ze(e,"x",t[Ke]);break;case"right":Ze(e,"x",-t[Xe])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ze(e,"y",t[qe]);break;case"bottom":Ze(e,"y",-t[Qe])}}(c,h,i,a,r),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,m=o*s+(h?h*(t.paraNumber-1):0),w=a;if(l&&m>_)m=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let a=0,c=s;a<c;a++){if(y=n[a],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=o,t.overflow>a&&w>m&&(y.isOverflow=!0,t.overflow=a+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||n===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,a),"none"!==l&&function(t,n){let i;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,"object"==typeof o?(i=o.type,o.color&&(t.decorationColor=e.ColorConvert.string(o.color))):i=o,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Je={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(e.TextConvert,$e),Object.assign(e.ColorConvert,Je),Object.assign(e.Paint,F),Object.assign(e.PaintImage,xt),Object.assign(e.PaintGradient,Ft),Object.assign(e.Effect,Xt),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}})}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>{const i=s(e),o=t.toDataURL(i,n);return"image/bmp"===i?o.replace("image/png;","image/bmp;"):o},canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new t.Platform.origin.Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("AppleWebKit")>-1&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:m}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){t.list.forEach(h)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=new t.Bounds(s);i.save(),s.spread(x.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),o=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,o),this.renderBounds=n=n||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function b(t,e){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,n){switch(e.__.strokeAlign){case"center":R(t,1,e,n);break;case"inside":L(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,n):L(t,"outside",e,n)}}function R(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?S(t,!0,n,i):P(n,i)}function L(t,e,n,i){const s=i.getSameCanvas(!0,!0);s.font=n.__.__font,R(t,2,n,s),s.blendMode="outside"===e?"destination-out":"destination-in",b(n,s),s.blendMode="normal",k(i,s,n),s.recycle(n.__nowWorld)}function k(e,n,i){i.__worldFlipped||t.Platform.fullImageShadow?e.copyWorldByReset(n,i.__nowWorld):e.copyWorldToInner(n,i.__nowWorld,i.__layout.renderBounds)}function P(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:o}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)}));if(o){const{decorationHeight:t}=i;s.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function S(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?P(i,s):s.stroke(),s.restoreBlendMode()):n?P(i,s):s.stroke())}function C(t,e,n){const i=e.__;if(i.__strokeWidth)if(i.__font)B(t,e,n);else switch(i.strokeAlign){case"center":A(t,1,e,n);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),A(t,2,e,n),n.restore()}(t,e,n);break;case"outside":!function(t,e,n){const i=e.__;if(i.__fillAfterStroke)A(t,2,e,n);else{const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),A(t,2,e,o),o.clipUI(i),o.clearWorld(s),k(n,o,e),o.recycle(e.__nowWorld)}}(t,e,n)}}function A(t,n,i,s){const o=i.__;s.setStroke(!o.__isStrokes&&t,o.__strokeWidth*n,o),o.__isStrokes?S(t,!1,i,s):s.stroke(),o.__useArrow&&e.Paint.strokeArrow(t,i,s)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:O,getOuterOf:T,getByMove:I,getIntersectData:W}=t.BoundsHelper;let D;const{stintSet:M}=t.DataHelper,{hasTransparent:z}=e.ColorConvert;function H(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;let s;const{boxBounds:o}=i.__layout;switch(n.type){case"image":s=e.PaintImage.image(i,t,n,o,!D||!D[n.url]);break;case"linear":s=e.PaintGradient.linearGradient(n,o);break;case"radial":s=e.PaintGradient.radialGradient(n,o);break;case"angular":s=e.PaintGradient.conicGradient(n,o);break;case"solid":const{type:a,color:r,opacity:l}=n;s={type:a,style:e.ColorConvert.string(r,l)};break;default:void 0!==n.r&&(s={type:"solid",style:e.ColorConvert.string(n)})}return s&&("string"==typeof s.style&&z(s.style)&&(s.isTransparent=!0),n.blendMode&&(s.blendMode=n.blendMode)),s}const F={compute:function(t,n){const i=n.__,s=[];let o,a,r=i.__input[t];r instanceof Array||(r=[r]),D=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=r.length;i<o;i++)(e=H(t,r[i],n))&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),a=!0),"fill"===t?(M(i,"__isAlphaPixelFill",o),M(i,"__isTransparentFill",a)):(M(i,"__isAlphaPixelStroke",o),M(i,"__isTransparentStroke",a))},fill:function(t,e,n){n.fillStyle=t,E(e,n)},fills:function(t,n,i){let s;for(let o=0,a=t.length;o<a;o++){if(s=t[o],s.image){if(e.PaintImage.checkImage(n,i,s,!n.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&n.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),E(n,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),E(n,i),i.restoreBlendMode()):E(n,i)}},fillPathOrText:E,fillText:b,stroke:C,strokes:function(t,e,n){C(t,e,n)},strokeText:B,drawTextStroke:P,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=W(i?O(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=T(s,a),o=I(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let G={};const{get:U,rotateOfOuter:j,translate:V,scaleOfOuter:Y,scale:N,rotate:q,skew:X}=t.MatrixHelper;function Q(t,e,n,i,s,o,a){const r=U();V(r,e.x+n,e.y+i),N(r,s,o),a&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function K(t,e,n,i,s,o,a,r){const l=U();a&&q(l,a),r&&X(l,r.x,r.y),s&&N(l,s,o),V(l,e.x+n,e.y+i),t.transform=l}function Z(t,e,n,i,s,o,a,r,l,d){const c=U();if(l)if("center"===d)j(c,{x:n/2,y:i/2},l);else switch(q(c,l),l){case 90:V(c,i,0);break;case 180:V(c,n,i);break;case 270:V(c,0,n)}G.x=e.x+s,G.y=e.y+o,V(c,G.x,G.y),a&&Y(c,G,a,r),t.transform=c}const{get:$,translate:J}=t.MatrixHelper,tt=new t.Bounds,et={},nt={};function it(t,e,n,i){const{changeful:s,sync:o,editing:a}=n;s&&(t.changeful=s),o&&(t.sync=o),a&&(t.editing=a),t.data=st(n,i,e)}function st(e,n,i){e.padding&&(n=tt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:o}=i;const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,repeat:p,filters:g}=e,_=n.width===s&&n.height===o,m={mode:r},w="center"!==l&&(u||0)%180==90;let y,v;switch(t.BoundsHelper.set(nt,0,0,w?o:s,w?s:o),r&&"cover"!==r&&"fit"!==r?((c||h)&&(t.MathHelper.getScaleData(c,h,i,et),y=et.scaleX,v=et.scaleY),l&&(y&&t.BoundsHelper.scale(nt,y,v,!0),t.AlignHelper.toPoint(l,nt,n,nt,!0,!0))):_&&!u||(y=v=t.BoundsHelper.getFitScale(n,nt,"fit"!==r),t.BoundsHelper.put(n,i,l,y,!1,nt),t.BoundsHelper.scale(nt,y,v,!0)),d&&t.PointHelper.move(nt,d),r){case"stretch":_||(s=n.width,o=n.height);break;case"normal":case"clip":(nt.x||nt.y||y||u||f)&&K(m,n,nt.x,nt.y,y,v,u,f);break;case"repeat":(!_||y||u)&&Z(m,n,s,o,nt.x,nt.y,y,v,u,l),p||(m.repeat="repeat");break;default:y&&Q(m,n,nt.x,nt.y,y,v,u)}return m.transform||(n.x||n.y)&&(m.transform=$(),J(m.transform,n.x,n.y)),y&&"stretch"!==r&&(m.scaleX=y,m.scaleY=v),m.width=s,m.height=o,a&&(m.opacity=a),g&&(m.filters=g),p&&(m.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat"),m}let ot,at=new t.Bounds;const{isSame:rt}=t.BoundsHelper;function lt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||it(s,i,n,o),!0}function dt(e,n){ut(e,t.ImageEvent.LOAD,n)}function ct(e,n){ut(e,t.ImageEvent.LOADED,n)}function ht(e,n,i){n.error=i,e.forceUpdate("surface"),ut(e,t.ImageEvent.ERROR,n)}function ut(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ft(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:pt,scale:gt,copy:_t}=t.MatrixHelper,{ceil:mt,abs:wt}=Math;function yt(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=wt(s),o=wt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(u=wt(u),f=wt(f),d=pt(),_t(d,p),gt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(d||(d=pt(),p&&_t(d,p)),gt(d,1/s,1/o));const w=e.getCanvas(mt(c)||1,mt(h)||1,r.opacity,r.filters),y=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function vt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:xt}=Math;const bt={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return ot&&i===ot.paint&&rt(s,ot.boxBounds)?a=ot.leafPaint:(a={type:i.type,image:l},l.hasAlphaPixel&&(a.isTransparent=!0),ot=l.use>1?{leafPaint:a,paint:i,boxBounds:at.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(lt(e,n,i,l,a,s),o&&(dt(e,r),ct(e,r))):l.error?o&&ht(e,r,l.error):(o&&(ft(e,!0),dt(e,r)),a.loadId=l.load((()=>{ft(e,!1),e.destroyed||(lt(e,n,i,l,a,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ct(e,r)),a.loadId=void 0}),(t=>{ft(e,!1),ht(e,r,t),a.loadId=void 0})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;if(o)if(d.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=xt(a)*l,n*=xt(r)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(function(t,e,n,i){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,d),!0):(!s.style||s.sync||e.Export.running?yt(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>vt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&yt(n,s,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:yt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r,l;for(let d=0,c=i.length;d<c;d++)s=i[d],o=s.image,l=o&&o.url,l&&(a||(a={}),a[l]=!0,t.ImageManager.recycle(o),o.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),o.unload(i[d].loadId,!r.some((t=>t.url===l)))));return a}return null},createData:it,getPatternData:st,fillOrFitMode:Q,clipMode:K,repeatMode:Z},{toPoint:Et}=t.AroundHelper,{hasTransparent:Bt}=e.ColorConvert,Rt={},Lt={};function kt(t,n,i,s){if(i){let o,a,r,l;for(let t=0,d=i.length;t<d;t++)o=i[t],"string"==typeof o?(r=t/(d-1),a=e.ColorConvert.string(o,s)):(r=o.offset,a=e.ColorConvert.string(o.color,s)),n.addColorStop(r,a),!l&&Bt(a)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Pt,getDistance:St}=t.PointHelper,{get:Ct,rotateOfOuter:At,scaleOfOuter:Ot}=t.MatrixHelper,{toPoint:Tt}=t.AroundHelper,It={},Wt={};function Dt(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=Pt(e,n);o=Ct(),s?(Ot(o,e,a/r*(i||1),1),At(o,e,t+90)):(Ot(o,e,1,a/r*(i||1)),At(o,e,t))}return o}const{getDistance:Mt}=t.PointHelper,{toPoint:zt}=t.AroundHelper,Ht={},Ft={};const Gt={linearGradient:function(e,n){let{from:i,to:s,type:o,opacity:a}=e;Et(i||"top",n,Rt),Et(s||"bottom",n,Lt);const r=t.Platform.canvas.createLinearGradient(Rt.x,Rt.y,Lt.x,Lt.y),l={type:o,style:r};return kt(l,r,e.stops,a),l},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,stretch:r}=e;Tt(i||"center",n,It),Tt(s||"bottom",n,Wt);const l=t.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,St(It,Wt)),d={type:o,style:l};kt(d,l,e.stops,a);const c=Dt(n,It,Wt,r,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,stretch:r}=e;zt(i||"center",n,Ht),zt(s||"bottom",n,Ft);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ht.x,Ht.y):t.Platform.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Mt(Ht,Ft)),d={type:o,style:l};kt(d,l,e.stops,a);const c=Dt(n,Ht,Ft,r||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Dt},{copy:Ut,toOffsetOutBounds:jt}=t.BoundsHelper,Vt={},Yt={};function Nt(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Ut(Vt,e.bounds),Vt.x+=n.x-a.x,Vt.y+=n.y-a.y,i){const{matrix:t}=s;Vt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Vt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Vt.width*=i,Vt.height*=i}e.copyWorld(s.canvas,e.bounds,Vt)}else i&&(Ut(Vt,n),Vt.x-=n.width/2*(i-1),Vt.y-=n.height/2*(i-1),Vt.width*=i,Vt.height*=i),e.copyWorld(s.canvas,a,i?Vt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Xt={};const Qt={shadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;jt(c,Yt),l.forEach(((l,_)=>{p.setWorldShadow(Yt.offsetX+l.x*u,Yt.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Nt(p,Yt,o,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,a,"copy"),s=a),d?p.copyWorld(d,a,a,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,a,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;qt(c,Xt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Xt.offsetX+l.x*u,Xt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Nt(p,Xt,o,i),p.restore(),d?(p.copyWorld(p,c,a,"copy"),p.copyWorld(d,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,a,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Kt}=t.LeafBoundsHelper;function Zt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Jt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Jt(t,n,i,o);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function Jt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(a&&(Zt(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=$t(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Kt(n,e)||n.__render(s||t,e);Zt(this,a,t,s,i,o)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oe=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ae=ie(te),re=ie(ee),le=ie("- —/~|┆·");var de;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(de||(de={}));const{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=de;function _e(t){return se[t]?ce:le[t]?ge:oe[t]?ue:ae[t]?fe:re[t]?pe:ne.test(t)?he:ce}const me={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function we(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ye}=me,{Letter:ve,Single:xe,Before:be,After:Ee,Symbol:Be,Break:Re}=de;let Le,ke,Pe,Se,Ce,Ae,Oe,Te,Ie,We,De,Me,ze,He,Fe,Ge,Ue,je=[];function Ve(t,e){Ie&&!Te&&(Te=Ie),Le.data.push({char:t,width:e}),Pe+=e}function Ye(){Se+=Pe,Le.width=Pe,ke.words.push(Le),Le={data:[]},Pe=0}function Ne(){He&&(Fe.paraNumber++,ke.paraStart=!0,He=!1),Ie&&(ke.startCharSize=Te,ke.endCharSize=Ie,Te=0),ke.width=Se,Ge.width?ye(ke):Ue&&qe(),je.push(ke),ke={words:[]},Se=0}function qe(){Se>(Fe.maxWidth||0)&&(Fe.maxWidth=Se)}const{top:Xe,right:Qe,bottom:Ke,left:Ze}=t.Direction4;function $e(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Je={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,o=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(a?(s=c[Ze],a-=c[Qe]+c[Ze]):i.autoSizeAlign||(s=c[Ze]),r?(o=c[Xe],r-=c[Xe]+c[Ke]):i.autoSizeAlign||(o=c[Xe]));const h={bounds:{x:s,y:o,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Fe=e,je=e.rows,Ge=e.bounds,Ue=!Ge.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ge;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;He=!0,De=null,Te=Oe=Ie=Pe=Se=0,Le={data:[]},ke={words:[]},s&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Ae=n[i],"\n"===Ae?(Pe&&Ye(),ke.paraEnd=!0,Ne(),He=!0):(We=_e(Ae),We===ve&&"none"!==a&&(Ae=we(Ae,a,!Pe)),Oe=r.measureText(Ae).width,s&&(s<0&&(Ie=Oe),Oe+=s),Me=We===xe&&(De===xe||De===ve)||De===xe&&We!==Ee,ze=!(We!==be&&We!==xe||De!==Be&&De!==Ee),Ce=He&&o?l-o:l,t&&l&&Se+Pe+Oe>Ce&&(e?(Pe&&Ye(),Se&&Ne()):(ze||(ze=We===ve&&De==Ee),Me||ze||We===Re||We===be||We===xe||Pe+Oe>Ce?(Pe&&Ye(),Se&&Ne()):Se&&Ne()))," "===Ae&&!0!==He&&Se+Pe===0||(We===Re?(" "===Ae&&Pe&&Ye(),Ve(Ae,Oe),Ye()):Me||ze?(Pe&&Ye(),Ve(Ae,Oe)):Ve(Ae,Oe)),De=We);Pe&&Ye(),Se&&Ne(),je.length>0&&(je[je.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Fe.paraNumber++,Se=r.measureText(t).width,je.push({x:o||0,text:t,width:Se,paraStart:!0}),Ue&&qe()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":$e(e,"x",t[Ze]);break;case"right":$e(e,"x",-t[Qe])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":$e(e,"y",t[Xe]);break;case"bottom":$e(e,"y",-t[Ke])}}(c,h,i,a,r),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,m=o*s+(h?h*(t.paraNumber-1):0),w=a;if(l&&m>_)m=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let a=0,c=s;a<c;a++){if(y=n[a],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=o,t.overflow>a&&w>m&&(y.isOverflow=!0,t.overflow=a+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||n===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,a),"none"!==l&&function(t,n){let i;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,"object"==typeof o?(i=o.type,o.color&&(t.decorationColor=e.ColorConvert.string(o.color))):i=o,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const tn={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(e.TextConvert,Je),Object.assign(e.ColorConvert,tn),Object.assign(e.Paint,F),Object.assign(e.PaintImage,bt),Object.assign(e.PaintGradient,Gt),Object.assign(e.Effect,Qt),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
2
2
|
//# sourceMappingURL=web.min.cjs.map
|