leafer-draw 1.5.3 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +73 -75
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +73 -75
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +265 -169
- package/dist/web.js.map +1 -1
- 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 +265 -169
- package/dist/web.module.js.map +1 -1
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
package/dist/web.cjs
CHANGED
|
@@ -422,7 +422,6 @@ function updateChange(updateList) {
|
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
425
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
426
425
|
class LayoutBlockData {
|
|
427
426
|
constructor(list) {
|
|
428
427
|
this.updatedBounds = new core.Bounds();
|
|
@@ -436,13 +435,7 @@ class LayoutBlockData {
|
|
|
436
435
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
437
436
|
}
|
|
438
437
|
setAfter() {
|
|
439
|
-
|
|
440
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
441
|
-
this.afterBounds.set(bigBounds);
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
445
|
-
}
|
|
438
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
446
439
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
447
440
|
}
|
|
448
441
|
merge(data) {
|
|
@@ -644,6 +637,22 @@ class Renderer {
|
|
|
644
637
|
requestLayout() {
|
|
645
638
|
this.target.emit(core.LayoutEvent.REQUEST);
|
|
646
639
|
}
|
|
640
|
+
checkRender() {
|
|
641
|
+
if (this.running) {
|
|
642
|
+
const { target } = this;
|
|
643
|
+
if (target.isApp) {
|
|
644
|
+
target.emit(core.RenderEvent.CHILD_START, target);
|
|
645
|
+
target.children.forEach(leafer => {
|
|
646
|
+
leafer.renderer.FPS = this.FPS;
|
|
647
|
+
leafer.renderer.checkRender();
|
|
648
|
+
});
|
|
649
|
+
target.emit(core.RenderEvent.CHILD_END, target);
|
|
650
|
+
}
|
|
651
|
+
if (this.changed && this.canvas.view)
|
|
652
|
+
this.render();
|
|
653
|
+
this.target.emit(core.RenderEvent.NEXT);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
647
656
|
render(callback) {
|
|
648
657
|
if (!(this.running && this.canvas.view))
|
|
649
658
|
return this.update();
|
|
@@ -652,8 +661,6 @@ class Renderer {
|
|
|
652
661
|
this.totalBounds = new core.Bounds();
|
|
653
662
|
debug.log(target.innerName, '--->');
|
|
654
663
|
try {
|
|
655
|
-
if (!target.isApp)
|
|
656
|
-
target.app.emit(core.RenderEvent.CHILD_START, target);
|
|
657
664
|
this.emitRender(core.RenderEvent.START);
|
|
658
665
|
this.renderOnce(callback);
|
|
659
666
|
this.emitRender(core.RenderEvent.END, this.totalBounds);
|
|
@@ -721,20 +728,12 @@ class Renderer {
|
|
|
721
728
|
}
|
|
722
729
|
clipRender(block) {
|
|
723
730
|
const t = core.Run.start('PartRender');
|
|
724
|
-
const { canvas } = this;
|
|
725
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
726
|
-
const includes = block.includes(this.target.__world);
|
|
727
|
-
const realBounds = new core.Bounds(bounds);
|
|
731
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
|
|
728
732
|
canvas.save();
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
734
|
-
canvas.clearWorld(bounds, true);
|
|
735
|
-
canvas.clipWorld(bounds, true);
|
|
736
|
-
}
|
|
737
|
-
this.__render(bounds, includes, realBounds);
|
|
733
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
734
|
+
canvas.clearWorld(bounds, true);
|
|
735
|
+
canvas.clipWorld(bounds, true);
|
|
736
|
+
this.__render(bounds, realBounds);
|
|
738
737
|
canvas.restore();
|
|
739
738
|
core.Run.end(t);
|
|
740
739
|
}
|
|
@@ -743,28 +742,22 @@ class Renderer {
|
|
|
743
742
|
const { canvas } = this;
|
|
744
743
|
canvas.save();
|
|
745
744
|
canvas.clear();
|
|
746
|
-
this.__render(canvas.bounds
|
|
745
|
+
this.__render(canvas.bounds);
|
|
747
746
|
canvas.restore();
|
|
748
747
|
core.Run.end(t);
|
|
749
748
|
}
|
|
750
|
-
__render(bounds,
|
|
751
|
-
const
|
|
749
|
+
__render(bounds, realBounds) {
|
|
750
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
752
751
|
if (this.needFill)
|
|
753
|
-
|
|
752
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
754
753
|
if (core.Debug.showRepaint)
|
|
755
|
-
|
|
756
|
-
this.target.__render(
|
|
754
|
+
core.Debug.drawRepaint(canvas, bounds);
|
|
755
|
+
this.target.__render(canvas, options);
|
|
757
756
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
758
757
|
this.renderOptions = options;
|
|
759
758
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
if (core.Debug.showBoundsView)
|
|
763
|
-
this.renderBoundsView(options);
|
|
764
|
-
this.canvas.updateRender(realBounds);
|
|
765
|
-
}
|
|
766
|
-
renderHitView(_options) { }
|
|
767
|
-
renderBoundsView(_options) { }
|
|
759
|
+
canvas.updateRender(realBounds);
|
|
760
|
+
}
|
|
768
761
|
addBlock(block) {
|
|
769
762
|
if (!this.updateBlocks)
|
|
770
763
|
this.updateBlocks = [];
|
|
@@ -780,17 +773,16 @@ class Renderer {
|
|
|
780
773
|
}
|
|
781
774
|
}
|
|
782
775
|
__requestRender() {
|
|
783
|
-
|
|
776
|
+
const target = this.target;
|
|
777
|
+
if (this.requestTime || !target)
|
|
784
778
|
return;
|
|
779
|
+
if (target.parentApp)
|
|
780
|
+
return target.parentApp.requestRender(false);
|
|
785
781
|
const requestTime = this.requestTime = Date.now();
|
|
786
782
|
core.Platform.requestRender(() => {
|
|
787
783
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
788
784
|
this.requestTime = 0;
|
|
789
|
-
|
|
790
|
-
if (this.changed && this.canvas.view)
|
|
791
|
-
this.render();
|
|
792
|
-
this.target.emit(core.RenderEvent.NEXT);
|
|
793
|
-
}
|
|
785
|
+
this.checkRender();
|
|
794
786
|
});
|
|
795
787
|
}
|
|
796
788
|
__onResize(e) {
|
|
@@ -848,6 +840,7 @@ class Renderer {
|
|
|
848
840
|
}
|
|
849
841
|
}
|
|
850
842
|
}
|
|
843
|
+
Renderer.clipSpread = 10;
|
|
851
844
|
|
|
852
845
|
Object.assign(core.Creator, {
|
|
853
846
|
watcher: (target, options) => new Watcher(target, options),
|
|
@@ -1210,9 +1203,11 @@ const tempBox = new core.Bounds();
|
|
|
1210
1203
|
const tempPoint = {};
|
|
1211
1204
|
const tempScaleData = {};
|
|
1212
1205
|
function createData(leafPaint, image, paint, box) {
|
|
1213
|
-
const { blendMode, sync } = paint;
|
|
1206
|
+
const { blendMode, changeful, sync } = paint;
|
|
1214
1207
|
if (blendMode)
|
|
1215
1208
|
leafPaint.blendMode = blendMode;
|
|
1209
|
+
if (changeful)
|
|
1210
|
+
leafPaint.changeful = changeful;
|
|
1216
1211
|
if (sync)
|
|
1217
1212
|
leafPaint.sync = sync;
|
|
1218
1213
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1477,40 +1472,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1477
1472
|
};
|
|
1478
1473
|
|
|
1479
1474
|
const { abs } = Math;
|
|
1480
|
-
function checkImage(ui, canvas, paint,
|
|
1475
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1481
1476
|
const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1482
|
-
const { pixelRatio } = canvas;
|
|
1483
|
-
if (!
|
|
1477
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1478
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1484
1479
|
return false;
|
|
1485
1480
|
}
|
|
1486
1481
|
else {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
let { width, height } = data;
|
|
1491
|
-
width *= abs(scaleX) * pixelRatio;
|
|
1492
|
-
height *= abs(scaleY) * pixelRatio;
|
|
1493
|
-
if (data.scaleX) {
|
|
1494
|
-
width *= data.scaleX;
|
|
1495
|
-
height *= data.scaleY;
|
|
1496
|
-
}
|
|
1497
|
-
allowPaint = (width * height > core.Platform.image.maxCacheSize) || draw.Export.running;
|
|
1482
|
+
if (allowDraw) {
|
|
1483
|
+
if (data.repeat) {
|
|
1484
|
+
allowDraw = false;
|
|
1498
1485
|
}
|
|
1499
1486
|
else {
|
|
1500
|
-
|
|
1487
|
+
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1488
|
+
let { width, height } = data;
|
|
1489
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1490
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1491
|
+
if (data.scaleX) {
|
|
1492
|
+
width *= data.scaleX;
|
|
1493
|
+
height *= data.scaleY;
|
|
1494
|
+
}
|
|
1495
|
+
allowDraw = (width * height > core.Platform.image.maxCacheSize);
|
|
1496
|
+
}
|
|
1501
1497
|
}
|
|
1502
1498
|
}
|
|
1503
|
-
if (
|
|
1504
|
-
canvas
|
|
1505
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1506
|
-
if (paint.blendMode)
|
|
1507
|
-
canvas.blendMode = paint.blendMode;
|
|
1508
|
-
if (data.opacity)
|
|
1509
|
-
canvas.opacity *= data.opacity;
|
|
1510
|
-
if (data.transform)
|
|
1511
|
-
canvas.transform(data.transform);
|
|
1512
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1513
|
-
canvas.restore();
|
|
1499
|
+
if (allowDraw) {
|
|
1500
|
+
drawImage(ui, canvas, paint, data);
|
|
1514
1501
|
return true;
|
|
1515
1502
|
}
|
|
1516
1503
|
else {
|
|
@@ -1531,13 +1518,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1531
1518
|
}
|
|
1532
1519
|
}
|
|
1533
1520
|
}
|
|
1521
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1522
|
+
canvas.save();
|
|
1523
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1524
|
+
if (paint.blendMode)
|
|
1525
|
+
canvas.blendMode = paint.blendMode;
|
|
1526
|
+
if (data.opacity)
|
|
1527
|
+
canvas.opacity *= data.opacity;
|
|
1528
|
+
if (data.transform)
|
|
1529
|
+
canvas.transform(data.transform);
|
|
1530
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1531
|
+
canvas.restore();
|
|
1532
|
+
}
|
|
1534
1533
|
|
|
1535
1534
|
function recycleImage(attrName, data) {
|
|
1536
1535
|
const paints = data['_' + attrName];
|
|
1537
1536
|
if (paints instanceof Array) {
|
|
1538
|
-
let image, recycleMap, input, url;
|
|
1537
|
+
let paint, image, recycleMap, input, url;
|
|
1539
1538
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1540
|
-
|
|
1539
|
+
paint = paints[i];
|
|
1540
|
+
image = paint.image;
|
|
1541
1541
|
url = image && image.url;
|
|
1542
1542
|
if (url) {
|
|
1543
1543
|
if (!recycleMap)
|
|
@@ -1552,8 +1552,6 @@ function recycleImage(attrName, data) {
|
|
|
1552
1552
|
}
|
|
1553
1553
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1554
1554
|
}
|
|
1555
|
-
else
|
|
1556
|
-
paints[i].style = null;
|
|
1557
1555
|
}
|
|
1558
1556
|
}
|
|
1559
1557
|
return recycleMap;
|
|
@@ -1732,7 +1730,7 @@ const { toOffsetOutBounds } = core.BoundsHelper;
|
|
|
1732
1730
|
const offsetOutBounds = {};
|
|
1733
1731
|
function innerShadow(ui, current, shape) {
|
|
1734
1732
|
let copyBounds, spreadScale;
|
|
1735
|
-
const { __nowWorld: nowWorld, __layout
|
|
1733
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1736
1734
|
const { innerShadow } = ui.__;
|
|
1737
1735
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1738
1736
|
const other = current.getSameCanvas();
|