@visactor/vrender-core 0.16.14-alpha.3 → 0.16.14-alpha.5
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/core/graphic-utils.d.ts +1 -3
- package/cjs/core/graphic-utils.js +2 -4
- package/cjs/core/graphic-utils.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.js +12 -11
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/interface/core.d.ts +1 -3
- package/cjs/interface/core.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +1 -1
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/dist/index.js +245 -244
- package/dist/index.min.js +1 -1
- package/es/core/graphic-utils.d.ts +1 -3
- package/es/core/graphic-utils.js +1 -5
- package/es/core/graphic-utils.js.map +1 -1
- package/es/graphic/richtext/paragraph.js +5 -2
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/interface/core.d.ts +1 -3
- package/es/interface/core.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +1 -1
- package/es/interface/graphic/richText.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5425,247 +5425,6 @@
|
|
|
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
|
-
|
|
5669
5428
|
exports.DefaultGraphicUtil = class DefaultGraphicUtil {
|
|
5670
5429
|
constructor(contributions, global) {
|
|
5671
5430
|
this.contributions = contributions;
|
|
@@ -5716,7 +5475,7 @@
|
|
|
5716
5475
|
return new vutils.TextMeasure(Object.assign({ defaultFontParams: {
|
|
5717
5476
|
fontFamily: DefaultTextStyle.fontFamily,
|
|
5718
5477
|
fontSize: DefaultTextStyle.fontSize
|
|
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 : {})),
|
|
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);
|
|
5720
5479
|
}
|
|
5721
5480
|
};
|
|
5722
5481
|
exports.DefaultGraphicUtil = __decorate([
|
|
@@ -9024,6 +8783,247 @@
|
|
|
9024
8783
|
easing: 'quadInOut'
|
|
9025
8784
|
};
|
|
9026
8785
|
|
|
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
|
+
const calculateLineHeight = (lineHeight, fontSize) => {
|
|
9020
|
+
if (vutils.isString(lineHeight) && lineHeight[lineHeight.length - 1] === '%') {
|
|
9021
|
+
const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
|
|
9022
|
+
return fontSize * scale;
|
|
9023
|
+
}
|
|
9024
|
+
return lineHeight;
|
|
9025
|
+
};
|
|
9026
|
+
|
|
9027
9027
|
class IncreaseCount extends ACustomAnimate {
|
|
9028
9028
|
constructor(from, to, duration, easing, params) {
|
|
9029
9029
|
super(from, to, duration, easing, params);
|
|
@@ -16473,8 +16473,9 @@
|
|
|
16473
16473
|
constructor(text, newLine, character) {
|
|
16474
16474
|
this.fontSize = character.fontSize || 16;
|
|
16475
16475
|
this.textBaseline = character.textBaseline || 'alphabetic';
|
|
16476
|
-
|
|
16477
|
-
|
|
16476
|
+
const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
|
|
16477
|
+
if (typeof lineHeight === 'number') {
|
|
16478
|
+
this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;
|
|
16478
16479
|
}
|
|
16479
16480
|
else {
|
|
16480
16481
|
this.lineHeight = Math.floor(1.2 * this.fontSize);
|