@visactor/vrender-core 0.16.14-alpha.2 → 0.16.14-alpha.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/cjs/common/utils.d.ts +1 -0
- package/cjs/common/utils.js +10 -1
- package/cjs/common/utils.js.map +1 -1
- package/cjs/core/graphic-utils.d.ts +3 -1
- package/cjs/core/graphic-utils.js +4 -2
- package/cjs/core/graphic-utils.js.map +1 -1
- package/cjs/graphic/text.js +15 -10
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/wrap-text.js +6 -5
- package/cjs/graphic/wrap-text.js.map +1 -1
- package/cjs/interface/core.d.ts +3 -1
- package/cjs/interface/core.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +1 -1
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/render/contributions/render/text-render.js +2 -2
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/dist/index.js +266 -252
- package/dist/index.min.js +1 -1
- package/es/common/utils.d.ts +1 -0
- package/es/common/utils.js +8 -1
- package/es/common/utils.js.map +1 -1
- package/es/core/graphic-utils.d.ts +3 -1
- package/es/core/graphic-utils.js +5 -1
- package/es/core/graphic-utils.js.map +1 -1
- package/es/graphic/text.js +11 -11
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/wrap-text.js +6 -4
- package/es/graphic/wrap-text.js.map +1 -1
- package/es/interface/core.d.ts +3 -1
- package/es/interface/core.js.map +1 -1
- package/es/interface/graphic/text.d.ts +1 -1
- package/es/interface/graphic/text.js.map +1 -1
- package/es/render/contributions/render/text-render.js +3 -1
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5425,6 +5425,247 @@
|
|
|
5425
5425
|
return containPath(commands, lineWidth, true, x, y);
|
|
5426
5426
|
}
|
|
5427
5427
|
|
|
5428
|
+
exports.Edge = void 0;
|
|
5429
|
+
(function (Edge) {
|
|
5430
|
+
Edge[Edge["Top"] = 1] = "Top";
|
|
5431
|
+
Edge[Edge["Right"] = 2] = "Right";
|
|
5432
|
+
Edge[Edge["Bottom"] = 4] = "Bottom";
|
|
5433
|
+
Edge[Edge["Left"] = 8] = "Left";
|
|
5434
|
+
Edge[Edge["ALL"] = 15] = "ALL";
|
|
5435
|
+
})(exports.Edge || (exports.Edge = {}));
|
|
5436
|
+
const _strokeVec4 = [
|
|
5437
|
+
false,
|
|
5438
|
+
false,
|
|
5439
|
+
false,
|
|
5440
|
+
false
|
|
5441
|
+
];
|
|
5442
|
+
const parseStroke = (stroke) => {
|
|
5443
|
+
var _a;
|
|
5444
|
+
let isFullStroke = true;
|
|
5445
|
+
if (vutils.isBoolean(stroke, true)) {
|
|
5446
|
+
for (let i = 0; i < 4; i++) {
|
|
5447
|
+
_strokeVec4[i] = stroke;
|
|
5448
|
+
isFullStroke && (isFullStroke = !!((_a = _strokeVec4[i]) !== null && _a !== void 0 ? _a : true));
|
|
5449
|
+
}
|
|
5450
|
+
isFullStroke = stroke;
|
|
5451
|
+
}
|
|
5452
|
+
else if (Array.isArray(stroke)) {
|
|
5453
|
+
for (let i = 0; i < 4; i++) {
|
|
5454
|
+
_strokeVec4[i] = !!stroke[i];
|
|
5455
|
+
isFullStroke && (isFullStroke = !!_strokeVec4[i]);
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
else {
|
|
5459
|
+
_strokeVec4[0] = false;
|
|
5460
|
+
_strokeVec4[1] = false;
|
|
5461
|
+
_strokeVec4[2] = false;
|
|
5462
|
+
_strokeVec4[3] = false;
|
|
5463
|
+
}
|
|
5464
|
+
return {
|
|
5465
|
+
isFullStroke,
|
|
5466
|
+
stroke: _strokeVec4
|
|
5467
|
+
};
|
|
5468
|
+
};
|
|
5469
|
+
const _paddingVec4 = [0, 0, 0, 0];
|
|
5470
|
+
const parsePadding = (padding) => {
|
|
5471
|
+
if (!padding) {
|
|
5472
|
+
return 0;
|
|
5473
|
+
}
|
|
5474
|
+
if (vutils.isArray(padding)) {
|
|
5475
|
+
if (padding.length === 0) {
|
|
5476
|
+
return 0;
|
|
5477
|
+
}
|
|
5478
|
+
else if (padding.length === 1) {
|
|
5479
|
+
return padding[0];
|
|
5480
|
+
}
|
|
5481
|
+
else if (padding.length === 2) {
|
|
5482
|
+
_paddingVec4[0] = padding[0];
|
|
5483
|
+
_paddingVec4[2] = padding[0];
|
|
5484
|
+
_paddingVec4[1] = padding[1];
|
|
5485
|
+
_paddingVec4[3] = padding[1];
|
|
5486
|
+
return _paddingVec4;
|
|
5487
|
+
}
|
|
5488
|
+
return padding;
|
|
5489
|
+
}
|
|
5490
|
+
return padding;
|
|
5491
|
+
};
|
|
5492
|
+
const _coords = [
|
|
5493
|
+
{ x: 0, y: 0 },
|
|
5494
|
+
{ x: 0, y: 0 },
|
|
5495
|
+
{ x: 0, y: 0 },
|
|
5496
|
+
{ x: 0, y: 0 }
|
|
5497
|
+
];
|
|
5498
|
+
const indexList = [1, 2, 3, 0, 1, 2, 3, 0];
|
|
5499
|
+
function circleBounds(startAngle, endAngle, radius, bounds) {
|
|
5500
|
+
while (startAngle >= vutils.pi2) {
|
|
5501
|
+
startAngle -= vutils.pi2;
|
|
5502
|
+
}
|
|
5503
|
+
while (startAngle < 0) {
|
|
5504
|
+
startAngle += vutils.pi2;
|
|
5505
|
+
}
|
|
5506
|
+
while (startAngle > endAngle) {
|
|
5507
|
+
endAngle += vutils.pi2;
|
|
5508
|
+
}
|
|
5509
|
+
_coords[0].x = radius;
|
|
5510
|
+
_coords[1].y = radius;
|
|
5511
|
+
_coords[2].x = -radius;
|
|
5512
|
+
_coords[3].y = -radius;
|
|
5513
|
+
const startIdx = Math.ceil(startAngle / vutils.halfPi) % 4;
|
|
5514
|
+
const endIdx = Math.ceil(endAngle / vutils.halfPi) % 4;
|
|
5515
|
+
bounds.add(vutils.cos(startAngle) * radius, vutils.sin(startAngle) * radius);
|
|
5516
|
+
bounds.add(vutils.cos(endAngle) * radius, vutils.sin(endAngle) * radius);
|
|
5517
|
+
if (startIdx !== endIdx || endAngle - startAngle > vutils.pi) {
|
|
5518
|
+
let match = false;
|
|
5519
|
+
for (let i = 0; i < indexList.length; i++) {
|
|
5520
|
+
if (!match && startIdx === indexList[i]) {
|
|
5521
|
+
match = true;
|
|
5522
|
+
const p = _coords[startIdx];
|
|
5523
|
+
bounds.add(p.x, p.y);
|
|
5524
|
+
continue;
|
|
5525
|
+
}
|
|
5526
|
+
else if (match && endIdx === indexList[i]) {
|
|
5527
|
+
break;
|
|
5528
|
+
}
|
|
5529
|
+
if (match) {
|
|
5530
|
+
const p = _coords[indexList[i]];
|
|
5531
|
+
bounds.add(p.x, p.y);
|
|
5532
|
+
}
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
function pointsEqual(pointsA, pointsB) {
|
|
5537
|
+
if (!pointsA || !pointsB) {
|
|
5538
|
+
return false;
|
|
5539
|
+
}
|
|
5540
|
+
if (Array.isArray(pointsA) && Array.isArray(pointsB)) {
|
|
5541
|
+
if (pointsA.length !== pointsB.length) {
|
|
5542
|
+
return false;
|
|
5543
|
+
}
|
|
5544
|
+
return pointsA.every((point, index) => pointEqual(point, pointsB[index]));
|
|
5545
|
+
}
|
|
5546
|
+
if (!Number.isNaN(pointsA.x + pointsA.y)) {
|
|
5547
|
+
return pointEqual(pointsA, pointsB);
|
|
5548
|
+
}
|
|
5549
|
+
return false;
|
|
5550
|
+
}
|
|
5551
|
+
function pointEqual(pointA, pointB) {
|
|
5552
|
+
return (pointA.x === pointB.x &&
|
|
5553
|
+
pointA.y === pointB.y &&
|
|
5554
|
+
pointA.x1 === pointB.x1 &&
|
|
5555
|
+
pointA.y1 === pointB.y1 &&
|
|
5556
|
+
pointA.defined === pointB.defined);
|
|
5557
|
+
}
|
|
5558
|
+
function pointInterpolation(pointA, pointB, ratio) {
|
|
5559
|
+
const { x, y } = vutils.pointAt(pointA.x, pointA.y, pointB.x, pointB.y, ratio);
|
|
5560
|
+
const { x: x1, y: y1 } = vutils.pointAt(pointA.x1, pointA.y1, pointB.x1, pointB.y1, ratio);
|
|
5561
|
+
const point = new vutils.Point(x, y, x1, y1);
|
|
5562
|
+
point.defined = pointB.defined;
|
|
5563
|
+
return point;
|
|
5564
|
+
}
|
|
5565
|
+
function pointInterpolationHighPerformance(pointA, pointB, ratio, point) {
|
|
5566
|
+
const { x, y } = vutils.pointAt(pointA.x, pointA.y, pointB.x, pointB.y, ratio);
|
|
5567
|
+
const { x: x1, y: y1 } = vutils.pointAt(pointA.x1, pointA.y1, pointB.x1, pointB.y1, ratio);
|
|
5568
|
+
point.x = x;
|
|
5569
|
+
point.y = y;
|
|
5570
|
+
point.x1 = x1;
|
|
5571
|
+
point.y1 = y1;
|
|
5572
|
+
point.defined = pointB.defined;
|
|
5573
|
+
return point;
|
|
5574
|
+
}
|
|
5575
|
+
function pointsInterpolation(pointsA, pointsB, ratio) {
|
|
5576
|
+
if (!pointsA || !pointsB) {
|
|
5577
|
+
return [];
|
|
5578
|
+
}
|
|
5579
|
+
if (!Array.isArray(pointsA)) {
|
|
5580
|
+
pointsA = [pointsA];
|
|
5581
|
+
}
|
|
5582
|
+
if (!Array.isArray(pointsB)) {
|
|
5583
|
+
pointsB = [pointsB];
|
|
5584
|
+
}
|
|
5585
|
+
let points = [];
|
|
5586
|
+
if (pointsA.length > pointsB.length) {
|
|
5587
|
+
points = pointsB.map(point => {
|
|
5588
|
+
const p = new vutils.Point(point.x, point.y, point.x1, point.y1);
|
|
5589
|
+
p.defined = point.defined;
|
|
5590
|
+
return p;
|
|
5591
|
+
});
|
|
5592
|
+
for (let i = 0; i < pointsB.length; i++) {
|
|
5593
|
+
points[i] = pointInterpolation(pointsA[i], pointsB[i], ratio);
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5596
|
+
else {
|
|
5597
|
+
points = pointsB.map(point => {
|
|
5598
|
+
const p = new vutils.Point(point.x, point.y, point.x1, point.y1);
|
|
5599
|
+
p.defined = point.defined;
|
|
5600
|
+
return p;
|
|
5601
|
+
});
|
|
5602
|
+
for (let i = 0; i < pointsA.length; i++) {
|
|
5603
|
+
points[i] = pointInterpolation(pointsA[i], pointsB[i], ratio);
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
return points;
|
|
5607
|
+
}
|
|
5608
|
+
const transformKeys = [
|
|
5609
|
+
'x',
|
|
5610
|
+
'y',
|
|
5611
|
+
'dx',
|
|
5612
|
+
'dy',
|
|
5613
|
+
'scaleX',
|
|
5614
|
+
'scaleY',
|
|
5615
|
+
'angle',
|
|
5616
|
+
'anchor',
|
|
5617
|
+
'postMatrix',
|
|
5618
|
+
'scrollX',
|
|
5619
|
+
'scrollY'
|
|
5620
|
+
];
|
|
5621
|
+
const isTransformKey = (key) => {
|
|
5622
|
+
return transformKeys.includes(key);
|
|
5623
|
+
};
|
|
5624
|
+
function getAttributeFromDefaultAttrList(attr, key) {
|
|
5625
|
+
if (vutils.isArray(attr)) {
|
|
5626
|
+
let val;
|
|
5627
|
+
for (let i = 0; i < attr.length && val === undefined; i++) {
|
|
5628
|
+
val = attr[i][key];
|
|
5629
|
+
}
|
|
5630
|
+
return val;
|
|
5631
|
+
}
|
|
5632
|
+
return attr[key];
|
|
5633
|
+
}
|
|
5634
|
+
class RafBasedSTO {
|
|
5635
|
+
constructor() {
|
|
5636
|
+
this.durations = [];
|
|
5637
|
+
this.timeout = RafBasedSTO.TimeOut;
|
|
5638
|
+
this.lastDate = 0;
|
|
5639
|
+
this.durationsListThreshold = 30;
|
|
5640
|
+
}
|
|
5641
|
+
call(cb) {
|
|
5642
|
+
this.lastDate = Date.now();
|
|
5643
|
+
return setTimeout(() => {
|
|
5644
|
+
this.appendDuration(Date.now() - this.lastDate);
|
|
5645
|
+
cb(0);
|
|
5646
|
+
}, this.timeout, true);
|
|
5647
|
+
}
|
|
5648
|
+
clear(h) {
|
|
5649
|
+
clearTimeout(h);
|
|
5650
|
+
}
|
|
5651
|
+
appendDuration(d) {
|
|
5652
|
+
this.durations.push(d);
|
|
5653
|
+
if (this.durations.length > this.durationsListThreshold) {
|
|
5654
|
+
this.durations.shift();
|
|
5655
|
+
}
|
|
5656
|
+
this.timeout = Math.min(Math.max(this.durations.reduce((a, b) => a + b, 0) / this.durations.length, 1000 / 60), 1000 / 30);
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
RafBasedSTO.TimeOut = 1000 / 60;
|
|
5660
|
+
const rafBasedSto = new RafBasedSTO();
|
|
5661
|
+
const calculateLineHeight = (lineHeight, fontSize) => {
|
|
5662
|
+
if (vutils.isString(lineHeight) && lineHeight[lineHeight.length - 1] === '%') {
|
|
5663
|
+
const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
|
|
5664
|
+
return fontSize * scale;
|
|
5665
|
+
}
|
|
5666
|
+
return lineHeight;
|
|
5667
|
+
};
|
|
5668
|
+
|
|
5428
5669
|
exports.DefaultGraphicUtil = class DefaultGraphicUtil {
|
|
5429
5670
|
constructor(contributions, global) {
|
|
5430
5671
|
this.contributions = contributions;
|
|
@@ -5475,7 +5716,7 @@
|
|
|
5475
5716
|
return new vutils.TextMeasure(Object.assign({ defaultFontParams: {
|
|
5476
5717
|
fontFamily: DefaultTextStyle.fontFamily,
|
|
5477
5718
|
fontSize: DefaultTextStyle.fontSize
|
|
5478
|
-
}, getCanvasForMeasure: getCanvasForMeasure || (() => this.canvas), getTextBounds: undefined, specialCharSet: '-/: .,@%\'"~' + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
|
|
5719
|
+
}, getCanvasForMeasure: getCanvasForMeasure || (() => this.canvas), getTextBounds: undefined, specialCharSet: '-/: .,@%\'"~' + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), Object.assign(Object.assign({}, textSpec), { lineHeight: calculateLineHeight(textSpec === null || textSpec === void 0 ? void 0 : textSpec.lineHeight, textSpec === null || textSpec === void 0 ? void 0 : textSpec.fontSize) }));
|
|
5479
5720
|
}
|
|
5480
5721
|
};
|
|
5481
5722
|
exports.DefaultGraphicUtil = __decorate([
|
|
@@ -8783,240 +9024,6 @@
|
|
|
8783
9024
|
easing: 'quadInOut'
|
|
8784
9025
|
};
|
|
8785
9026
|
|
|
8786
|
-
exports.Edge = void 0;
|
|
8787
|
-
(function (Edge) {
|
|
8788
|
-
Edge[Edge["Top"] = 1] = "Top";
|
|
8789
|
-
Edge[Edge["Right"] = 2] = "Right";
|
|
8790
|
-
Edge[Edge["Bottom"] = 4] = "Bottom";
|
|
8791
|
-
Edge[Edge["Left"] = 8] = "Left";
|
|
8792
|
-
Edge[Edge["ALL"] = 15] = "ALL";
|
|
8793
|
-
})(exports.Edge || (exports.Edge = {}));
|
|
8794
|
-
const _strokeVec4 = [
|
|
8795
|
-
false,
|
|
8796
|
-
false,
|
|
8797
|
-
false,
|
|
8798
|
-
false
|
|
8799
|
-
];
|
|
8800
|
-
const parseStroke = (stroke) => {
|
|
8801
|
-
var _a;
|
|
8802
|
-
let isFullStroke = true;
|
|
8803
|
-
if (vutils.isBoolean(stroke, true)) {
|
|
8804
|
-
for (let i = 0; i < 4; i++) {
|
|
8805
|
-
_strokeVec4[i] = stroke;
|
|
8806
|
-
isFullStroke && (isFullStroke = !!((_a = _strokeVec4[i]) !== null && _a !== void 0 ? _a : true));
|
|
8807
|
-
}
|
|
8808
|
-
isFullStroke = stroke;
|
|
8809
|
-
}
|
|
8810
|
-
else if (Array.isArray(stroke)) {
|
|
8811
|
-
for (let i = 0; i < 4; i++) {
|
|
8812
|
-
_strokeVec4[i] = !!stroke[i];
|
|
8813
|
-
isFullStroke && (isFullStroke = !!_strokeVec4[i]);
|
|
8814
|
-
}
|
|
8815
|
-
}
|
|
8816
|
-
else {
|
|
8817
|
-
_strokeVec4[0] = false;
|
|
8818
|
-
_strokeVec4[1] = false;
|
|
8819
|
-
_strokeVec4[2] = false;
|
|
8820
|
-
_strokeVec4[3] = false;
|
|
8821
|
-
}
|
|
8822
|
-
return {
|
|
8823
|
-
isFullStroke,
|
|
8824
|
-
stroke: _strokeVec4
|
|
8825
|
-
};
|
|
8826
|
-
};
|
|
8827
|
-
const _paddingVec4 = [0, 0, 0, 0];
|
|
8828
|
-
const parsePadding = (padding) => {
|
|
8829
|
-
if (!padding) {
|
|
8830
|
-
return 0;
|
|
8831
|
-
}
|
|
8832
|
-
if (vutils.isArray(padding)) {
|
|
8833
|
-
if (padding.length === 0) {
|
|
8834
|
-
return 0;
|
|
8835
|
-
}
|
|
8836
|
-
else if (padding.length === 1) {
|
|
8837
|
-
return padding[0];
|
|
8838
|
-
}
|
|
8839
|
-
else if (padding.length === 2) {
|
|
8840
|
-
_paddingVec4[0] = padding[0];
|
|
8841
|
-
_paddingVec4[2] = padding[0];
|
|
8842
|
-
_paddingVec4[1] = padding[1];
|
|
8843
|
-
_paddingVec4[3] = padding[1];
|
|
8844
|
-
return _paddingVec4;
|
|
8845
|
-
}
|
|
8846
|
-
return padding;
|
|
8847
|
-
}
|
|
8848
|
-
return padding;
|
|
8849
|
-
};
|
|
8850
|
-
const _coords = [
|
|
8851
|
-
{ x: 0, y: 0 },
|
|
8852
|
-
{ x: 0, y: 0 },
|
|
8853
|
-
{ x: 0, y: 0 },
|
|
8854
|
-
{ x: 0, y: 0 }
|
|
8855
|
-
];
|
|
8856
|
-
const indexList = [1, 2, 3, 0, 1, 2, 3, 0];
|
|
8857
|
-
function circleBounds(startAngle, endAngle, radius, bounds) {
|
|
8858
|
-
while (startAngle >= vutils.pi2) {
|
|
8859
|
-
startAngle -= vutils.pi2;
|
|
8860
|
-
}
|
|
8861
|
-
while (startAngle < 0) {
|
|
8862
|
-
startAngle += vutils.pi2;
|
|
8863
|
-
}
|
|
8864
|
-
while (startAngle > endAngle) {
|
|
8865
|
-
endAngle += vutils.pi2;
|
|
8866
|
-
}
|
|
8867
|
-
_coords[0].x = radius;
|
|
8868
|
-
_coords[1].y = radius;
|
|
8869
|
-
_coords[2].x = -radius;
|
|
8870
|
-
_coords[3].y = -radius;
|
|
8871
|
-
const startIdx = Math.ceil(startAngle / vutils.halfPi) % 4;
|
|
8872
|
-
const endIdx = Math.ceil(endAngle / vutils.halfPi) % 4;
|
|
8873
|
-
bounds.add(vutils.cos(startAngle) * radius, vutils.sin(startAngle) * radius);
|
|
8874
|
-
bounds.add(vutils.cos(endAngle) * radius, vutils.sin(endAngle) * radius);
|
|
8875
|
-
if (startIdx !== endIdx || endAngle - startAngle > vutils.pi) {
|
|
8876
|
-
let match = false;
|
|
8877
|
-
for (let i = 0; i < indexList.length; i++) {
|
|
8878
|
-
if (!match && startIdx === indexList[i]) {
|
|
8879
|
-
match = true;
|
|
8880
|
-
const p = _coords[startIdx];
|
|
8881
|
-
bounds.add(p.x, p.y);
|
|
8882
|
-
continue;
|
|
8883
|
-
}
|
|
8884
|
-
else if (match && endIdx === indexList[i]) {
|
|
8885
|
-
break;
|
|
8886
|
-
}
|
|
8887
|
-
if (match) {
|
|
8888
|
-
const p = _coords[indexList[i]];
|
|
8889
|
-
bounds.add(p.x, p.y);
|
|
8890
|
-
}
|
|
8891
|
-
}
|
|
8892
|
-
}
|
|
8893
|
-
}
|
|
8894
|
-
function pointsEqual(pointsA, pointsB) {
|
|
8895
|
-
if (!pointsA || !pointsB) {
|
|
8896
|
-
return false;
|
|
8897
|
-
}
|
|
8898
|
-
if (Array.isArray(pointsA) && Array.isArray(pointsB)) {
|
|
8899
|
-
if (pointsA.length !== pointsB.length) {
|
|
8900
|
-
return false;
|
|
8901
|
-
}
|
|
8902
|
-
return pointsA.every((point, index) => pointEqual(point, pointsB[index]));
|
|
8903
|
-
}
|
|
8904
|
-
if (!Number.isNaN(pointsA.x + pointsA.y)) {
|
|
8905
|
-
return pointEqual(pointsA, pointsB);
|
|
8906
|
-
}
|
|
8907
|
-
return false;
|
|
8908
|
-
}
|
|
8909
|
-
function pointEqual(pointA, pointB) {
|
|
8910
|
-
return (pointA.x === pointB.x &&
|
|
8911
|
-
pointA.y === pointB.y &&
|
|
8912
|
-
pointA.x1 === pointB.x1 &&
|
|
8913
|
-
pointA.y1 === pointB.y1 &&
|
|
8914
|
-
pointA.defined === pointB.defined);
|
|
8915
|
-
}
|
|
8916
|
-
function pointInterpolation(pointA, pointB, ratio) {
|
|
8917
|
-
const { x, y } = vutils.pointAt(pointA.x, pointA.y, pointB.x, pointB.y, ratio);
|
|
8918
|
-
const { x: x1, y: y1 } = vutils.pointAt(pointA.x1, pointA.y1, pointB.x1, pointB.y1, ratio);
|
|
8919
|
-
const point = new vutils.Point(x, y, x1, y1);
|
|
8920
|
-
point.defined = pointB.defined;
|
|
8921
|
-
return point;
|
|
8922
|
-
}
|
|
8923
|
-
function pointInterpolationHighPerformance(pointA, pointB, ratio, point) {
|
|
8924
|
-
const { x, y } = vutils.pointAt(pointA.x, pointA.y, pointB.x, pointB.y, ratio);
|
|
8925
|
-
const { x: x1, y: y1 } = vutils.pointAt(pointA.x1, pointA.y1, pointB.x1, pointB.y1, ratio);
|
|
8926
|
-
point.x = x;
|
|
8927
|
-
point.y = y;
|
|
8928
|
-
point.x1 = x1;
|
|
8929
|
-
point.y1 = y1;
|
|
8930
|
-
point.defined = pointB.defined;
|
|
8931
|
-
return point;
|
|
8932
|
-
}
|
|
8933
|
-
function pointsInterpolation(pointsA, pointsB, ratio) {
|
|
8934
|
-
if (!pointsA || !pointsB) {
|
|
8935
|
-
return [];
|
|
8936
|
-
}
|
|
8937
|
-
if (!Array.isArray(pointsA)) {
|
|
8938
|
-
pointsA = [pointsA];
|
|
8939
|
-
}
|
|
8940
|
-
if (!Array.isArray(pointsB)) {
|
|
8941
|
-
pointsB = [pointsB];
|
|
8942
|
-
}
|
|
8943
|
-
let points = [];
|
|
8944
|
-
if (pointsA.length > pointsB.length) {
|
|
8945
|
-
points = pointsB.map(point => {
|
|
8946
|
-
const p = new vutils.Point(point.x, point.y, point.x1, point.y1);
|
|
8947
|
-
p.defined = point.defined;
|
|
8948
|
-
return p;
|
|
8949
|
-
});
|
|
8950
|
-
for (let i = 0; i < pointsB.length; i++) {
|
|
8951
|
-
points[i] = pointInterpolation(pointsA[i], pointsB[i], ratio);
|
|
8952
|
-
}
|
|
8953
|
-
}
|
|
8954
|
-
else {
|
|
8955
|
-
points = pointsB.map(point => {
|
|
8956
|
-
const p = new vutils.Point(point.x, point.y, point.x1, point.y1);
|
|
8957
|
-
p.defined = point.defined;
|
|
8958
|
-
return p;
|
|
8959
|
-
});
|
|
8960
|
-
for (let i = 0; i < pointsA.length; i++) {
|
|
8961
|
-
points[i] = pointInterpolation(pointsA[i], pointsB[i], ratio);
|
|
8962
|
-
}
|
|
8963
|
-
}
|
|
8964
|
-
return points;
|
|
8965
|
-
}
|
|
8966
|
-
const transformKeys = [
|
|
8967
|
-
'x',
|
|
8968
|
-
'y',
|
|
8969
|
-
'dx',
|
|
8970
|
-
'dy',
|
|
8971
|
-
'scaleX',
|
|
8972
|
-
'scaleY',
|
|
8973
|
-
'angle',
|
|
8974
|
-
'anchor',
|
|
8975
|
-
'postMatrix',
|
|
8976
|
-
'scrollX',
|
|
8977
|
-
'scrollY'
|
|
8978
|
-
];
|
|
8979
|
-
const isTransformKey = (key) => {
|
|
8980
|
-
return transformKeys.includes(key);
|
|
8981
|
-
};
|
|
8982
|
-
function getAttributeFromDefaultAttrList(attr, key) {
|
|
8983
|
-
if (vutils.isArray(attr)) {
|
|
8984
|
-
let val;
|
|
8985
|
-
for (let i = 0; i < attr.length && val === undefined; i++) {
|
|
8986
|
-
val = attr[i][key];
|
|
8987
|
-
}
|
|
8988
|
-
return val;
|
|
8989
|
-
}
|
|
8990
|
-
return attr[key];
|
|
8991
|
-
}
|
|
8992
|
-
class RafBasedSTO {
|
|
8993
|
-
constructor() {
|
|
8994
|
-
this.durations = [];
|
|
8995
|
-
this.timeout = RafBasedSTO.TimeOut;
|
|
8996
|
-
this.lastDate = 0;
|
|
8997
|
-
this.durationsListThreshold = 30;
|
|
8998
|
-
}
|
|
8999
|
-
call(cb) {
|
|
9000
|
-
this.lastDate = Date.now();
|
|
9001
|
-
return setTimeout(() => {
|
|
9002
|
-
this.appendDuration(Date.now() - this.lastDate);
|
|
9003
|
-
cb(0);
|
|
9004
|
-
}, this.timeout, true);
|
|
9005
|
-
}
|
|
9006
|
-
clear(h) {
|
|
9007
|
-
clearTimeout(h);
|
|
9008
|
-
}
|
|
9009
|
-
appendDuration(d) {
|
|
9010
|
-
this.durations.push(d);
|
|
9011
|
-
if (this.durations.length > this.durationsListThreshold) {
|
|
9012
|
-
this.durations.shift();
|
|
9013
|
-
}
|
|
9014
|
-
this.timeout = Math.min(Math.max(this.durations.reduce((a, b) => a + b, 0) / this.durations.length, 1000 / 60), 1000 / 30);
|
|
9015
|
-
}
|
|
9016
|
-
}
|
|
9017
|
-
RafBasedSTO.TimeOut = 1000 / 60;
|
|
9018
|
-
const rafBasedSto = new RafBasedSTO();
|
|
9019
|
-
|
|
9020
9027
|
class IncreaseCount extends ACustomAnimate {
|
|
9021
9028
|
constructor(from, to, duration, easing, params) {
|
|
9022
9029
|
super(from, to, duration, easing, params);
|
|
@@ -14404,11 +14411,12 @@
|
|
|
14404
14411
|
return bounds;
|
|
14405
14412
|
}
|
|
14406
14413
|
updateWrapAABBBounds(text) {
|
|
14407
|
-
var _a, _b, _c;
|
|
14414
|
+
var _a, _b, _c, _d;
|
|
14408
14415
|
const textTheme = getTheme(this).text;
|
|
14409
|
-
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize,
|
|
14416
|
+
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
|
|
14417
|
+
const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
|
|
14410
14418
|
const buf = ignoreBuf ? 0 : 2;
|
|
14411
|
-
if (!this.shouldUpdateShape() && ((
|
|
14419
|
+
if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
|
|
14412
14420
|
const bbox = this.cache.layoutData.bbox;
|
|
14413
14421
|
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
14414
14422
|
if (stroke) {
|
|
@@ -14445,8 +14453,8 @@
|
|
|
14445
14453
|
if (str !== '' && clip.str === '') {
|
|
14446
14454
|
if (ellipsis) {
|
|
14447
14455
|
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
|
|
14448
|
-
clip.str = (
|
|
14449
|
-
clip.width = (
|
|
14456
|
+
clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
|
|
14457
|
+
clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
|
|
14450
14458
|
}
|
|
14451
14459
|
else {
|
|
14452
14460
|
clip.str = '';
|
|
@@ -14535,7 +14543,8 @@
|
|
|
14535
14543
|
return this.updateWrapAABBBounds(text);
|
|
14536
14544
|
}
|
|
14537
14545
|
const buf = ignoreBuf ? 0 : Math.max(2, fontSize * 0.075);
|
|
14538
|
-
const
|
|
14546
|
+
const textFontSize = attribute.fontSize || textTheme.fontSize;
|
|
14547
|
+
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) !== null && _a !== void 0 ? _a : textFontSize + buf;
|
|
14539
14548
|
if (!this.shouldUpdateShape() && this.cache) {
|
|
14540
14549
|
width = (_b = this.cache.clipedWidth) !== null && _b !== void 0 ? _b : 0;
|
|
14541
14550
|
const dx = textDrawOffsetX(textAlign, width);
|
|
@@ -14593,7 +14602,8 @@
|
|
|
14593
14602
|
const attribute = this.attribute;
|
|
14594
14603
|
const { ignoreBuf = textTheme.ignoreBuf } = attribute;
|
|
14595
14604
|
const buf = ignoreBuf ? 0 : 2;
|
|
14596
|
-
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke,
|
|
14605
|
+
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
|
|
14606
|
+
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14597
14607
|
let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
|
|
14598
14608
|
if (!verticalMode) {
|
|
14599
14609
|
const t = textAlign;
|
|
@@ -14650,14 +14660,15 @@
|
|
|
14650
14660
|
return this._AABBBounds;
|
|
14651
14661
|
}
|
|
14652
14662
|
updateHorizontalMultilineAABBBounds(text) {
|
|
14653
|
-
var _a;
|
|
14663
|
+
var _a, _b;
|
|
14654
14664
|
const textTheme = getTheme(this).text;
|
|
14655
14665
|
const attribute = this.attribute;
|
|
14656
|
-
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight,
|
|
14666
|
+
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace } = attribute;
|
|
14667
|
+
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize);
|
|
14657
14668
|
if (whiteSpace === 'normal') {
|
|
14658
14669
|
return this.updateWrapAABBBounds(text);
|
|
14659
14670
|
}
|
|
14660
|
-
if (!this.shouldUpdateShape() && ((
|
|
14671
|
+
if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
|
|
14661
14672
|
const bbox = this.cache.layoutData.bbox;
|
|
14662
14673
|
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
14663
14674
|
if (stroke) {
|
|
@@ -14685,7 +14696,8 @@
|
|
|
14685
14696
|
const attribute = this.attribute;
|
|
14686
14697
|
const { ignoreBuf = textTheme.ignoreBuf } = attribute;
|
|
14687
14698
|
const buf = ignoreBuf ? 0 : 2;
|
|
14688
|
-
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke,
|
|
14699
|
+
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
|
|
14700
|
+
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14689
14701
|
let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
|
|
14690
14702
|
if (!verticalMode) {
|
|
14691
14703
|
const t = textAlign;
|
|
@@ -14792,11 +14804,12 @@
|
|
|
14792
14804
|
return text != null && text !== '';
|
|
14793
14805
|
}
|
|
14794
14806
|
updateMultilineAABBBounds(text) {
|
|
14795
|
-
var _a, _b, _c;
|
|
14807
|
+
var _a, _b, _c, _d;
|
|
14796
14808
|
const textTheme = getTheme(this).text;
|
|
14797
|
-
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize,
|
|
14809
|
+
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
|
|
14810
|
+
const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
|
|
14798
14811
|
const buf = ignoreBuf ? 0 : 2;
|
|
14799
|
-
if (!this.shouldUpdateShape() && ((
|
|
14812
|
+
if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
|
|
14800
14813
|
const bbox = this.cache.layoutData.bbox;
|
|
14801
14814
|
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
14802
14815
|
if (stroke) {
|
|
@@ -14833,8 +14846,8 @@
|
|
|
14833
14846
|
if (str !== '' && clip.str === '') {
|
|
14834
14847
|
if (ellipsis) {
|
|
14835
14848
|
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
|
|
14836
|
-
clip.str = (
|
|
14837
|
-
clip.width = (
|
|
14849
|
+
clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
|
|
14850
|
+
clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
|
|
14838
14851
|
}
|
|
14839
14852
|
else {
|
|
14840
14853
|
clip.str = '';
|
|
@@ -20978,7 +20991,7 @@
|
|
|
20978
20991
|
textAlign = (_a = text.getBaselineMapAlign()[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
|
|
20979
20992
|
textBaseline = (_b = text.getAlignMapBaseline()[t]) !== null && _b !== void 0 ? _b : 'top';
|
|
20980
20993
|
}
|
|
20981
|
-
const lineHeight = (_c = text.attribute.lineHeight) !== null && _c !== void 0 ? _c : fontSize;
|
|
20994
|
+
const lineHeight = (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) !== null && _c !== void 0 ? _c : fontSize;
|
|
20982
20995
|
const data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
20983
20996
|
if (!data) {
|
|
20984
20997
|
return;
|
|
@@ -27633,6 +27646,7 @@
|
|
|
27633
27646
|
exports.builtinSymbols = builtinSymbols;
|
|
27634
27647
|
exports.builtinSymbolsMap = builtinSymbolsMap;
|
|
27635
27648
|
exports.calcLineCache = calcLineCache$1;
|
|
27649
|
+
exports.calculateLineHeight = calculateLineHeight;
|
|
27636
27650
|
exports.centroidOfSubpath = centroidOfSubpath;
|
|
27637
27651
|
exports.circleBounds = circleBounds;
|
|
27638
27652
|
exports.clock = clock;
|