leafer-draw 1.5.3 → 1.6.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 +68 -71
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +68 -71
- 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 +260 -165
- 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 +260 -165
- 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,13 @@ class Renderer {
|
|
|
644
637
|
requestLayout() {
|
|
645
638
|
this.target.emit(core.LayoutEvent.REQUEST);
|
|
646
639
|
}
|
|
640
|
+
checkRender() {
|
|
641
|
+
if (this.running) {
|
|
642
|
+
if (this.changed && this.canvas.view)
|
|
643
|
+
this.render();
|
|
644
|
+
this.target.emit(core.RenderEvent.NEXT);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
647
|
render(callback) {
|
|
648
648
|
if (!(this.running && this.canvas.view))
|
|
649
649
|
return this.update();
|
|
@@ -652,8 +652,6 @@ class Renderer {
|
|
|
652
652
|
this.totalBounds = new core.Bounds();
|
|
653
653
|
debug.log(target.innerName, '--->');
|
|
654
654
|
try {
|
|
655
|
-
if (!target.isApp)
|
|
656
|
-
target.app.emit(core.RenderEvent.CHILD_START, target);
|
|
657
655
|
this.emitRender(core.RenderEvent.START);
|
|
658
656
|
this.renderOnce(callback);
|
|
659
657
|
this.emitRender(core.RenderEvent.END, this.totalBounds);
|
|
@@ -721,20 +719,12 @@ class Renderer {
|
|
|
721
719
|
}
|
|
722
720
|
clipRender(block) {
|
|
723
721
|
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);
|
|
722
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
|
|
728
723
|
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);
|
|
724
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
725
|
+
canvas.clearWorld(bounds, true);
|
|
726
|
+
canvas.clipWorld(bounds, true);
|
|
727
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
738
728
|
canvas.restore();
|
|
739
729
|
core.Run.end(t);
|
|
740
730
|
}
|
|
@@ -748,23 +738,17 @@ class Renderer {
|
|
|
748
738
|
core.Run.end(t);
|
|
749
739
|
}
|
|
750
740
|
__render(bounds, includes, realBounds) {
|
|
751
|
-
const options =
|
|
741
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
752
742
|
if (this.needFill)
|
|
753
|
-
|
|
743
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
754
744
|
if (core.Debug.showRepaint)
|
|
755
|
-
|
|
756
|
-
this.target.__render(
|
|
745
|
+
core.Debug.drawRepaint(canvas, bounds);
|
|
746
|
+
this.target.__render(canvas, options);
|
|
757
747
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
758
748
|
this.renderOptions = options;
|
|
759
749
|
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) { }
|
|
750
|
+
canvas.updateRender(realBounds);
|
|
751
|
+
}
|
|
768
752
|
addBlock(block) {
|
|
769
753
|
if (!this.updateBlocks)
|
|
770
754
|
this.updateBlocks = [];
|
|
@@ -780,17 +764,24 @@ class Renderer {
|
|
|
780
764
|
}
|
|
781
765
|
}
|
|
782
766
|
__requestRender() {
|
|
767
|
+
const target = this.target;
|
|
768
|
+
if (target.parentApp)
|
|
769
|
+
return target.parentApp.renderer.update(false);
|
|
783
770
|
if (this.requestTime)
|
|
784
771
|
return;
|
|
785
772
|
const requestTime = this.requestTime = Date.now();
|
|
786
773
|
core.Platform.requestRender(() => {
|
|
787
774
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
788
775
|
this.requestTime = 0;
|
|
789
|
-
if (
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
776
|
+
if (target.isApp) {
|
|
777
|
+
target.emit(core.RenderEvent.CHILD_START, target);
|
|
778
|
+
target.children.forEach(leafer => {
|
|
779
|
+
leafer.renderer.FPS = this.FPS;
|
|
780
|
+
leafer.renderer.checkRender();
|
|
781
|
+
});
|
|
782
|
+
target.emit(core.RenderEvent.CHILD_END, target);
|
|
793
783
|
}
|
|
784
|
+
this.checkRender();
|
|
794
785
|
});
|
|
795
786
|
}
|
|
796
787
|
__onResize(e) {
|
|
@@ -848,6 +839,7 @@ class Renderer {
|
|
|
848
839
|
}
|
|
849
840
|
}
|
|
850
841
|
}
|
|
842
|
+
Renderer.clipSpread = 10;
|
|
851
843
|
|
|
852
844
|
Object.assign(core.Creator, {
|
|
853
845
|
watcher: (target, options) => new Watcher(target, options),
|
|
@@ -1210,9 +1202,11 @@ const tempBox = new core.Bounds();
|
|
|
1210
1202
|
const tempPoint = {};
|
|
1211
1203
|
const tempScaleData = {};
|
|
1212
1204
|
function createData(leafPaint, image, paint, box) {
|
|
1213
|
-
const { blendMode, sync } = paint;
|
|
1205
|
+
const { blendMode, changeful, sync } = paint;
|
|
1214
1206
|
if (blendMode)
|
|
1215
1207
|
leafPaint.blendMode = blendMode;
|
|
1208
|
+
if (changeful)
|
|
1209
|
+
leafPaint.changeful = changeful;
|
|
1216
1210
|
if (sync)
|
|
1217
1211
|
leafPaint.sync = sync;
|
|
1218
1212
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1477,40 +1471,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1477
1471
|
};
|
|
1478
1472
|
|
|
1479
1473
|
const { abs } = Math;
|
|
1480
|
-
function checkImage(ui, canvas, paint,
|
|
1474
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1481
1475
|
const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1482
|
-
const { pixelRatio } = canvas;
|
|
1483
|
-
if (!
|
|
1476
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1477
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1484
1478
|
return false;
|
|
1485
1479
|
}
|
|
1486
1480
|
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;
|
|
1481
|
+
if (allowDraw) {
|
|
1482
|
+
if (data.repeat) {
|
|
1483
|
+
allowDraw = false;
|
|
1498
1484
|
}
|
|
1499
1485
|
else {
|
|
1500
|
-
|
|
1486
|
+
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1487
|
+
let { width, height } = data;
|
|
1488
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1489
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1490
|
+
if (data.scaleX) {
|
|
1491
|
+
width *= data.scaleX;
|
|
1492
|
+
height *= data.scaleY;
|
|
1493
|
+
}
|
|
1494
|
+
allowDraw = (width * height > core.Platform.image.maxCacheSize);
|
|
1495
|
+
}
|
|
1501
1496
|
}
|
|
1502
1497
|
}
|
|
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();
|
|
1498
|
+
if (allowDraw) {
|
|
1499
|
+
drawImage(ui, canvas, paint, data);
|
|
1514
1500
|
return true;
|
|
1515
1501
|
}
|
|
1516
1502
|
else {
|
|
@@ -1531,13 +1517,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1531
1517
|
}
|
|
1532
1518
|
}
|
|
1533
1519
|
}
|
|
1520
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1521
|
+
canvas.save();
|
|
1522
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1523
|
+
if (paint.blendMode)
|
|
1524
|
+
canvas.blendMode = paint.blendMode;
|
|
1525
|
+
if (data.opacity)
|
|
1526
|
+
canvas.opacity *= data.opacity;
|
|
1527
|
+
if (data.transform)
|
|
1528
|
+
canvas.transform(data.transform);
|
|
1529
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1530
|
+
canvas.restore();
|
|
1531
|
+
}
|
|
1534
1532
|
|
|
1535
1533
|
function recycleImage(attrName, data) {
|
|
1536
1534
|
const paints = data['_' + attrName];
|
|
1537
1535
|
if (paints instanceof Array) {
|
|
1538
|
-
let image, recycleMap, input, url;
|
|
1536
|
+
let paint, image, recycleMap, input, url;
|
|
1539
1537
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
1540
|
-
|
|
1538
|
+
paint = paints[i];
|
|
1539
|
+
image = paint.image;
|
|
1541
1540
|
url = image && image.url;
|
|
1542
1541
|
if (url) {
|
|
1543
1542
|
if (!recycleMap)
|
|
@@ -1552,8 +1551,6 @@ function recycleImage(attrName, data) {
|
|
|
1552
1551
|
}
|
|
1553
1552
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
1554
1553
|
}
|
|
1555
|
-
else
|
|
1556
|
-
paints[i].style = null;
|
|
1557
1554
|
}
|
|
1558
1555
|
}
|
|
1559
1556
|
return recycleMap;
|
|
@@ -1732,7 +1729,7 @@ const { toOffsetOutBounds } = core.BoundsHelper;
|
|
|
1732
1729
|
const offsetOutBounds = {};
|
|
1733
1730
|
function innerShadow(ui, current, shape) {
|
|
1734
1731
|
let copyBounds, spreadScale;
|
|
1735
|
-
const { __nowWorld: nowWorld, __layout
|
|
1732
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
1736
1733
|
const { innerShadow } = ui.__;
|
|
1737
1734
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
1738
1735
|
const other = current.getSameCanvas();
|