@antv/g-lite 1.0.14 → 1.0.16
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/Canvas.d.ts +7 -0
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/css/parser/path.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyPath.d.ts +2 -3
- package/dist/css/properties/CSSPropertyPath.d.ts.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts.map +1 -1
- package/dist/display-objects/Path.d.ts +0 -2
- package/dist/display-objects/Path.d.ts.map +1 -1
- package/dist/dom/Element.d.ts +5 -1
- package/dist/dom/Element.d.ts.map +1 -1
- package/dist/index.esm.js +277 -110
- package/dist/index.js +277 -110
- package/dist/index.umd.js +284 -115
- package/dist/index.umd.min.js +2 -2
- package/dist/types.d.ts +0 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/path.d.ts +1 -1
- package/dist/utils/path.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -655,6 +655,7 @@ function getHeight($el) {
|
|
|
655
655
|
|
|
656
656
|
var ERROR_MSG_METHOD_NOT_IMPLEMENTED = 'Method not implemented.';
|
|
657
657
|
var ERROR_MSG_USE_DOCUMENT_ELEMENT = 'Use document.documentElement instead.';
|
|
658
|
+
var ERROR_MSG_APPEND_DESTROYED_ELEMENT = 'Cannot append a destroyed element.';
|
|
658
659
|
|
|
659
660
|
// borrow from hammer.js
|
|
660
661
|
var MOUSE_POINTER_ID = 1;
|
|
@@ -4291,9 +4292,8 @@ var internalParsePath = function internalParsePath(path) {
|
|
|
4291
4292
|
segments: [],
|
|
4292
4293
|
polygons: [],
|
|
4293
4294
|
polylines: [],
|
|
4294
|
-
curve:
|
|
4295
|
+
curve: null,
|
|
4295
4296
|
totalLength: 0,
|
|
4296
|
-
zCommandIndexes: [],
|
|
4297
4297
|
rect: {
|
|
4298
4298
|
x: 0,
|
|
4299
4299
|
y: 0,
|
|
@@ -4316,13 +4316,7 @@ var internalParsePath = function internalParsePath(path) {
|
|
|
4316
4316
|
|
|
4317
4317
|
var _extractPolygons = extractPolygons(absolutePath),
|
|
4318
4318
|
polygons = _extractPolygons.polygons,
|
|
4319
|
-
polylines = _extractPolygons.polylines; //
|
|
4320
|
-
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
var _path2Curve = path2Curve(absolutePath, true),
|
|
4324
|
-
curve = _path2Curve[0],
|
|
4325
|
-
zCommandIndexes = _path2Curve[1]; // for later use
|
|
4319
|
+
polylines = _extractPolygons.polylines; // for later use
|
|
4326
4320
|
|
|
4327
4321
|
|
|
4328
4322
|
var segments = path2Segments(absolutePath); // Only calculate bbox here since we don't need length now.
|
|
@@ -4339,10 +4333,9 @@ var internalParsePath = function internalParsePath(path) {
|
|
|
4339
4333
|
segments: segments,
|
|
4340
4334
|
polygons: polygons,
|
|
4341
4335
|
polylines: polylines,
|
|
4342
|
-
|
|
4336
|
+
// curve,
|
|
4343
4337
|
// Delay the calculation of length.
|
|
4344
4338
|
totalLength: 0,
|
|
4345
|
-
zCommandIndexes: zCommandIndexes,
|
|
4346
4339
|
rect: {
|
|
4347
4340
|
x: Number.isFinite(x) ? x : 0,
|
|
4348
4341
|
y: Number.isFinite(y) ? y : 0,
|
|
@@ -4366,6 +4359,19 @@ function parsePath(path, object) {
|
|
|
4366
4359
|
function mergePaths(left, right, object) {
|
|
4367
4360
|
var curve1 = left.curve;
|
|
4368
4361
|
var curve2 = right.curve;
|
|
4362
|
+
|
|
4363
|
+
if (!curve1 || curve1.length === 0) {
|
|
4364
|
+
// convert to curves to do morphing & picking later
|
|
4365
|
+
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
4366
|
+
curve1 = path2Curve(left.absolutePath, false);
|
|
4367
|
+
left.curve = curve1;
|
|
4368
|
+
}
|
|
4369
|
+
|
|
4370
|
+
if (!curve2 || curve2.length === 0) {
|
|
4371
|
+
curve2 = path2Curve(right.absolutePath, false);
|
|
4372
|
+
right.curve = curve2;
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4369
4375
|
var curves = [curve1, curve2];
|
|
4370
4376
|
|
|
4371
4377
|
if (curve1.length !== curve2.length) {
|
|
@@ -5485,9 +5491,8 @@ var CSSPropertyPath = /*#__PURE__*/function () {
|
|
|
5485
5491
|
segments: [],
|
|
5486
5492
|
polygons: [],
|
|
5487
5493
|
polylines: [],
|
|
5488
|
-
curve:
|
|
5494
|
+
curve: null,
|
|
5489
5495
|
totalLength: 0,
|
|
5490
|
-
zCommandIndexes: [],
|
|
5491
5496
|
rect: new Rectangle(0, 0, 0, 0)
|
|
5492
5497
|
};
|
|
5493
5498
|
}
|
|
@@ -6770,6 +6775,118 @@ function toSymmetry(point, center) {
|
|
|
6770
6775
|
return [center[0] + (center[0] - point[0]), center[1] + (center[1] - point[1])];
|
|
6771
6776
|
}
|
|
6772
6777
|
|
|
6778
|
+
var angleBetween = function angleBetween(v0, v1) {
|
|
6779
|
+
var p = v0.x * v1.x + v0.y * v1.y;
|
|
6780
|
+
var n = Math.sqrt((Math.pow(v0.x, 2) + Math.pow(v0.y, 2)) * (Math.pow(v1.x, 2) + Math.pow(v1.y, 2)));
|
|
6781
|
+
var sign = v0.x * v1.y - v0.y * v1.x < 0 ? -1 : 1;
|
|
6782
|
+
var angle = sign * Math.acos(p / n);
|
|
6783
|
+
return angle;
|
|
6784
|
+
};
|
|
6785
|
+
/**
|
|
6786
|
+
* @see https://github.com/rveciana/svg-path-properties/blob/b6bd9a322966f6ef7a311872d80c56e3718de861/src/arc.ts#L121
|
|
6787
|
+
*/
|
|
6788
|
+
|
|
6789
|
+
|
|
6790
|
+
var pointOnEllipticalArc = function pointOnEllipticalArc(p0, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, p1, t) {
|
|
6791
|
+
// In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
|
|
6792
|
+
rx = Math.abs(rx);
|
|
6793
|
+
ry = Math.abs(ry);
|
|
6794
|
+
xAxisRotation = mod(xAxisRotation, 360);
|
|
6795
|
+
var xAxisRotationRadians = deg2rad(xAxisRotation); // If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
|
|
6796
|
+
|
|
6797
|
+
if (p0.x === p1.x && p0.y === p1.y) {
|
|
6798
|
+
return {
|
|
6799
|
+
x: p0.x,
|
|
6800
|
+
y: p0.y,
|
|
6801
|
+
ellipticalArcAngle: 0
|
|
6802
|
+
}; // Check if angle is correct
|
|
6803
|
+
} // If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
|
|
6804
|
+
|
|
6805
|
+
|
|
6806
|
+
if (rx === 0 || ry === 0) {
|
|
6807
|
+
//return this.pointOnLine(p0, p1, t);
|
|
6808
|
+
return {
|
|
6809
|
+
x: 0,
|
|
6810
|
+
y: 0,
|
|
6811
|
+
ellipticalArcAngle: 0
|
|
6812
|
+
}; // Check if angle is correct
|
|
6813
|
+
} // Following "Conversion from endpoint to center parameterization"
|
|
6814
|
+
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
|
|
6815
|
+
// Step #1: Compute transformedPoint
|
|
6816
|
+
|
|
6817
|
+
|
|
6818
|
+
var dx = (p0.x - p1.x) / 2;
|
|
6819
|
+
var dy = (p0.y - p1.y) / 2;
|
|
6820
|
+
var transformedPoint = {
|
|
6821
|
+
x: Math.cos(xAxisRotationRadians) * dx + Math.sin(xAxisRotationRadians) * dy,
|
|
6822
|
+
y: -Math.sin(xAxisRotationRadians) * dx + Math.cos(xAxisRotationRadians) * dy
|
|
6823
|
+
}; // Ensure radii are large enough
|
|
6824
|
+
|
|
6825
|
+
var radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
|
|
6826
|
+
|
|
6827
|
+
if (radiiCheck > 1) {
|
|
6828
|
+
rx = Math.sqrt(radiiCheck) * rx;
|
|
6829
|
+
ry = Math.sqrt(radiiCheck) * ry;
|
|
6830
|
+
} // Step #2: Compute transformedCenter
|
|
6831
|
+
|
|
6832
|
+
|
|
6833
|
+
var cSquareNumerator = Math.pow(rx, 2) * Math.pow(ry, 2) - Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) - Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
|
|
6834
|
+
var cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
|
|
6835
|
+
var cRadicand = cSquareNumerator / cSquareRootDenom; // Make sure this never drops below zero because of precision
|
|
6836
|
+
|
|
6837
|
+
cRadicand = cRadicand < 0 ? 0 : cRadicand;
|
|
6838
|
+
var cCoef = (largeArcFlag !== sweepFlag ? 1 : -1) * Math.sqrt(cRadicand);
|
|
6839
|
+
var transformedCenter = {
|
|
6840
|
+
x: cCoef * (rx * transformedPoint.y / ry),
|
|
6841
|
+
y: cCoef * (-(ry * transformedPoint.x) / rx)
|
|
6842
|
+
}; // Step #3: Compute center
|
|
6843
|
+
|
|
6844
|
+
var center = {
|
|
6845
|
+
x: Math.cos(xAxisRotationRadians) * transformedCenter.x - Math.sin(xAxisRotationRadians) * transformedCenter.y + (p0.x + p1.x) / 2,
|
|
6846
|
+
y: Math.sin(xAxisRotationRadians) * transformedCenter.x + Math.cos(xAxisRotationRadians) * transformedCenter.y + (p0.y + p1.y) / 2
|
|
6847
|
+
}; // Step #4: Compute start/sweep angles
|
|
6848
|
+
// Start angle of the elliptical arc prior to the stretch and rotate operations.
|
|
6849
|
+
// Difference between the start and end angles
|
|
6850
|
+
|
|
6851
|
+
var startVector = {
|
|
6852
|
+
x: (transformedPoint.x - transformedCenter.x) / rx,
|
|
6853
|
+
y: (transformedPoint.y - transformedCenter.y) / ry
|
|
6854
|
+
};
|
|
6855
|
+
var startAngle = angleBetween({
|
|
6856
|
+
x: 1,
|
|
6857
|
+
y: 0
|
|
6858
|
+
}, startVector);
|
|
6859
|
+
var endVector = {
|
|
6860
|
+
x: (-transformedPoint.x - transformedCenter.x) / rx,
|
|
6861
|
+
y: (-transformedPoint.y - transformedCenter.y) / ry
|
|
6862
|
+
};
|
|
6863
|
+
var sweepAngle = angleBetween(startVector, endVector);
|
|
6864
|
+
|
|
6865
|
+
if (!sweepFlag && sweepAngle > 0) {
|
|
6866
|
+
sweepAngle -= 2 * Math.PI;
|
|
6867
|
+
} else if (sweepFlag && sweepAngle < 0) {
|
|
6868
|
+
sweepAngle += 2 * Math.PI;
|
|
6869
|
+
} // We use % instead of `mod(..)` because we want it to be -360deg to 360deg(but actually in radians)
|
|
6870
|
+
|
|
6871
|
+
|
|
6872
|
+
sweepAngle %= 2 * Math.PI; // From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
|
|
6873
|
+
|
|
6874
|
+
var angle = startAngle + sweepAngle * t;
|
|
6875
|
+
var ellipseComponentX = rx * Math.cos(angle);
|
|
6876
|
+
var ellipseComponentY = ry * Math.sin(angle);
|
|
6877
|
+
var point = {
|
|
6878
|
+
x: Math.cos(xAxisRotationRadians) * ellipseComponentX - Math.sin(xAxisRotationRadians) * ellipseComponentY + center.x,
|
|
6879
|
+
y: Math.sin(xAxisRotationRadians) * ellipseComponentX + Math.cos(xAxisRotationRadians) * ellipseComponentY + center.y,
|
|
6880
|
+
ellipticalArcStartAngle: startAngle,
|
|
6881
|
+
ellipticalArcEndAngle: startAngle + sweepAngle,
|
|
6882
|
+
ellipticalArcAngle: angle,
|
|
6883
|
+
ellipticalArcCenter: center,
|
|
6884
|
+
resultantRx: rx,
|
|
6885
|
+
resultantRy: ry
|
|
6886
|
+
};
|
|
6887
|
+
return point;
|
|
6888
|
+
};
|
|
6889
|
+
|
|
6773
6890
|
function path2Segments(path) {
|
|
6774
6891
|
var segments = [];
|
|
6775
6892
|
var currentPoint = null; // 当前图形
|
|
@@ -6795,7 +6912,8 @@ function path2Segments(path) {
|
|
|
6795
6912
|
endTangent: null,
|
|
6796
6913
|
currentPoint: null,
|
|
6797
6914
|
nextPoint: null,
|
|
6798
|
-
arcParams: null
|
|
6915
|
+
arcParams: null,
|
|
6916
|
+
box: null
|
|
6799
6917
|
};
|
|
6800
6918
|
|
|
6801
6919
|
switch (command) {
|
|
@@ -6899,42 +7017,64 @@ function path2Segments(path) {
|
|
|
6899
7017
|
segment.endTangent = [currentPoint[0] - _cp3[0], currentPoint[1] - _cp3[1]];
|
|
6900
7018
|
}
|
|
6901
7019
|
} else if (command === 'A') {
|
|
6902
|
-
var
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
_ref$cx = _ref.cx,
|
|
6906
|
-
cx = _ref$cx === void 0 ? 0 : _ref$cx,
|
|
6907
|
-
_ref$cy = _ref.cy,
|
|
6908
|
-
cy = _ref$cy === void 0 ? 0 : _ref$cy,
|
|
6909
|
-
_ref$rx = _ref.rx,
|
|
6910
|
-
rx = _ref$rx === void 0 ? 0 : _ref$rx,
|
|
6911
|
-
_ref$ry = _ref.ry,
|
|
6912
|
-
ry = _ref$ry === void 0 ? 0 : _ref$ry,
|
|
6913
|
-
_ref$sweepFlag = _ref.sweepFlag,
|
|
6914
|
-
sweepFlag = _ref$sweepFlag === void 0 ? 0 : _ref$sweepFlag,
|
|
6915
|
-
_ref$startAngle = _ref.startAngle,
|
|
6916
|
-
startAngle = _ref$startAngle === void 0 ? 0 : _ref$startAngle,
|
|
6917
|
-
_ref$endAngle = _ref.endAngle,
|
|
6918
|
-
endAngle = _ref$endAngle === void 0 ? 0 : _ref$endAngle;
|
|
6919
|
-
|
|
6920
|
-
if (sweepFlag === 0) {
|
|
6921
|
-
d *= -1;
|
|
6922
|
-
}
|
|
7020
|
+
var _getTangentAtRatio = getTangentAtRatio(segment, 0),
|
|
7021
|
+
dx1 = _getTangentAtRatio.x,
|
|
7022
|
+
dy1 = _getTangentAtRatio.y;
|
|
6923
7023
|
|
|
6924
|
-
var
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
segment.endTangent = [
|
|
7024
|
+
var _getTangentAtRatio2 = getTangentAtRatio(segment, 1, false),
|
|
7025
|
+
dx2 = _getTangentAtRatio2.x,
|
|
7026
|
+
dy2 = _getTangentAtRatio2.y;
|
|
7027
|
+
|
|
7028
|
+
segment.startTangent = [dx1, dy1];
|
|
7029
|
+
segment.endTangent = [dx2, dy2];
|
|
6930
7030
|
}
|
|
6931
7031
|
|
|
6932
7032
|
segments.push(segment);
|
|
6933
7033
|
}
|
|
6934
7034
|
|
|
6935
7035
|
return segments;
|
|
7036
|
+
}
|
|
7037
|
+
/**
|
|
7038
|
+
* Use length instead of ratio
|
|
7039
|
+
*/
|
|
7040
|
+
|
|
7041
|
+
function getTangentAtRatio(segment, ratio, sign) {
|
|
7042
|
+
if (sign === void 0) {
|
|
7043
|
+
sign = true;
|
|
7044
|
+
}
|
|
7045
|
+
|
|
7046
|
+
var _segment$arcParams = segment.arcParams,
|
|
7047
|
+
_segment$arcParams$rx = _segment$arcParams.rx,
|
|
7048
|
+
rx = _segment$arcParams$rx === void 0 ? 0 : _segment$arcParams$rx,
|
|
7049
|
+
_segment$arcParams$ry = _segment$arcParams.ry,
|
|
7050
|
+
ry = _segment$arcParams$ry === void 0 ? 0 : _segment$arcParams$ry,
|
|
7051
|
+
xRotation = _segment$arcParams.xRotation,
|
|
7052
|
+
arcFlag = _segment$arcParams.arcFlag,
|
|
7053
|
+
sweepFlag = _segment$arcParams.sweepFlag;
|
|
7054
|
+
var p1 = pointOnEllipticalArc({
|
|
7055
|
+
x: segment.prePoint[0],
|
|
7056
|
+
y: segment.prePoint[1]
|
|
7057
|
+
}, rx, ry, xRotation, !!arcFlag, !!sweepFlag, {
|
|
7058
|
+
x: segment.currentPoint[0],
|
|
7059
|
+
y: segment.currentPoint[1]
|
|
7060
|
+
}, ratio);
|
|
7061
|
+
var p2 = pointOnEllipticalArc({
|
|
7062
|
+
x: segment.prePoint[0],
|
|
7063
|
+
y: segment.prePoint[1]
|
|
7064
|
+
}, rx, ry, xRotation, !!arcFlag, !!sweepFlag, {
|
|
7065
|
+
x: segment.currentPoint[0],
|
|
7066
|
+
y: segment.currentPoint[1]
|
|
7067
|
+
}, sign ? ratio + 0.005 : ratio - 0.005);
|
|
7068
|
+
var xDist = p2.x - p1.x;
|
|
7069
|
+
var yDist = p2.y - p1.y;
|
|
7070
|
+
var dist = Math.sqrt(xDist * xDist + yDist * yDist);
|
|
7071
|
+
return {
|
|
7072
|
+
x: -xDist / dist,
|
|
7073
|
+
y: -yDist / dist
|
|
7074
|
+
};
|
|
6936
7075
|
} // 向量长度
|
|
6937
7076
|
|
|
7077
|
+
|
|
6938
7078
|
function vMag(v) {
|
|
6939
7079
|
return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
|
|
6940
7080
|
} // u.v/|u||v|,计算夹角的余弦值
|
|
@@ -7066,6 +7206,17 @@ function commandsToPathString(commands, object, transform) {
|
|
|
7066
7206
|
}
|
|
7067
7207
|
|
|
7068
7208
|
path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "," + cur[5] + "," + c[0] + "," + c[1];
|
|
7209
|
+
} else if (cur[0] === 'Q') {
|
|
7210
|
+
var _p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
|
|
7211
|
+
|
|
7212
|
+
var _p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
|
|
7213
|
+
|
|
7214
|
+
if (transform) {
|
|
7215
|
+
vec3.transformMat4(_p, _p, transform);
|
|
7216
|
+
vec3.transformMat4(_p2, _p2, transform);
|
|
7217
|
+
}
|
|
7218
|
+
|
|
7219
|
+
path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "}";
|
|
7069
7220
|
}
|
|
7070
7221
|
|
|
7071
7222
|
return prev += path;
|
|
@@ -7185,13 +7336,8 @@ function convertToPath(object, transform) {
|
|
|
7185
7336
|
break;
|
|
7186
7337
|
|
|
7187
7338
|
case Shape.PATH:
|
|
7188
|
-
var
|
|
7189
|
-
|
|
7190
|
-
zCommandIndexes = _object$parsedStyle$p.zCommandIndexes;
|
|
7191
|
-
commands = [].concat(curve);
|
|
7192
|
-
zCommandIndexes.forEach(function (zIndex, index) {
|
|
7193
|
-
commands.splice(zIndex + index + 1, 0, ['Z']);
|
|
7194
|
-
});
|
|
7339
|
+
var absolutePath = object.parsedStyle.path.absolutePath;
|
|
7340
|
+
commands = [].concat(absolutePath);
|
|
7195
7341
|
break;
|
|
7196
7342
|
}
|
|
7197
7343
|
|
|
@@ -7199,7 +7345,7 @@ function convertToPath(object, transform) {
|
|
|
7199
7345
|
return commandsToPathString(commands, object, transform);
|
|
7200
7346
|
}
|
|
7201
7347
|
}
|
|
7202
|
-
function translatePathToString(
|
|
7348
|
+
function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
|
|
7203
7349
|
if (startOffsetX === void 0) {
|
|
7204
7350
|
startOffsetX = 0;
|
|
7205
7351
|
}
|
|
@@ -7216,27 +7362,32 @@ function translatePathToString(pathArray, x, y, startOffsetX, startOffsetY, endO
|
|
|
7216
7362
|
endOffsetY = 0;
|
|
7217
7363
|
}
|
|
7218
7364
|
|
|
7219
|
-
var newValue =
|
|
7365
|
+
var newValue = absolutePath.map(function (params, i) {
|
|
7220
7366
|
var command = params[0];
|
|
7221
|
-
var
|
|
7222
|
-
var
|
|
7223
|
-
var
|
|
7367
|
+
var nextSegment = absolutePath[i + 1];
|
|
7368
|
+
var useStartOffset = i === 0 && startOffsetX !== 0 && startOffsetY !== 0;
|
|
7369
|
+
var useEndOffset = (i === absolutePath.length - 1 || nextSegment && (nextSegment[0] === 'M' || nextSegment[0] === 'Z')) && endOffsetX !== 0 && endOffsetY !== 0;
|
|
7224
7370
|
|
|
7225
7371
|
switch (command) {
|
|
7226
7372
|
case 'M':
|
|
7227
|
-
|
|
7373
|
+
// Use start marker offset
|
|
7374
|
+
if (useStartOffset) {
|
|
7375
|
+
return "M " + (params[1] - defX + startOffsetX) + "," + (params[2] - defY + startOffsetY) + " L " + (params[1] - defX) + "," + (params[2] - defY);
|
|
7376
|
+
} else {
|
|
7377
|
+
return "M " + (params[1] - defX) + "," + (params[2] - defY);
|
|
7378
|
+
}
|
|
7228
7379
|
|
|
7229
7380
|
case 'L':
|
|
7230
|
-
return "L " + (params[1] -
|
|
7381
|
+
return "L " + (params[1] - defX + (useEndOffset ? endOffsetX : 0)) + "," + (params[2] - defY + (useEndOffset ? endOffsetY : 0));
|
|
7231
7382
|
|
|
7232
7383
|
case 'Q':
|
|
7233
|
-
return "Q " + (params[1] -
|
|
7384
|
+
return "Q " + (params[1] - defX) + " " + (params[2] - defY) + "," + (params[3] - defX) + " " + (params[4] - defY) + (useEndOffset ? " L " + (params[3] - defX + endOffsetX) + "," + (params[4] - defY + endOffsetY) : '');
|
|
7234
7385
|
|
|
7235
7386
|
case 'C':
|
|
7236
|
-
return "C " + (params[1] -
|
|
7387
|
+
return "C " + (params[1] - defX) + " " + (params[2] - defY) + "," + (params[3] - defX) + " " + (params[4] - defY) + "," + (params[5] - defX) + " " + (params[6] - defY) + (useEndOffset ? " L " + (params[5] - defX + endOffsetX) + "," + (params[6] - defY + endOffsetY) : '');
|
|
7237
7388
|
|
|
7238
7389
|
case 'A':
|
|
7239
|
-
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] -
|
|
7390
|
+
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - defX) + " " + (params[7] - defY) + (useEndOffset ? " L " + (params[6] - defX + endOffsetX) + "," + (params[7] - defY + endOffsetY) : '');
|
|
7240
7391
|
|
|
7241
7392
|
case 'Z':
|
|
7242
7393
|
return 'Z';
|
|
@@ -10783,6 +10934,10 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10783
10934
|
_proto.appendChild = function appendChild(child, index) {
|
|
10784
10935
|
var _this$ownerDocument;
|
|
10785
10936
|
|
|
10937
|
+
if (child.destroyed) {
|
|
10938
|
+
throw new Error(ERROR_MSG_APPEND_DESTROYED_ELEMENT);
|
|
10939
|
+
}
|
|
10940
|
+
|
|
10786
10941
|
runtime.sceneGraphService.attach(child, this, index);
|
|
10787
10942
|
|
|
10788
10943
|
if ((_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.defaultView) {
|
|
@@ -10828,7 +10983,7 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10828
10983
|
return child;
|
|
10829
10984
|
}
|
|
10830
10985
|
/**
|
|
10831
|
-
* Remove all children
|
|
10986
|
+
* Remove all children which can be appended to its original parent later again.
|
|
10832
10987
|
*/
|
|
10833
10988
|
;
|
|
10834
10989
|
|
|
@@ -10837,7 +10992,16 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
10837
10992
|
|
|
10838
10993
|
this.childNodes.slice().forEach(function (child) {
|
|
10839
10994
|
_this2.removeChild(child);
|
|
10995
|
+
});
|
|
10996
|
+
}
|
|
10997
|
+
/**
|
|
10998
|
+
* Recursively destroy all children which can not be appended to its original parent later again.
|
|
10999
|
+
*/
|
|
11000
|
+
;
|
|
10840
11001
|
|
|
11002
|
+
_proto.destroyChildren = function destroyChildren() {
|
|
11003
|
+
this.childNodes.slice().forEach(function (child) {
|
|
11004
|
+
child.destroyChildren();
|
|
10841
11005
|
child.destroy();
|
|
10842
11006
|
});
|
|
10843
11007
|
}
|
|
@@ -12059,11 +12223,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
12059
12223
|
_proto.animate = function animate(keyframes, options) {
|
|
12060
12224
|
var _this$ownerDocument;
|
|
12061
12225
|
|
|
12062
|
-
var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline;
|
|
12063
|
-
// if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
|
|
12064
|
-
// const target = this.parsedStyle.clipPathTargets[0];
|
|
12065
|
-
// timeline = target.ownerDocument?.timeline;
|
|
12066
|
-
// }
|
|
12226
|
+
var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline;
|
|
12067
12227
|
|
|
12068
12228
|
if (timeline) {
|
|
12069
12229
|
return timeline.play(this, keyframes, options);
|
|
@@ -13012,7 +13172,6 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
13012
13172
|
});
|
|
13013
13173
|
|
|
13014
13174
|
if (marker && marker instanceof DisplayObject) {
|
|
13015
|
-
// FIXME: should use original path instead of parsed curve
|
|
13016
13175
|
for (var i = 1; i < segments.length - 1; i++) {
|
|
13017
13176
|
var _segments$i$currentPo = segments[i].currentPoint,
|
|
13018
13177
|
ox = _segments$i$currentPo[0],
|
|
@@ -18785,10 +18944,22 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18785
18944
|
|
|
18786
18945
|
_proto.removeChild = function removeChild(child) {
|
|
18787
18946
|
return this.document.documentElement.removeChild(child);
|
|
18788
|
-
}
|
|
18947
|
+
}
|
|
18948
|
+
/**
|
|
18949
|
+
* Remove all children which can be appended to its original parent later again.
|
|
18950
|
+
*/
|
|
18951
|
+
;
|
|
18789
18952
|
|
|
18790
18953
|
_proto.removeChildren = function removeChildren() {
|
|
18791
18954
|
this.document.documentElement.removeChildren();
|
|
18955
|
+
}
|
|
18956
|
+
/**
|
|
18957
|
+
* Recursively destroy all children which can not be appended to its original parent later again.
|
|
18958
|
+
*/
|
|
18959
|
+
;
|
|
18960
|
+
|
|
18961
|
+
_proto.destroyChildren = function destroyChildren() {
|
|
18962
|
+
this.document.documentElement.destroyChildren();
|
|
18792
18963
|
};
|
|
18793
18964
|
|
|
18794
18965
|
_proto.render = function render() {
|
|
@@ -18945,37 +19116,32 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18945
19116
|
_proto.unmountChildren = function unmountChildren(parent) {
|
|
18946
19117
|
var _this5 = this;
|
|
18947
19118
|
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
path.push(child);
|
|
18953
|
-
}
|
|
18954
|
-
}); // unmount from leaf to root
|
|
19119
|
+
// unmountChildren recursively
|
|
19120
|
+
parent.childNodes.forEach(function (child) {
|
|
19121
|
+
_this5.unmountChildren(child);
|
|
19122
|
+
});
|
|
18955
19123
|
|
|
18956
|
-
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
|
|
18960
|
-
|
|
18961
|
-
|
|
18962
|
-
|
|
19124
|
+
if (this.inited) {
|
|
19125
|
+
if (parent.isMutationObserved) {
|
|
19126
|
+
parent.dispatchEvent(unmountedEvent);
|
|
19127
|
+
} else {
|
|
19128
|
+
unmountedEvent.target = parent;
|
|
19129
|
+
this.dispatchEvent(unmountedEvent, true);
|
|
19130
|
+
} // skip document.documentElement
|
|
18963
19131
|
|
|
18964
|
-
if (child.isMutationObserved) {
|
|
18965
|
-
child.dispatchEvent(unmountedEvent);
|
|
18966
|
-
} else {
|
|
18967
|
-
unmountedEvent.target = child;
|
|
18968
19132
|
|
|
18969
|
-
|
|
18970
|
-
|
|
19133
|
+
if (parent !== this.document.documentElement) {
|
|
19134
|
+
parent.ownerDocument = null;
|
|
19135
|
+
}
|
|
18971
19136
|
|
|
19137
|
+
parent.isConnected = false;
|
|
19138
|
+
} // trigger after unmounted
|
|
18972
19139
|
|
|
18973
|
-
if (child !== _this5.document.documentElement) {
|
|
18974
|
-
child.ownerDocument = null;
|
|
18975
|
-
}
|
|
18976
19140
|
|
|
18977
|
-
|
|
18978
|
-
|
|
19141
|
+
if (parent.isCustomElement) {
|
|
19142
|
+
if (parent.disconnectedCallback) {
|
|
19143
|
+
parent.disconnectedCallback();
|
|
19144
|
+
}
|
|
18979
19145
|
}
|
|
18980
19146
|
};
|
|
18981
19147
|
|
|
@@ -18983,29 +19149,30 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
18983
19149
|
var _this6 = this;
|
|
18984
19150
|
|
|
18985
19151
|
if (this.inited) {
|
|
18986
|
-
parent.
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
child.isConnected = true;
|
|
18990
|
-
|
|
18991
|
-
if (child.isMutationObserved) {
|
|
18992
|
-
child.dispatchEvent(mountedEvent);
|
|
18993
|
-
} else {
|
|
18994
|
-
mountedEvent.target = child;
|
|
18995
|
-
|
|
18996
|
-
_this6.dispatchEvent(mountedEvent, true);
|
|
18997
|
-
} // trigger after mounted
|
|
19152
|
+
if (!parent.isConnected) {
|
|
19153
|
+
parent.ownerDocument = this.document;
|
|
19154
|
+
parent.isConnected = true;
|
|
18998
19155
|
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
}
|
|
19156
|
+
if (parent.isMutationObserved) {
|
|
19157
|
+
parent.dispatchEvent(mountedEvent);
|
|
19158
|
+
} else {
|
|
19159
|
+
mountedEvent.target = parent;
|
|
19160
|
+
this.dispatchEvent(mountedEvent, true);
|
|
19005
19161
|
}
|
|
19006
|
-
}
|
|
19162
|
+
}
|
|
19007
19163
|
} else {
|
|
19008
19164
|
console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', parent.nodeName);
|
|
19165
|
+
} // recursively mount children
|
|
19166
|
+
|
|
19167
|
+
|
|
19168
|
+
parent.childNodes.forEach(function (child) {
|
|
19169
|
+
_this6.mountChildren(child);
|
|
19170
|
+
}); // trigger after mounted
|
|
19171
|
+
|
|
19172
|
+
if (parent.isCustomElement) {
|
|
19173
|
+
if (parent.connectedCallback) {
|
|
19174
|
+
parent.connectedCallback();
|
|
19175
|
+
}
|
|
19009
19176
|
}
|
|
19010
19177
|
};
|
|
19011
19178
|
|