leafer-ui 1.6.1 → 1.6.3
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 +207 -201
- package/dist/web.esm.js +211 -205
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +614 -449
- 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 +609 -449
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
- package/dist/web.cjs.map +0 -1
- package/dist/web.esm.js.map +0 -1
- package/dist/web.js.map +0 -1
- package/dist/web.module.js.map +0 -1
package/dist/web.cjs
CHANGED
|
@@ -342,17 +342,15 @@ class Watcher {
|
|
|
342
342
|
this.target.emitEvent(new core.WatchEvent(core.WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
343
343
|
this.__updatedList = new core.LeafList();
|
|
344
344
|
this.totalTimes++;
|
|
345
|
-
this.changed = false;
|
|
346
|
-
this.hasVisible = false;
|
|
347
|
-
this.hasRemove = false;
|
|
348
|
-
this.hasAdd = false;
|
|
345
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
349
346
|
}
|
|
350
347
|
__listenEvents() {
|
|
351
|
-
const { target } = this;
|
|
352
348
|
this.__eventIds = [
|
|
353
|
-
target.on_(
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
this.target.on_([
|
|
350
|
+
[core.PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
351
|
+
[[core.ChildEvent.ADD, core.ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
352
|
+
[core.WatchEvent.REQUEST, this.__onRquestData, this]
|
|
353
|
+
])
|
|
356
354
|
];
|
|
357
355
|
}
|
|
358
356
|
__removeListenEvents() {
|
|
@@ -362,13 +360,12 @@ class Watcher {
|
|
|
362
360
|
if (this.target) {
|
|
363
361
|
this.stop();
|
|
364
362
|
this.__removeListenEvents();
|
|
365
|
-
this.target = null;
|
|
366
|
-
this.__updatedList = null;
|
|
363
|
+
this.target = this.__updatedList = null;
|
|
367
364
|
}
|
|
368
365
|
}
|
|
369
366
|
}
|
|
370
367
|
|
|
371
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
368
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
|
|
372
369
|
const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
|
|
373
370
|
function updateMatrix(updateList, levelList) {
|
|
374
371
|
let layout;
|
|
@@ -411,15 +408,7 @@ function updateBounds(boundsList) {
|
|
|
411
408
|
});
|
|
412
409
|
}
|
|
413
410
|
function updateChange(updateList) {
|
|
414
|
-
|
|
415
|
-
updateList.list.forEach(leaf => {
|
|
416
|
-
layout = leaf.__layout;
|
|
417
|
-
if (layout.opacityChanged)
|
|
418
|
-
updateAllWorldOpacity(leaf);
|
|
419
|
-
if (layout.stateStyleChanged)
|
|
420
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
421
|
-
leaf.__updateChange();
|
|
422
|
-
});
|
|
411
|
+
updateList.list.forEach(updateOneChange);
|
|
423
412
|
}
|
|
424
413
|
|
|
425
414
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
@@ -476,7 +465,7 @@ class Layouter {
|
|
|
476
465
|
this.disabled = true;
|
|
477
466
|
}
|
|
478
467
|
layout() {
|
|
479
|
-
if (!this.running)
|
|
468
|
+
if (this.layouting || !this.running)
|
|
480
469
|
return;
|
|
481
470
|
const { target } = this;
|
|
482
471
|
this.times = 0;
|
|
@@ -559,12 +548,10 @@ class Layouter {
|
|
|
559
548
|
}
|
|
560
549
|
static fullLayout(target) {
|
|
561
550
|
updateAllMatrix(target, true);
|
|
562
|
-
if (target.isBranch)
|
|
551
|
+
if (target.isBranch)
|
|
563
552
|
core.BranchHelper.updateBounds(target);
|
|
564
|
-
|
|
565
|
-
else {
|
|
553
|
+
else
|
|
566
554
|
core.LeafHelper.updateBounds(target);
|
|
567
|
-
}
|
|
568
555
|
updateAllChange(target);
|
|
569
556
|
}
|
|
570
557
|
addExtra(leaf) {
|
|
@@ -587,11 +574,12 @@ class Layouter {
|
|
|
587
574
|
this.__updatedList = event.data.updatedList;
|
|
588
575
|
}
|
|
589
576
|
__listenEvents() {
|
|
590
|
-
const { target } = this;
|
|
591
577
|
this.__eventIds = [
|
|
592
|
-
target.on_(
|
|
593
|
-
|
|
594
|
-
|
|
578
|
+
this.target.on_([
|
|
579
|
+
[core.LayoutEvent.REQUEST, this.layout, this],
|
|
580
|
+
[core.LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
581
|
+
[core.WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
582
|
+
])
|
|
595
583
|
];
|
|
596
584
|
}
|
|
597
585
|
__removeListenEvents() {
|
|
@@ -822,12 +810,13 @@ class Renderer {
|
|
|
822
810
|
this.target.emitEvent(new core.RenderEvent(type, this.times, bounds, options));
|
|
823
811
|
}
|
|
824
812
|
__listenEvents() {
|
|
825
|
-
const { target } = this;
|
|
826
813
|
this.__eventIds = [
|
|
827
|
-
target.on_(
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
814
|
+
this.target.on_([
|
|
815
|
+
[core.RenderEvent.REQUEST, this.update, this],
|
|
816
|
+
[core.LayoutEvent.END, this.__onLayoutEnd, this],
|
|
817
|
+
[core.RenderEvent.AGAIN, this.renderAgain, this],
|
|
818
|
+
[core.ResizeEvent.RESIZE, this.__onResize, this]
|
|
819
|
+
])
|
|
831
820
|
];
|
|
832
821
|
}
|
|
833
822
|
__removeListenEvents() {
|
|
@@ -1319,8 +1308,10 @@ class Interaction extends core$1.InteractionBase {
|
|
|
1319
1308
|
}
|
|
1320
1309
|
|
|
1321
1310
|
function fillText(ui, canvas) {
|
|
1322
|
-
|
|
1323
|
-
|
|
1311
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
1312
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
1313
|
+
canvas.fillStyle = data.placeholderColor;
|
|
1314
|
+
let row;
|
|
1324
1315
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
1325
1316
|
row = rows[i];
|
|
1326
1317
|
if (row.text)
|
|
@@ -1329,7 +1320,7 @@ function fillText(ui, canvas) {
|
|
|
1329
1320
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
1330
1321
|
}
|
|
1331
1322
|
if (decorationY) {
|
|
1332
|
-
const { decorationColor, decorationHeight } = data;
|
|
1323
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
1333
1324
|
if (decorationColor)
|
|
1334
1325
|
canvas.fillStyle = decorationColor;
|
|
1335
1326
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -1338,65 +1329,73 @@ function fillText(ui, canvas) {
|
|
|
1338
1329
|
|
|
1339
1330
|
function fill(fill, ui, canvas) {
|
|
1340
1331
|
canvas.fillStyle = fill;
|
|
1341
|
-
|
|
1332
|
+
fillPathOrText(ui, canvas);
|
|
1342
1333
|
}
|
|
1343
1334
|
function fills(fills, ui, canvas) {
|
|
1344
1335
|
let item;
|
|
1345
|
-
const { windingRule, __font } = ui.__;
|
|
1346
1336
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
1347
1337
|
item = fills[i];
|
|
1348
|
-
if (item.image
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
if (item.blendMode)
|
|
1356
|
-
canvas.blendMode = item.blendMode;
|
|
1357
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
1358
|
-
canvas.restore();
|
|
1338
|
+
if (item.image) {
|
|
1339
|
+
if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
1340
|
+
continue;
|
|
1341
|
+
if (!item.style) {
|
|
1342
|
+
if (!i && item.image.isPlacehold)
|
|
1343
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
1344
|
+
continue;
|
|
1359
1345
|
}
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1346
|
+
}
|
|
1347
|
+
canvas.fillStyle = item.style;
|
|
1348
|
+
if (item.transform) {
|
|
1349
|
+
canvas.save();
|
|
1350
|
+
canvas.transform(item.transform);
|
|
1351
|
+
if (item.blendMode)
|
|
1352
|
+
canvas.blendMode = item.blendMode;
|
|
1353
|
+
fillPathOrText(ui, canvas);
|
|
1354
|
+
canvas.restore();
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
if (item.blendMode) {
|
|
1358
|
+
canvas.saveBlendMode(item.blendMode);
|
|
1359
|
+
fillPathOrText(ui, canvas);
|
|
1360
|
+
canvas.restoreBlendMode();
|
|
1369
1361
|
}
|
|
1362
|
+
else
|
|
1363
|
+
fillPathOrText(ui, canvas);
|
|
1370
1364
|
}
|
|
1371
1365
|
}
|
|
1372
1366
|
}
|
|
1367
|
+
function fillPathOrText(ui, canvas) {
|
|
1368
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const Paint = {};
|
|
1373
1372
|
|
|
1374
1373
|
function strokeText(stroke, ui, canvas) {
|
|
1375
|
-
|
|
1376
|
-
const isStrokes = typeof stroke !== 'string';
|
|
1377
|
-
switch (strokeAlign) {
|
|
1374
|
+
switch (ui.__.strokeAlign) {
|
|
1378
1375
|
case 'center':
|
|
1379
|
-
|
|
1380
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
1376
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
1381
1377
|
break;
|
|
1382
1378
|
case 'inside':
|
|
1383
|
-
|
|
1379
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
1384
1380
|
break;
|
|
1385
1381
|
case 'outside':
|
|
1386
|
-
|
|
1382
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
1387
1383
|
break;
|
|
1388
1384
|
}
|
|
1389
1385
|
}
|
|
1390
|
-
function
|
|
1391
|
-
const
|
|
1386
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
1387
|
+
const data = ui.__;
|
|
1388
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
1389
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
1390
|
+
}
|
|
1391
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
1392
1392
|
const out = canvas.getSameCanvas(true, true);
|
|
1393
|
-
out.
|
|
1394
|
-
|
|
1395
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
1393
|
+
out.font = ui.__.__font;
|
|
1394
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
1396
1395
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
1397
1396
|
fillText(ui, out);
|
|
1398
1397
|
out.blendMode = 'normal';
|
|
1399
|
-
if (ui.__worldFlipped)
|
|
1398
|
+
if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
|
|
1400
1399
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1401
1400
|
else
|
|
1402
1401
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -1438,90 +1437,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
1438
1437
|
}
|
|
1439
1438
|
|
|
1440
1439
|
function stroke(stroke, ui, canvas) {
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
if (!__strokeWidth)
|
|
1440
|
+
const data = ui.__;
|
|
1441
|
+
if (!data.__strokeWidth)
|
|
1444
1442
|
return;
|
|
1445
|
-
if (__font) {
|
|
1443
|
+
if (data.__font) {
|
|
1446
1444
|
strokeText(stroke, ui, canvas);
|
|
1447
1445
|
}
|
|
1448
1446
|
else {
|
|
1449
|
-
switch (strokeAlign) {
|
|
1447
|
+
switch (data.strokeAlign) {
|
|
1450
1448
|
case 'center':
|
|
1451
|
-
|
|
1452
|
-
canvas.stroke();
|
|
1453
|
-
if (options.__useArrow)
|
|
1454
|
-
strokeArrow(ui, canvas);
|
|
1449
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
1455
1450
|
break;
|
|
1456
1451
|
case 'inside':
|
|
1457
|
-
canvas
|
|
1458
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
1459
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
1460
|
-
canvas.stroke();
|
|
1461
|
-
canvas.restore();
|
|
1452
|
+
drawInside(stroke, ui, canvas);
|
|
1462
1453
|
break;
|
|
1463
1454
|
case 'outside':
|
|
1464
|
-
|
|
1465
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
1466
|
-
ui.__drawRenderPath(out);
|
|
1467
|
-
out.stroke();
|
|
1468
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1469
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
1470
|
-
if (ui.__worldFlipped)
|
|
1471
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1472
|
-
else
|
|
1473
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
1474
|
-
out.recycle(ui.__nowWorld);
|
|
1455
|
+
drawOutside(stroke, ui, canvas);
|
|
1475
1456
|
break;
|
|
1476
1457
|
}
|
|
1477
1458
|
}
|
|
1478
1459
|
}
|
|
1479
1460
|
function strokes(strokes, ui, canvas) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1461
|
+
stroke(strokes, ui, canvas);
|
|
1462
|
+
}
|
|
1463
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
1464
|
+
const data = ui.__;
|
|
1465
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1466
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
1467
|
+
if (data.__useArrow)
|
|
1468
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
1469
|
+
}
|
|
1470
|
+
function drawInside(stroke, ui, canvas) {
|
|
1471
|
+
const data = ui.__;
|
|
1472
|
+
canvas.save();
|
|
1473
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
1474
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
1475
|
+
canvas.restore();
|
|
1476
|
+
}
|
|
1477
|
+
function drawOutside(stroke, ui, canvas) {
|
|
1478
|
+
const data = ui.__;
|
|
1479
|
+
if (data.__fillAfterStroke) {
|
|
1480
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
1486
1481
|
}
|
|
1487
1482
|
else {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
1500
|
-
canvas.restore();
|
|
1501
|
-
break;
|
|
1502
|
-
case 'outside':
|
|
1503
|
-
const { renderBounds } = ui.__layout;
|
|
1504
|
-
const out = canvas.getSameCanvas(true, true);
|
|
1505
|
-
ui.__drawRenderPath(out);
|
|
1506
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
1507
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
1508
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1509
|
-
out.clearWorld(renderBounds);
|
|
1510
|
-
if (ui.__worldFlipped)
|
|
1511
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1512
|
-
else
|
|
1513
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1514
|
-
out.recycle(ui.__nowWorld);
|
|
1515
|
-
break;
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
function strokeArrow(ui, canvas) {
|
|
1520
|
-
if (ui.__.dashPattern) {
|
|
1521
|
-
canvas.beginPath();
|
|
1522
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
1523
|
-
canvas.dashPattern = null;
|
|
1524
|
-
canvas.stroke();
|
|
1483
|
+
const { renderBounds } = ui.__layout;
|
|
1484
|
+
const out = canvas.getSameCanvas(true, true);
|
|
1485
|
+
ui.__drawRenderPath(out);
|
|
1486
|
+
drawCenter(stroke, 2, ui, out);
|
|
1487
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
1488
|
+
out.clearWorld(renderBounds);
|
|
1489
|
+
if (ui.__worldFlipped || core$1.Platform.fullImageShadow)
|
|
1490
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1491
|
+
else
|
|
1492
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1493
|
+
out.recycle(ui.__nowWorld);
|
|
1525
1494
|
}
|
|
1526
1495
|
}
|
|
1527
1496
|
|
|
@@ -1568,9 +1537,10 @@ function shape(ui, current, options) {
|
|
|
1568
1537
|
}
|
|
1569
1538
|
|
|
1570
1539
|
let recycleMap;
|
|
1540
|
+
const { stintSet } = core.DataHelper, { hasTransparent: hasTransparent$1 } = draw.ColorConvert;
|
|
1571
1541
|
function compute(attrName, ui) {
|
|
1572
1542
|
const data = ui.__, leafPaints = [];
|
|
1573
|
-
let paints = data.__input[attrName],
|
|
1543
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
1574
1544
|
if (!(paints instanceof Array))
|
|
1575
1545
|
paints = [paints];
|
|
1576
1546
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
@@ -1580,35 +1550,62 @@ function compute(attrName, ui) {
|
|
|
1580
1550
|
leafPaints.push(item);
|
|
1581
1551
|
}
|
|
1582
1552
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1583
|
-
if (leafPaints.length
|
|
1584
|
-
|
|
1585
|
-
|
|
1553
|
+
if (leafPaints.length) {
|
|
1554
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
1555
|
+
if (leafPaints.some(item => item.image))
|
|
1556
|
+
isAlphaPixel = true;
|
|
1557
|
+
isTransparent = true;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
if (attrName === 'fill') {
|
|
1561
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
1562
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
1563
|
+
}
|
|
1564
|
+
else {
|
|
1565
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1566
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1567
|
+
}
|
|
1586
1568
|
}
|
|
1587
1569
|
function getLeafPaint(attrName, paint, ui) {
|
|
1588
1570
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
1589
1571
|
return undefined;
|
|
1572
|
+
let data;
|
|
1590
1573
|
const { boxBounds } = ui.__layout;
|
|
1591
1574
|
switch (paint.type) {
|
|
1592
|
-
case 'solid':
|
|
1593
|
-
let { type, blendMode, color, opacity } = paint;
|
|
1594
|
-
return { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
1595
1575
|
case 'image':
|
|
1596
|
-
|
|
1576
|
+
data = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1577
|
+
break;
|
|
1597
1578
|
case 'linear':
|
|
1598
|
-
|
|
1579
|
+
data = draw.PaintGradient.linearGradient(paint, boxBounds);
|
|
1580
|
+
break;
|
|
1599
1581
|
case 'radial':
|
|
1600
|
-
|
|
1582
|
+
data = draw.PaintGradient.radialGradient(paint, boxBounds);
|
|
1583
|
+
break;
|
|
1601
1584
|
case 'angular':
|
|
1602
|
-
|
|
1585
|
+
data = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
1586
|
+
break;
|
|
1587
|
+
case 'solid':
|
|
1588
|
+
const { type, blendMode, color, opacity } = paint;
|
|
1589
|
+
data = { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
1590
|
+
break;
|
|
1603
1591
|
default:
|
|
1604
|
-
|
|
1592
|
+
if (paint.r !== undefined)
|
|
1593
|
+
data = { type: 'solid', style: draw.ColorConvert.string(paint) };
|
|
1594
|
+
}
|
|
1595
|
+
if (data) {
|
|
1596
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1597
|
+
data.isTransparent = true;
|
|
1598
|
+
if (paint.blendMode)
|
|
1599
|
+
data.blendMode = paint.blendMode;
|
|
1605
1600
|
}
|
|
1601
|
+
return data;
|
|
1606
1602
|
}
|
|
1607
1603
|
|
|
1608
1604
|
const PaintModule = {
|
|
1609
1605
|
compute,
|
|
1610
1606
|
fill,
|
|
1611
1607
|
fills,
|
|
1608
|
+
fillPathOrText,
|
|
1612
1609
|
fillText,
|
|
1613
1610
|
stroke,
|
|
1614
1611
|
strokes,
|
|
@@ -1667,12 +1664,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1667
1664
|
|
|
1668
1665
|
const { get: get$2, translate } = core.MatrixHelper;
|
|
1669
1666
|
const tempBox = new core.Bounds();
|
|
1670
|
-
const tempPoint = {};
|
|
1671
1667
|
const tempScaleData = {};
|
|
1668
|
+
const tempImage = {};
|
|
1672
1669
|
function createData(leafPaint, image, paint, box) {
|
|
1673
|
-
const {
|
|
1674
|
-
if (blendMode)
|
|
1675
|
-
leafPaint.blendMode = blendMode;
|
|
1670
|
+
const { changeful, sync } = paint;
|
|
1676
1671
|
if (changeful)
|
|
1677
1672
|
leafPaint.changeful = changeful;
|
|
1678
1673
|
if (sync)
|
|
@@ -1680,38 +1675,38 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1680
1675
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1681
1676
|
}
|
|
1682
1677
|
function getPatternData(paint, box, image) {
|
|
1683
|
-
let { width, height } = image;
|
|
1684
1678
|
if (paint.padding)
|
|
1685
1679
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1686
1680
|
if (paint.mode === 'strench')
|
|
1687
1681
|
paint.mode = 'stretch';
|
|
1682
|
+
let { width, height } = image;
|
|
1688
1683
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1689
1684
|
const sameBox = box.width === width && box.height === height;
|
|
1690
1685
|
const data = { mode };
|
|
1691
1686
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1692
|
-
|
|
1693
|
-
let
|
|
1687
|
+
core.BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
1688
|
+
let scaleX, scaleY;
|
|
1694
1689
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
1695
1690
|
if (!sameBox || rotation) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1691
|
+
scaleX = scaleY = core.BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
1692
|
+
core.BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
1693
|
+
core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1699
1694
|
}
|
|
1700
1695
|
}
|
|
1701
|
-
else
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1696
|
+
else {
|
|
1697
|
+
if (scale || size) {
|
|
1698
|
+
core.MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
1699
|
+
scaleX = tempScaleData.scaleX;
|
|
1700
|
+
scaleY = tempScaleData.scaleY;
|
|
1701
|
+
}
|
|
1702
|
+
if (align) {
|
|
1703
|
+
if (scaleX)
|
|
1704
|
+
core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1705
|
+
core.AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
1706
|
+
}
|
|
1712
1707
|
}
|
|
1713
1708
|
if (offset)
|
|
1714
|
-
|
|
1709
|
+
core.PointHelper.move(tempImage, offset);
|
|
1715
1710
|
switch (mode) {
|
|
1716
1711
|
case 'stretch':
|
|
1717
1712
|
if (!sameBox)
|
|
@@ -1719,12 +1714,12 @@ function getPatternData(paint, box, image) {
|
|
|
1719
1714
|
break;
|
|
1720
1715
|
case 'normal':
|
|
1721
1716
|
case 'clip':
|
|
1722
|
-
if (x || y || scaleX || rotation)
|
|
1723
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1717
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1718
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1724
1719
|
break;
|
|
1725
1720
|
case 'repeat':
|
|
1726
1721
|
if (!sameBox || scaleX || rotation)
|
|
1727
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
1722
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
1728
1723
|
if (!repeat)
|
|
1729
1724
|
data.repeat = 'repeat';
|
|
1730
1725
|
break;
|
|
@@ -1732,7 +1727,7 @@ function getPatternData(paint, box, image) {
|
|
|
1732
1727
|
case 'cover':
|
|
1733
1728
|
default:
|
|
1734
1729
|
if (scaleX)
|
|
1735
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1730
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1736
1731
|
}
|
|
1737
1732
|
if (!data.transform) {
|
|
1738
1733
|
if (box.x || box.y) {
|
|
@@ -1765,6 +1760,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1765
1760
|
}
|
|
1766
1761
|
else {
|
|
1767
1762
|
leafPaint = { type: paint.type, image };
|
|
1763
|
+
if (image.hasAlphaPixel)
|
|
1764
|
+
leafPaint.isTransparent = true;
|
|
1768
1765
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
1769
1766
|
}
|
|
1770
1767
|
if (firstUse || image.loading)
|
|
@@ -1789,7 +1786,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1789
1786
|
ignoreRender(ui, false);
|
|
1790
1787
|
if (!ui.destroyed) {
|
|
1791
1788
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
1792
|
-
if (image.
|
|
1789
|
+
if (image.hasAlphaPixel)
|
|
1793
1790
|
ui.__layout.hitCanvasChanged = true;
|
|
1794
1791
|
ui.forceUpdate('surface');
|
|
1795
1792
|
}
|
|
@@ -1801,6 +1798,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1801
1798
|
onLoadError(ui, event, error);
|
|
1802
1799
|
leafPaint.loadId = null;
|
|
1803
1800
|
});
|
|
1801
|
+
if (ui.placeholderColor) {
|
|
1802
|
+
if (!ui.placeholderDelay)
|
|
1803
|
+
image.isPlacehold = true;
|
|
1804
|
+
else
|
|
1805
|
+
setTimeout(() => {
|
|
1806
|
+
if (!image.ready) {
|
|
1807
|
+
image.isPlacehold = true;
|
|
1808
|
+
ui.forceUpdate('surface');
|
|
1809
|
+
}
|
|
1810
|
+
}, ui.placeholderDelay);
|
|
1811
|
+
}
|
|
1804
1812
|
}
|
|
1805
1813
|
return leafPaint;
|
|
1806
1814
|
}
|
|
@@ -2038,32 +2046,33 @@ const PaintImageModule = {
|
|
|
2038
2046
|
repeatMode
|
|
2039
2047
|
};
|
|
2040
2048
|
|
|
2041
|
-
const { toPoint: toPoint$2 } = core.AroundHelper;
|
|
2049
|
+
const { toPoint: toPoint$2 } = core.AroundHelper, { hasTransparent } = draw.ColorConvert;
|
|
2042
2050
|
const realFrom$2 = {};
|
|
2043
2051
|
const realTo$2 = {};
|
|
2044
2052
|
function linearGradient(paint, box) {
|
|
2045
|
-
let { from, to, type,
|
|
2053
|
+
let { from, to, type, opacity } = paint;
|
|
2046
2054
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
2047
2055
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
2048
2056
|
const style = core.Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
2049
|
-
applyStops(style, paint.stops, opacity);
|
|
2050
2057
|
const data = { type, style };
|
|
2051
|
-
|
|
2052
|
-
data.blendMode = blendMode;
|
|
2058
|
+
applyStops(data, style, paint.stops, opacity);
|
|
2053
2059
|
return data;
|
|
2054
2060
|
}
|
|
2055
|
-
function applyStops(gradient, stops, opacity) {
|
|
2061
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
2056
2062
|
if (stops) {
|
|
2057
|
-
let stop;
|
|
2063
|
+
let stop, color, offset, isTransparent;
|
|
2058
2064
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
2059
2065
|
stop = stops[i];
|
|
2060
|
-
if (typeof stop === 'string')
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
+
if (typeof stop === 'string')
|
|
2067
|
+
offset = i / (len - 1), color = draw.ColorConvert.string(stop, opacity);
|
|
2068
|
+
else
|
|
2069
|
+
offset = stop.offset, color = draw.ColorConvert.string(stop.color, opacity);
|
|
2070
|
+
gradient.addColorStop(offset, color);
|
|
2071
|
+
if (!isTransparent && hasTransparent(color))
|
|
2072
|
+
isTransparent = true;
|
|
2066
2073
|
}
|
|
2074
|
+
if (isTransparent)
|
|
2075
|
+
data.isTransparent = true;
|
|
2067
2076
|
}
|
|
2068
2077
|
}
|
|
2069
2078
|
|
|
@@ -2073,17 +2082,15 @@ const { toPoint: toPoint$1 } = core.AroundHelper;
|
|
|
2073
2082
|
const realFrom$1 = {};
|
|
2074
2083
|
const realTo$1 = {};
|
|
2075
2084
|
function radialGradient(paint, box) {
|
|
2076
|
-
let { from, to, type, opacity,
|
|
2085
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
2077
2086
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
2078
2087
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
2079
2088
|
const style = core.Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
2080
|
-
applyStops(style, paint.stops, opacity);
|
|
2081
2089
|
const data = { type, style };
|
|
2090
|
+
applyStops(data, style, paint.stops, opacity);
|
|
2082
2091
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
2083
2092
|
if (transform)
|
|
2084
2093
|
data.transform = transform;
|
|
2085
|
-
if (blendMode)
|
|
2086
|
-
data.blendMode = blendMode;
|
|
2087
2094
|
return data;
|
|
2088
2095
|
}
|
|
2089
2096
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -2109,17 +2116,15 @@ const { toPoint } = core.AroundHelper;
|
|
|
2109
2116
|
const realFrom = {};
|
|
2110
2117
|
const realTo = {};
|
|
2111
2118
|
function conicGradient(paint, box) {
|
|
2112
|
-
let { from, to, type, opacity,
|
|
2119
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
2113
2120
|
toPoint(from || 'center', box, realFrom);
|
|
2114
2121
|
toPoint(to || 'bottom', box, realTo);
|
|
2115
2122
|
const style = core.Platform.conicGradientSupport ? core.Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : core.Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
2116
|
-
applyStops(style, paint.stops, opacity);
|
|
2117
2123
|
const data = { type, style };
|
|
2124
|
+
applyStops(data, style, paint.stops, opacity);
|
|
2118
2125
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, core.Platform.conicGradientRotate90);
|
|
2119
2126
|
if (transform)
|
|
2120
2127
|
data.transform = transform;
|
|
2121
|
-
if (blendMode)
|
|
2122
|
-
data.blendMode = blendMode;
|
|
2123
2128
|
return data;
|
|
2124
2129
|
}
|
|
2125
2130
|
|
|
@@ -2452,6 +2457,8 @@ function createRows(drawData, content, style) {
|
|
|
2452
2457
|
lastCharType = null;
|
|
2453
2458
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
2454
2459
|
word = { data: [] }, row = { words: [] };
|
|
2460
|
+
if (__letterSpacing)
|
|
2461
|
+
content = [...content];
|
|
2455
2462
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
2456
2463
|
char = content[i];
|
|
2457
2464
|
if (char === '\n') {
|
|
@@ -2894,4 +2901,3 @@ Object.keys(core$1).forEach(function (k) {
|
|
|
2894
2901
|
get: function () { return core$1[k]; }
|
|
2895
2902
|
});
|
|
2896
2903
|
});
|
|
2897
|
-
//# sourceMappingURL=web.cjs.map
|