@leafer-ui/draw 1.7.0 → 1.8.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/lib/draw.cjs +58 -33
- package/lib/draw.esm.js +59 -35
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.esm.min.js.map +1 -1
- package/lib/draw.min.cjs +1 -1
- package/lib/draw.min.cjs.map +1 -1
- package/package.json +6 -6
package/lib/draw.cjs
CHANGED
|
@@ -64,6 +64,11 @@ function zoomLayerType() {
|
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
+
function createAttr(defaultValue) {
|
|
68
|
+
return (target, key) => {
|
|
69
|
+
core.defineKey(target, key, core.createDescriptor(key, defaultValue));
|
|
70
|
+
};
|
|
71
|
+
}
|
|
67
72
|
|
|
68
73
|
function hasTransparent$1(color) {
|
|
69
74
|
if (!color || color.length === 7 || color.length === 4)
|
|
@@ -121,22 +126,9 @@ const emptyPaint = {};
|
|
|
121
126
|
const debug$1 = core.Debug.get('UIData');
|
|
122
127
|
class UIData extends core.LeafData {
|
|
123
128
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
124
|
-
get __strokeWidth() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const ui = this.__leaf;
|
|
128
|
-
let { scaleX } = ui.__nowWorld || ui.__world;
|
|
129
|
-
if (scaleX < 0)
|
|
130
|
-
scaleX = -scaleX;
|
|
131
|
-
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
132
|
-
}
|
|
133
|
-
else
|
|
134
|
-
return strokeWidth;
|
|
135
|
-
}
|
|
136
|
-
get __hasMultiPaint() {
|
|
137
|
-
const t = this;
|
|
138
|
-
return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
|
|
139
|
-
}
|
|
129
|
+
get __strokeWidth() { return this.__getRealStrokeWidth(); }
|
|
130
|
+
get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
|
|
131
|
+
get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
|
|
140
132
|
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
141
133
|
get __hasSurface() { const t = this; return (t.fill || t.stroke); }
|
|
142
134
|
get __autoWidth() { return !this._width; }
|
|
@@ -218,6 +210,21 @@ class UIData extends core.LeafData {
|
|
|
218
210
|
Paint.compute('stroke', this.__leaf);
|
|
219
211
|
this.__needComputePaint = undefined;
|
|
220
212
|
}
|
|
213
|
+
__getRealStrokeWidth(childStyle) {
|
|
214
|
+
let { strokeWidth, strokeWidthFixed } = this;
|
|
215
|
+
if (childStyle) {
|
|
216
|
+
if (childStyle.strokeWidth)
|
|
217
|
+
strokeWidth = childStyle.strokeWidth;
|
|
218
|
+
if (childStyle.strokeWidthFixed !== undefined)
|
|
219
|
+
strokeWidthFixed = childStyle.strokeWidthFixed;
|
|
220
|
+
}
|
|
221
|
+
if (strokeWidthFixed) {
|
|
222
|
+
const scale = this.__leaf.getClampRenderScale();
|
|
223
|
+
return scale > 1 ? strokeWidth / scale : strokeWidth;
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
return strokeWidth;
|
|
227
|
+
}
|
|
221
228
|
__setPaint(attrName, value) {
|
|
222
229
|
this.__setInput(attrName, value);
|
|
223
230
|
const layout = this.__leaf.__layout;
|
|
@@ -242,6 +249,7 @@ class UIData extends core.LeafData {
|
|
|
242
249
|
}
|
|
243
250
|
else {
|
|
244
251
|
stintSet$1(this, '__isAlphaPixelStroke', undefined);
|
|
252
|
+
stintSet$1(this, '__hasMultiStrokeStyle', undefined);
|
|
245
253
|
this._stroke = this.__isStrokes = undefined;
|
|
246
254
|
}
|
|
247
255
|
}
|
|
@@ -263,8 +271,8 @@ class GroupData extends UIData {
|
|
|
263
271
|
|
|
264
272
|
class BoxData extends GroupData {
|
|
265
273
|
get __boxStroke() { return !this.__pathInputed; }
|
|
266
|
-
get __drawAfterFill() { const t = this; return
|
|
267
|
-
get __clipAfterFill() { return
|
|
274
|
+
get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
|
|
275
|
+
get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
|
|
268
276
|
}
|
|
269
277
|
|
|
270
278
|
class LeaferData extends GroupData {
|
|
@@ -384,7 +392,7 @@ class CanvasData extends RectData {
|
|
|
384
392
|
const UIBounds = {
|
|
385
393
|
__updateStrokeSpread() {
|
|
386
394
|
let width = 0, boxWidth = 0;
|
|
387
|
-
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
395
|
+
const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
|
|
388
396
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
389
397
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
390
398
|
if (!data.__boxStroke) {
|
|
@@ -404,13 +412,15 @@ const UIBounds = {
|
|
|
404
412
|
},
|
|
405
413
|
__updateRenderSpread() {
|
|
406
414
|
let width = 0;
|
|
407
|
-
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
415
|
+
const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
|
|
408
416
|
if (shadow)
|
|
409
417
|
shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
410
418
|
if (blur)
|
|
411
419
|
width = Math.max(width, blur);
|
|
412
420
|
if (filter)
|
|
413
421
|
width += Filter.getSpread(filter);
|
|
422
|
+
if (renderSpread)
|
|
423
|
+
width += renderSpread;
|
|
414
424
|
let shapeWidth = width = Math.ceil(width);
|
|
415
425
|
if (innerShadow)
|
|
416
426
|
innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
|
|
@@ -433,7 +443,7 @@ const UIRender = {
|
|
|
433
443
|
}
|
|
434
444
|
if (data.__useEffect) {
|
|
435
445
|
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
436
|
-
stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread &&
|
|
446
|
+
stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
437
447
|
data.__useEffect = !!(shadow || otherEffect);
|
|
438
448
|
}
|
|
439
449
|
data.__checkSingle();
|
|
@@ -540,17 +550,17 @@ const RectRender = {
|
|
|
540
550
|
if (__drawAfterFill)
|
|
541
551
|
this.__drawAfterFill(canvas, options);
|
|
542
552
|
if (stroke) {
|
|
543
|
-
const { strokeAlign, __strokeWidth } = this.__;
|
|
544
|
-
if (!
|
|
553
|
+
const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
|
|
554
|
+
if (!strokeWidth)
|
|
545
555
|
return;
|
|
546
|
-
canvas.setStroke(stroke,
|
|
547
|
-
const half =
|
|
556
|
+
canvas.setStroke(stroke, strokeWidth, this.__);
|
|
557
|
+
const half = strokeWidth / 2;
|
|
548
558
|
switch (strokeAlign) {
|
|
549
559
|
case 'center':
|
|
550
560
|
canvas.strokeRect(0, 0, width, height);
|
|
551
561
|
break;
|
|
552
562
|
case 'inside':
|
|
553
|
-
width -=
|
|
563
|
+
width -= strokeWidth, height -= strokeWidth;
|
|
554
564
|
if (width < 0 || height < 0) {
|
|
555
565
|
canvas.save();
|
|
556
566
|
this.__clip(canvas, options);
|
|
@@ -561,7 +571,7 @@ const RectRender = {
|
|
|
561
571
|
canvas.strokeRect(x + half, y + half, width, height);
|
|
562
572
|
break;
|
|
563
573
|
case 'outside':
|
|
564
|
-
canvas.strokeRect(x - half, y - half, width +
|
|
574
|
+
canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
|
|
565
575
|
break;
|
|
566
576
|
}
|
|
567
577
|
}
|
|
@@ -574,6 +584,8 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
574
584
|
get isFrame() { return false; }
|
|
575
585
|
set scale(value) { core.MathHelper.assignScale(this, value); }
|
|
576
586
|
get scale() { return this.__.scale; }
|
|
587
|
+
get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
|
|
588
|
+
get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
|
|
577
589
|
get pen() {
|
|
578
590
|
const { path } = this.__;
|
|
579
591
|
core.pen.set(this.path = path || []);
|
|
@@ -788,6 +800,9 @@ __decorate([
|
|
|
788
800
|
__decorate([
|
|
789
801
|
core.naturalBoundsType(1)
|
|
790
802
|
], exports.UI.prototype, "pixelRatio", void 0);
|
|
803
|
+
__decorate([
|
|
804
|
+
core.affectRenderBoundsType(0)
|
|
805
|
+
], exports.UI.prototype, "renderSpread", void 0);
|
|
791
806
|
__decorate([
|
|
792
807
|
core.pathInputType()
|
|
793
808
|
], exports.UI.prototype, "path", void 0);
|
|
@@ -944,7 +959,8 @@ exports.Group = class Group extends exports.UI {
|
|
|
944
959
|
}
|
|
945
960
|
toJSON(options) {
|
|
946
961
|
const data = super.toJSON(options);
|
|
947
|
-
|
|
962
|
+
if (!this.childlessJSON)
|
|
963
|
+
data.children = this.children.map(child => child.toJSON(options));
|
|
948
964
|
return data;
|
|
949
965
|
}
|
|
950
966
|
pick(_hitPoint, _options) { return undefined; }
|
|
@@ -1391,8 +1407,8 @@ exports.Box = class Box extends exports.Group {
|
|
|
1391
1407
|
__updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
|
|
1392
1408
|
__updateRectBoxBounds() { }
|
|
1393
1409
|
__updateBoxBounds(_secondLayout) {
|
|
1394
|
-
const data = this.__;
|
|
1395
1410
|
if (this.children.length && !this.pathInputed) {
|
|
1411
|
+
const data = this.__;
|
|
1396
1412
|
if (data.__autoSide) {
|
|
1397
1413
|
if (data.__hasSurface)
|
|
1398
1414
|
this.__extraUpdate();
|
|
@@ -1419,20 +1435,26 @@ exports.Box = class Box extends exports.Group {
|
|
|
1419
1435
|
__updateStrokeBounds() { }
|
|
1420
1436
|
__updateRenderBounds() {
|
|
1421
1437
|
let isOverflow;
|
|
1422
|
-
const { renderBounds } = this.__layout;
|
|
1423
1438
|
if (this.children.length) {
|
|
1439
|
+
const data = this.__, { renderBounds, boxBounds } = this.__layout;
|
|
1424
1440
|
super.__updateRenderBounds();
|
|
1425
1441
|
copy(childrenRenderBounds, renderBounds);
|
|
1426
1442
|
this.__updateRectRenderBounds();
|
|
1427
|
-
|
|
1428
|
-
|
|
1443
|
+
if (data.scrollY || data.scrollX) {
|
|
1444
|
+
childrenRenderBounds.x += data.scrollX;
|
|
1445
|
+
childrenRenderBounds.y += data.scrollY;
|
|
1446
|
+
}
|
|
1447
|
+
isOverflow = !includes$1(boxBounds, childrenRenderBounds);
|
|
1448
|
+
if (isOverflow && data.overflow !== 'hide')
|
|
1429
1449
|
add(renderBounds, childrenRenderBounds);
|
|
1430
1450
|
}
|
|
1431
1451
|
else
|
|
1432
1452
|
this.__updateRectRenderBounds();
|
|
1433
1453
|
core.DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
1454
|
+
this.__updateScrollBar();
|
|
1434
1455
|
}
|
|
1435
1456
|
__updateRectRenderBounds() { }
|
|
1457
|
+
__updateScrollBar() { }
|
|
1436
1458
|
__updateRectChange() { }
|
|
1437
1459
|
__updateChange() {
|
|
1438
1460
|
super.__updateChange();
|
|
@@ -1449,10 +1471,12 @@ exports.Box = class Box extends exports.Group {
|
|
|
1449
1471
|
if (this.children.length)
|
|
1450
1472
|
this.__renderGroup(canvas, options);
|
|
1451
1473
|
}
|
|
1474
|
+
if (this.scrollBar)
|
|
1475
|
+
this.scrollBar.__render(canvas, options);
|
|
1452
1476
|
}
|
|
1453
1477
|
__drawContent(canvas, options) {
|
|
1454
1478
|
this.__renderGroup(canvas, options);
|
|
1455
|
-
if (this.__.__useStroke) {
|
|
1479
|
+
if (this.__.__useStroke || this.__.__useEffect) {
|
|
1456
1480
|
canvas.setWorld(this.__nowWorld);
|
|
1457
1481
|
this.__drawRenderPath(canvas);
|
|
1458
1482
|
}
|
|
@@ -2104,6 +2128,7 @@ exports.UIBounds = UIBounds;
|
|
|
2104
2128
|
exports.UIData = UIData;
|
|
2105
2129
|
exports.UIRender = UIRender;
|
|
2106
2130
|
exports.UnitConvert = UnitConvert;
|
|
2131
|
+
exports.createAttr = createAttr;
|
|
2107
2132
|
exports.effectType = effectType;
|
|
2108
2133
|
exports.resizeType = resizeType;
|
|
2109
2134
|
exports.zoomLayerType = zoomLayerType;
|
package/lib/draw.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, DataHelper, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper,
|
|
1
|
+
import { defineKey, decorateLeafAttr, attr, createDescriptor, Plugin, PathConvert, DataHelper, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, affectRenderBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, LeaferImage, ImageEvent, Matrix, PathCreator } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
/******************************************************************************
|
|
@@ -63,6 +63,11 @@ function zoomLayerType() {
|
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
+
function createAttr(defaultValue) {
|
|
67
|
+
return (target, key) => {
|
|
68
|
+
defineKey(target, key, createDescriptor(key, defaultValue));
|
|
69
|
+
};
|
|
70
|
+
}
|
|
66
71
|
|
|
67
72
|
function hasTransparent$1(color) {
|
|
68
73
|
if (!color || color.length === 7 || color.length === 4)
|
|
@@ -120,22 +125,9 @@ const emptyPaint = {};
|
|
|
120
125
|
const debug$1 = Debug.get('UIData');
|
|
121
126
|
class UIData extends LeafData {
|
|
122
127
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
123
|
-
get __strokeWidth() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const ui = this.__leaf;
|
|
127
|
-
let { scaleX } = ui.__nowWorld || ui.__world;
|
|
128
|
-
if (scaleX < 0)
|
|
129
|
-
scaleX = -scaleX;
|
|
130
|
-
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
131
|
-
}
|
|
132
|
-
else
|
|
133
|
-
return strokeWidth;
|
|
134
|
-
}
|
|
135
|
-
get __hasMultiPaint() {
|
|
136
|
-
const t = this;
|
|
137
|
-
return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
|
|
138
|
-
}
|
|
128
|
+
get __strokeWidth() { return this.__getRealStrokeWidth(); }
|
|
129
|
+
get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
|
|
130
|
+
get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
|
|
139
131
|
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
140
132
|
get __hasSurface() { const t = this; return (t.fill || t.stroke); }
|
|
141
133
|
get __autoWidth() { return !this._width; }
|
|
@@ -217,6 +209,21 @@ class UIData extends LeafData {
|
|
|
217
209
|
Paint.compute('stroke', this.__leaf);
|
|
218
210
|
this.__needComputePaint = undefined;
|
|
219
211
|
}
|
|
212
|
+
__getRealStrokeWidth(childStyle) {
|
|
213
|
+
let { strokeWidth, strokeWidthFixed } = this;
|
|
214
|
+
if (childStyle) {
|
|
215
|
+
if (childStyle.strokeWidth)
|
|
216
|
+
strokeWidth = childStyle.strokeWidth;
|
|
217
|
+
if (childStyle.strokeWidthFixed !== undefined)
|
|
218
|
+
strokeWidthFixed = childStyle.strokeWidthFixed;
|
|
219
|
+
}
|
|
220
|
+
if (strokeWidthFixed) {
|
|
221
|
+
const scale = this.__leaf.getClampRenderScale();
|
|
222
|
+
return scale > 1 ? strokeWidth / scale : strokeWidth;
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
return strokeWidth;
|
|
226
|
+
}
|
|
220
227
|
__setPaint(attrName, value) {
|
|
221
228
|
this.__setInput(attrName, value);
|
|
222
229
|
const layout = this.__leaf.__layout;
|
|
@@ -241,6 +248,7 @@ class UIData extends LeafData {
|
|
|
241
248
|
}
|
|
242
249
|
else {
|
|
243
250
|
stintSet$1(this, '__isAlphaPixelStroke', undefined);
|
|
251
|
+
stintSet$1(this, '__hasMultiStrokeStyle', undefined);
|
|
244
252
|
this._stroke = this.__isStrokes = undefined;
|
|
245
253
|
}
|
|
246
254
|
}
|
|
@@ -262,8 +270,8 @@ class GroupData extends UIData {
|
|
|
262
270
|
|
|
263
271
|
class BoxData extends GroupData {
|
|
264
272
|
get __boxStroke() { return !this.__pathInputed; }
|
|
265
|
-
get __drawAfterFill() { const t = this; return
|
|
266
|
-
get __clipAfterFill() { return
|
|
273
|
+
get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
|
|
274
|
+
get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
|
|
267
275
|
}
|
|
268
276
|
|
|
269
277
|
class LeaferData extends GroupData {
|
|
@@ -383,7 +391,7 @@ class CanvasData extends RectData {
|
|
|
383
391
|
const UIBounds = {
|
|
384
392
|
__updateStrokeSpread() {
|
|
385
393
|
let width = 0, boxWidth = 0;
|
|
386
|
-
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
394
|
+
const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
|
|
387
395
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
388
396
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
389
397
|
if (!data.__boxStroke) {
|
|
@@ -403,13 +411,15 @@ const UIBounds = {
|
|
|
403
411
|
},
|
|
404
412
|
__updateRenderSpread() {
|
|
405
413
|
let width = 0;
|
|
406
|
-
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
414
|
+
const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
|
|
407
415
|
if (shadow)
|
|
408
416
|
shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
409
417
|
if (blur)
|
|
410
418
|
width = Math.max(width, blur);
|
|
411
419
|
if (filter)
|
|
412
420
|
width += Filter.getSpread(filter);
|
|
421
|
+
if (renderSpread)
|
|
422
|
+
width += renderSpread;
|
|
413
423
|
let shapeWidth = width = Math.ceil(width);
|
|
414
424
|
if (innerShadow)
|
|
415
425
|
innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
|
|
@@ -432,7 +442,7 @@ const UIRender = {
|
|
|
432
442
|
}
|
|
433
443
|
if (data.__useEffect) {
|
|
434
444
|
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
435
|
-
stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread &&
|
|
445
|
+
stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
436
446
|
data.__useEffect = !!(shadow || otherEffect);
|
|
437
447
|
}
|
|
438
448
|
data.__checkSingle();
|
|
@@ -539,17 +549,17 @@ const RectRender = {
|
|
|
539
549
|
if (__drawAfterFill)
|
|
540
550
|
this.__drawAfterFill(canvas, options);
|
|
541
551
|
if (stroke) {
|
|
542
|
-
const { strokeAlign, __strokeWidth } = this.__;
|
|
543
|
-
if (!
|
|
552
|
+
const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
|
|
553
|
+
if (!strokeWidth)
|
|
544
554
|
return;
|
|
545
|
-
canvas.setStroke(stroke,
|
|
546
|
-
const half =
|
|
555
|
+
canvas.setStroke(stroke, strokeWidth, this.__);
|
|
556
|
+
const half = strokeWidth / 2;
|
|
547
557
|
switch (strokeAlign) {
|
|
548
558
|
case 'center':
|
|
549
559
|
canvas.strokeRect(0, 0, width, height);
|
|
550
560
|
break;
|
|
551
561
|
case 'inside':
|
|
552
|
-
width -=
|
|
562
|
+
width -= strokeWidth, height -= strokeWidth;
|
|
553
563
|
if (width < 0 || height < 0) {
|
|
554
564
|
canvas.save();
|
|
555
565
|
this.__clip(canvas, options);
|
|
@@ -560,7 +570,7 @@ const RectRender = {
|
|
|
560
570
|
canvas.strokeRect(x + half, y + half, width, height);
|
|
561
571
|
break;
|
|
562
572
|
case 'outside':
|
|
563
|
-
canvas.strokeRect(x - half, y - half, width +
|
|
573
|
+
canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
|
|
564
574
|
break;
|
|
565
575
|
}
|
|
566
576
|
}
|
|
@@ -573,6 +583,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
573
583
|
get isFrame() { return false; }
|
|
574
584
|
set scale(value) { MathHelper.assignScale(this, value); }
|
|
575
585
|
get scale() { return this.__.scale; }
|
|
586
|
+
get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
|
|
587
|
+
get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
|
|
576
588
|
get pen() {
|
|
577
589
|
const { path } = this.__;
|
|
578
590
|
pen.set(this.path = path || []);
|
|
@@ -787,6 +799,9 @@ __decorate([
|
|
|
787
799
|
__decorate([
|
|
788
800
|
naturalBoundsType(1)
|
|
789
801
|
], UI.prototype, "pixelRatio", void 0);
|
|
802
|
+
__decorate([
|
|
803
|
+
affectRenderBoundsType(0)
|
|
804
|
+
], UI.prototype, "renderSpread", void 0);
|
|
790
805
|
__decorate([
|
|
791
806
|
pathInputType()
|
|
792
807
|
], UI.prototype, "path", void 0);
|
|
@@ -943,7 +958,8 @@ let Group = class Group extends UI {
|
|
|
943
958
|
}
|
|
944
959
|
toJSON(options) {
|
|
945
960
|
const data = super.toJSON(options);
|
|
946
|
-
|
|
961
|
+
if (!this.childlessJSON)
|
|
962
|
+
data.children = this.children.map(child => child.toJSON(options));
|
|
947
963
|
return data;
|
|
948
964
|
}
|
|
949
965
|
pick(_hitPoint, _options) { return undefined; }
|
|
@@ -1390,8 +1406,8 @@ let Box = class Box extends Group {
|
|
|
1390
1406
|
__updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
|
|
1391
1407
|
__updateRectBoxBounds() { }
|
|
1392
1408
|
__updateBoxBounds(_secondLayout) {
|
|
1393
|
-
const data = this.__;
|
|
1394
1409
|
if (this.children.length && !this.pathInputed) {
|
|
1410
|
+
const data = this.__;
|
|
1395
1411
|
if (data.__autoSide) {
|
|
1396
1412
|
if (data.__hasSurface)
|
|
1397
1413
|
this.__extraUpdate();
|
|
@@ -1418,20 +1434,26 @@ let Box = class Box extends Group {
|
|
|
1418
1434
|
__updateStrokeBounds() { }
|
|
1419
1435
|
__updateRenderBounds() {
|
|
1420
1436
|
let isOverflow;
|
|
1421
|
-
const { renderBounds } = this.__layout;
|
|
1422
1437
|
if (this.children.length) {
|
|
1438
|
+
const data = this.__, { renderBounds, boxBounds } = this.__layout;
|
|
1423
1439
|
super.__updateRenderBounds();
|
|
1424
1440
|
copy(childrenRenderBounds, renderBounds);
|
|
1425
1441
|
this.__updateRectRenderBounds();
|
|
1426
|
-
|
|
1427
|
-
|
|
1442
|
+
if (data.scrollY || data.scrollX) {
|
|
1443
|
+
childrenRenderBounds.x += data.scrollX;
|
|
1444
|
+
childrenRenderBounds.y += data.scrollY;
|
|
1445
|
+
}
|
|
1446
|
+
isOverflow = !includes$1(boxBounds, childrenRenderBounds);
|
|
1447
|
+
if (isOverflow && data.overflow !== 'hide')
|
|
1428
1448
|
add(renderBounds, childrenRenderBounds);
|
|
1429
1449
|
}
|
|
1430
1450
|
else
|
|
1431
1451
|
this.__updateRectRenderBounds();
|
|
1432
1452
|
DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
1453
|
+
this.__updateScrollBar();
|
|
1433
1454
|
}
|
|
1434
1455
|
__updateRectRenderBounds() { }
|
|
1456
|
+
__updateScrollBar() { }
|
|
1435
1457
|
__updateRectChange() { }
|
|
1436
1458
|
__updateChange() {
|
|
1437
1459
|
super.__updateChange();
|
|
@@ -1448,10 +1470,12 @@ let Box = class Box extends Group {
|
|
|
1448
1470
|
if (this.children.length)
|
|
1449
1471
|
this.__renderGroup(canvas, options);
|
|
1450
1472
|
}
|
|
1473
|
+
if (this.scrollBar)
|
|
1474
|
+
this.scrollBar.__render(canvas, options);
|
|
1451
1475
|
}
|
|
1452
1476
|
__drawContent(canvas, options) {
|
|
1453
1477
|
this.__renderGroup(canvas, options);
|
|
1454
|
-
if (this.__.__useStroke) {
|
|
1478
|
+
if (this.__.__useStroke || this.__.__useEffect) {
|
|
1455
1479
|
canvas.setWorld(this.__nowWorld);
|
|
1456
1480
|
this.__drawRenderPath(canvas);
|
|
1457
1481
|
}
|
|
@@ -2072,4 +2096,4 @@ function penPathType() {
|
|
|
2072
2096
|
};
|
|
2073
2097
|
}
|
|
2074
2098
|
|
|
2075
|
-
export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, effectType, resizeType, zoomLayerType };
|
|
2099
|
+
export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, createAttr, effectType, resizeType, zoomLayerType };
|