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