@antv/g 5.1.8 → 5.2.2
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/css/StyleValueRegistry.d.ts.map +1 -1
- package/dist/css/cssom/CSSGradientValue.d.ts +10 -23
- package/dist/css/cssom/CSSGradientValue.d.ts.map +1 -1
- package/dist/css/cssom/CSSNumericValue.d.ts +1 -1
- package/dist/css/parser/color.d.ts +12 -3
- package/dist/css/parser/color.d.ts.map +1 -1
- package/dist/css/parser/dimension.d.ts.map +1 -1
- package/dist/css/parser/gradient.d.ts +4 -0
- package/dist/css/parser/gradient.d.ts.map +1 -0
- package/dist/css/parser/path.d.ts +2 -2
- package/dist/css/parser/path.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyColor.d.ts +5 -4
- package/dist/css/properties/CSSPropertyColor.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyPath.d.ts +3 -3
- package/dist/css/properties/CSSPropertyPath.d.ts.map +1 -1
- package/dist/display-objects/Path.d.ts +8 -8
- package/dist/display-objects/Path.d.ts.map +1 -1
- package/dist/dom/KeyframeList.d.ts.map +1 -1
- package/dist/index.esm.js +841 -756
- package/dist/index.js +849 -762
- package/dist/index.umd.js +5782 -4335
- package/dist/index.umd.min.js +2 -2
- package/dist/services/aabb/PathUpdater.d.ts +1 -1
- package/dist/services/aabb/PathUpdater.d.ts.map +1 -1
- package/dist/services/aabb/RectUpdater.d.ts +1 -1
- package/dist/services/aabb/RectUpdater.d.ts.map +1 -1
- package/dist/types.d.ts +5 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/gradient.d.ts +106 -0
- package/dist/utils/gradient.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/path.d.ts +11 -7
- package/dist/utils/path.d.ts.map +1 -1
- package/package.json +9 -6
package/dist/index.js
CHANGED
|
@@ -7,10 +7,11 @@ var RBush = require('rbush');
|
|
|
7
7
|
require('reflect-metadata');
|
|
8
8
|
var tslib = require('tslib');
|
|
9
9
|
var glMatrix = require('gl-matrix');
|
|
10
|
-
var gMath = require('@antv/g-math');
|
|
11
10
|
var eventemitter3 = require('eventemitter3');
|
|
12
11
|
var d3 = require('d3-color');
|
|
12
|
+
var lodashEs = require('lodash-es');
|
|
13
13
|
var util = require('@antv/util');
|
|
14
|
+
var gMath = require('@antv/g-math');
|
|
14
15
|
var requestAnimationFramePolyfill = require('request-animation-frame-polyfill');
|
|
15
16
|
|
|
16
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -418,7 +419,7 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
418
419
|
}
|
|
419
420
|
|
|
420
421
|
function _extends() {
|
|
421
|
-
_extends = Object.assign
|
|
422
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
422
423
|
for (var i = 1; i < arguments.length; i++) {
|
|
423
424
|
var source = arguments[i];
|
|
424
425
|
|
|
@@ -431,7 +432,6 @@ function _extends() {
|
|
|
431
432
|
|
|
432
433
|
return target;
|
|
433
434
|
};
|
|
434
|
-
|
|
435
435
|
return _extends.apply(this, arguments);
|
|
436
436
|
}
|
|
437
437
|
|
|
@@ -443,11 +443,10 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
function _setPrototypeOf(o, p) {
|
|
446
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
446
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
447
447
|
o.__proto__ = p;
|
|
448
448
|
return o;
|
|
449
449
|
};
|
|
450
|
-
|
|
451
450
|
return _setPrototypeOf(o, p);
|
|
452
451
|
}
|
|
453
452
|
|
|
@@ -466,7 +465,7 @@ function _isNativeReflectConstruct() {
|
|
|
466
465
|
|
|
467
466
|
function _construct(Parent, args, Class) {
|
|
468
467
|
if (_isNativeReflectConstruct()) {
|
|
469
|
-
_construct = Reflect.construct;
|
|
468
|
+
_construct = Reflect.construct.bind();
|
|
470
469
|
} else {
|
|
471
470
|
_construct = function _construct(Parent, args, Class) {
|
|
472
471
|
var a = [null];
|
|
@@ -1688,6 +1687,379 @@ var TOUCH_TO_POINTER = {
|
|
|
1688
1687
|
touchcancel: 'pointercancel'
|
|
1689
1688
|
};
|
|
1690
1689
|
|
|
1690
|
+
/**
|
|
1691
|
+
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
1692
|
+
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
1693
|
+
*/
|
|
1694
|
+
function colorStopToString(colorStop) {
|
|
1695
|
+
var type = colorStop.type,
|
|
1696
|
+
value = colorStop.value;
|
|
1697
|
+
|
|
1698
|
+
if (type === 'hex') {
|
|
1699
|
+
return "#" + value;
|
|
1700
|
+
} else if (type === 'literal') {
|
|
1701
|
+
return value;
|
|
1702
|
+
} else if (type === 'rgb') {
|
|
1703
|
+
return "rgb(" + value.join(',') + ")";
|
|
1704
|
+
} else {
|
|
1705
|
+
return "rgba(" + value.join(',') + ")";
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
var parseGradient = function () {
|
|
1709
|
+
var tokens = {
|
|
1710
|
+
linearGradient: /^(linear\-gradient)/i,
|
|
1711
|
+
repeatingLinearGradient: /^(repeating\-linear\-gradient)/i,
|
|
1712
|
+
radialGradient: /^(radial\-gradient)/i,
|
|
1713
|
+
repeatingRadialGradient: /^(repeating\-radial\-gradient)/i,
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* @see https://projects.verou.me/conic-gradient/
|
|
1717
|
+
*/
|
|
1718
|
+
conicGradient: /^(conic\-gradient)/i,
|
|
1719
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
1720
|
+
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
1721
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
1722
|
+
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
1723
|
+
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
1724
|
+
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
1725
|
+
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
1726
|
+
startCall: /^\(/,
|
|
1727
|
+
endCall: /^\)/,
|
|
1728
|
+
comma: /^,/,
|
|
1729
|
+
hexColor: /^\#([0-9a-fA-F]+)/,
|
|
1730
|
+
literalColor: /^([a-zA-Z]+)/,
|
|
1731
|
+
rgbColor: /^rgb/i,
|
|
1732
|
+
rgbaColor: /^rgba/i,
|
|
1733
|
+
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
1734
|
+
};
|
|
1735
|
+
var input = '';
|
|
1736
|
+
|
|
1737
|
+
function error(msg) {
|
|
1738
|
+
throw new Error(input + ': ' + msg);
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
function getAST() {
|
|
1742
|
+
var ast = matchListDefinitions();
|
|
1743
|
+
|
|
1744
|
+
if (input.length > 0) {
|
|
1745
|
+
error('Invalid input not EOF');
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
return ast;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
function matchListDefinitions() {
|
|
1752
|
+
return matchListing(matchDefinition);
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
function matchDefinition() {
|
|
1756
|
+
return matchGradient('linear-gradient', tokens.linearGradient, matchLinearOrientation) || matchGradient('repeating-linear-gradient', tokens.repeatingLinearGradient, matchLinearOrientation) || matchGradient('radial-gradient', tokens.radialGradient, matchListRadialOrientations) || matchGradient('repeating-radial-gradient', tokens.repeatingRadialGradient, matchListRadialOrientations) || matchGradient('conic-gradient', tokens.conicGradient, matchListRadialOrientations);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
1760
|
+
return matchCall(pattern, function (captures) {
|
|
1761
|
+
var orientation = orientationMatcher();
|
|
1762
|
+
|
|
1763
|
+
if (orientation) {
|
|
1764
|
+
if (!scan(tokens.comma)) {
|
|
1765
|
+
error('Missing comma before color stops');
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
return {
|
|
1770
|
+
type: gradientType,
|
|
1771
|
+
orientation: orientation,
|
|
1772
|
+
colorStops: matchListing(matchColorStop)
|
|
1773
|
+
};
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
function matchCall(pattern, callback) {
|
|
1778
|
+
var captures = scan(pattern);
|
|
1779
|
+
|
|
1780
|
+
if (captures) {
|
|
1781
|
+
if (!scan(tokens.startCall)) {
|
|
1782
|
+
error('Missing (');
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
var result = callback(captures);
|
|
1786
|
+
|
|
1787
|
+
if (!scan(tokens.endCall)) {
|
|
1788
|
+
error('Missing )');
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
return result;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
function matchLinearOrientation() {
|
|
1796
|
+
return matchSideOrCorner() || matchAngle();
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
function matchSideOrCorner() {
|
|
1800
|
+
return match('directional', tokens.sideOrCorner, 1);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
function matchAngle() {
|
|
1804
|
+
return match('angular', tokens.angleValue, 1);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
function matchListRadialOrientations() {
|
|
1808
|
+
var radialOrientations,
|
|
1809
|
+
radialOrientation = matchRadialOrientation(),
|
|
1810
|
+
lookaheadCache;
|
|
1811
|
+
|
|
1812
|
+
if (radialOrientation) {
|
|
1813
|
+
radialOrientations = [];
|
|
1814
|
+
radialOrientations.push(radialOrientation);
|
|
1815
|
+
lookaheadCache = input;
|
|
1816
|
+
|
|
1817
|
+
if (scan(tokens.comma)) {
|
|
1818
|
+
radialOrientation = matchRadialOrientation();
|
|
1819
|
+
|
|
1820
|
+
if (radialOrientation) {
|
|
1821
|
+
radialOrientations.push(radialOrientation);
|
|
1822
|
+
} else {
|
|
1823
|
+
input = lookaheadCache;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
return radialOrientations;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
function matchRadialOrientation() {
|
|
1832
|
+
var radialType = matchCircle() || matchEllipse();
|
|
1833
|
+
|
|
1834
|
+
if (radialType) {
|
|
1835
|
+
// @ts-ignore
|
|
1836
|
+
radialType.at = matchAtPosition();
|
|
1837
|
+
} else {
|
|
1838
|
+
var extent = matchExtentKeyword();
|
|
1839
|
+
|
|
1840
|
+
if (extent) {
|
|
1841
|
+
radialType = extent;
|
|
1842
|
+
var positionAt = matchAtPosition();
|
|
1843
|
+
|
|
1844
|
+
if (positionAt) {
|
|
1845
|
+
// @ts-ignore
|
|
1846
|
+
radialType.at = positionAt;
|
|
1847
|
+
}
|
|
1848
|
+
} else {
|
|
1849
|
+
var defaultPosition = matchPositioning();
|
|
1850
|
+
|
|
1851
|
+
if (defaultPosition) {
|
|
1852
|
+
radialType = {
|
|
1853
|
+
type: 'default-radial',
|
|
1854
|
+
// @ts-ignore
|
|
1855
|
+
at: defaultPosition
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
return radialType;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
function matchCircle() {
|
|
1865
|
+
var circle = match('shape', /^(circle)/i, 0);
|
|
1866
|
+
|
|
1867
|
+
if (circle) {
|
|
1868
|
+
// @ts-ignore
|
|
1869
|
+
circle.style = matchLength() || matchExtentKeyword();
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
return circle;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
function matchEllipse() {
|
|
1876
|
+
var ellipse = match('shape', /^(ellipse)/i, 0);
|
|
1877
|
+
|
|
1878
|
+
if (ellipse) {
|
|
1879
|
+
// @ts-ignore
|
|
1880
|
+
ellipse.style = matchDistance() || matchExtentKeyword();
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
return ellipse;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
function matchExtentKeyword() {
|
|
1887
|
+
return match('extent-keyword', tokens.extentKeywords, 1);
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
function matchAtPosition() {
|
|
1891
|
+
if (match('position', /^at/, 0)) {
|
|
1892
|
+
var positioning = matchPositioning();
|
|
1893
|
+
|
|
1894
|
+
if (!positioning) {
|
|
1895
|
+
error('Missing positioning value');
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
return positioning;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
function matchPositioning() {
|
|
1903
|
+
var location = matchCoordinates();
|
|
1904
|
+
|
|
1905
|
+
if (location.x || location.y) {
|
|
1906
|
+
return {
|
|
1907
|
+
type: 'position',
|
|
1908
|
+
value: location
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
function matchCoordinates() {
|
|
1914
|
+
return {
|
|
1915
|
+
x: matchDistance(),
|
|
1916
|
+
y: matchDistance()
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
function matchListing(matcher) {
|
|
1921
|
+
var captures = matcher();
|
|
1922
|
+
var result = [];
|
|
1923
|
+
|
|
1924
|
+
if (captures) {
|
|
1925
|
+
result.push(captures);
|
|
1926
|
+
|
|
1927
|
+
while (scan(tokens.comma)) {
|
|
1928
|
+
captures = matcher();
|
|
1929
|
+
|
|
1930
|
+
if (captures) {
|
|
1931
|
+
result.push(captures);
|
|
1932
|
+
} else {
|
|
1933
|
+
error('One extra comma');
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
return result;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
function matchColorStop() {
|
|
1942
|
+
var color = matchColor();
|
|
1943
|
+
|
|
1944
|
+
if (!color) {
|
|
1945
|
+
error('Expected color definition');
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
color.length = matchDistance();
|
|
1949
|
+
return color;
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
function matchColor() {
|
|
1953
|
+
return matchHexColor() || matchRGBAColor() || matchRGBColor() || matchLiteralColor();
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
function matchLiteralColor() {
|
|
1957
|
+
return match('literal', tokens.literalColor, 0);
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
function matchHexColor() {
|
|
1961
|
+
return match('hex', tokens.hexColor, 1);
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
function matchRGBColor() {
|
|
1965
|
+
return matchCall(tokens.rgbColor, function () {
|
|
1966
|
+
return {
|
|
1967
|
+
type: 'rgb',
|
|
1968
|
+
value: matchListing(matchNumber)
|
|
1969
|
+
};
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
function matchRGBAColor() {
|
|
1974
|
+
return matchCall(tokens.rgbaColor, function () {
|
|
1975
|
+
return {
|
|
1976
|
+
type: 'rgba',
|
|
1977
|
+
value: matchListing(matchNumber)
|
|
1978
|
+
};
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
function matchNumber() {
|
|
1983
|
+
return scan(tokens.number)[1];
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
function matchDistance() {
|
|
1987
|
+
return match('%', tokens.percentageValue, 1) || matchPositionKeyword() || matchLength();
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
function matchPositionKeyword() {
|
|
1991
|
+
return match('position-keyword', tokens.positionKeywords, 1);
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
function matchLength() {
|
|
1995
|
+
return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1);
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
function match(type, pattern, captureIndex) {
|
|
1999
|
+
var captures = scan(pattern);
|
|
2000
|
+
|
|
2001
|
+
if (captures) {
|
|
2002
|
+
return {
|
|
2003
|
+
type: type,
|
|
2004
|
+
value: captures[captureIndex]
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
function scan(regexp) {
|
|
2010
|
+
var blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
2011
|
+
|
|
2012
|
+
if (blankCaptures) {
|
|
2013
|
+
consume(blankCaptures[0].length);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
var captures = regexp.exec(input);
|
|
2017
|
+
|
|
2018
|
+
if (captures) {
|
|
2019
|
+
consume(captures[0].length);
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
return captures;
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
function consume(size) {
|
|
2026
|
+
input = input.substring(size);
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
return function (code) {
|
|
2030
|
+
input = code;
|
|
2031
|
+
return getAST();
|
|
2032
|
+
};
|
|
2033
|
+
}();
|
|
2034
|
+
function computeLinearGradient(width, height, angle) {
|
|
2035
|
+
var rad = angle * Math.PI / 180;
|
|
2036
|
+
var rx = 0;
|
|
2037
|
+
var ry = 0;
|
|
2038
|
+
var rcx = rx + width / 2;
|
|
2039
|
+
var rcy = ry + height / 2; // get the length of gradient line
|
|
2040
|
+
// @see https://observablehq.com/@danburzo/css-gradient-line
|
|
2041
|
+
|
|
2042
|
+
var length = Math.abs(width * Math.cos(rad)) + Math.abs(height * Math.sin(rad));
|
|
2043
|
+
var x1 = rcx - Math.cos(rad) * length / 2;
|
|
2044
|
+
var y1 = rcy - Math.sin(rad) * length / 2;
|
|
2045
|
+
var x2 = rcx + Math.cos(rad) * length / 2;
|
|
2046
|
+
var y2 = rcy + Math.sin(rad) * length / 2;
|
|
2047
|
+
return {
|
|
2048
|
+
x1: x1,
|
|
2049
|
+
y1: y1,
|
|
2050
|
+
x2: x2,
|
|
2051
|
+
y2: y2
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
function computeRadialGradient(width, height, cx, cy) {
|
|
2055
|
+
var r = Math.sqrt(width * width + height * height) / 2;
|
|
2056
|
+
return {
|
|
2057
|
+
x: cx * width,
|
|
2058
|
+
y: cy * height,
|
|
2059
|
+
r: r
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
|
|
1691
2063
|
(function (PropertySyntax) {
|
|
1692
2064
|
/**
|
|
1693
2065
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
|
|
@@ -2203,210 +2575,134 @@ function formatAttribute(name, value) {
|
|
|
2203
2575
|
|
|
2204
2576
|
var CanvasConfig = manaSyringe.Syringe.defineToken('CanvasConfig');
|
|
2205
2577
|
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
*/
|
|
2578
|
+
function hasArcOrBezier(path) {
|
|
2579
|
+
var hasArc = false;
|
|
2580
|
+
var count = path.length;
|
|
2210
2581
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2582
|
+
for (var i = 0; i < count; i++) {
|
|
2583
|
+
var params = path[i];
|
|
2584
|
+
var cmd = params[0];
|
|
2585
|
+
|
|
2586
|
+
if (cmd === 'C' || cmd === 'A' || cmd === 'Q') {
|
|
2587
|
+
hasArc = true;
|
|
2588
|
+
break;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2218
2591
|
|
|
2219
|
-
|
|
2220
|
-
if (t === void 0) {
|
|
2221
|
-
t = 0.5;
|
|
2222
|
-
}
|
|
2223
|
-
|
|
2224
|
-
var p0 = pts.slice(0, 2);
|
|
2225
|
-
var p1 = pts.slice(2, 4);
|
|
2226
|
-
var p2 = pts.slice(4, 6);
|
|
2227
|
-
var p3 = pts.slice(6, 8);
|
|
2228
|
-
var p4 = midPoint(p0, p1, t);
|
|
2229
|
-
var p5 = midPoint(p1, p2, t);
|
|
2230
|
-
var p6 = midPoint(p2, p3, t);
|
|
2231
|
-
var p7 = midPoint(p4, p5, t);
|
|
2232
|
-
var p8 = midPoint(p5, p6, t);
|
|
2233
|
-
var p9 = midPoint(p7, p8, t);
|
|
2234
|
-
return [// @ts-ignore
|
|
2235
|
-
['C'].concat(p4, p7, p9), // @ts-ignore
|
|
2236
|
-
['C'].concat(p8, p6, p3)];
|
|
2592
|
+
return hasArc;
|
|
2237
2593
|
}
|
|
2594
|
+
function extractPolygons(pathArray) {
|
|
2595
|
+
var polygons = [];
|
|
2596
|
+
var polylines = [];
|
|
2597
|
+
var points = []; // 防止第一个命令不是 'M'
|
|
2238
2598
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2599
|
+
for (var i = 0; i < pathArray.length; i++) {
|
|
2600
|
+
var params = pathArray[i];
|
|
2601
|
+
var cmd = params[0];
|
|
2602
|
+
|
|
2603
|
+
if (cmd === 'M') {
|
|
2604
|
+
// 遇到 'M' 判定是否是新数组,新数组中没有点
|
|
2605
|
+
if (points.length) {
|
|
2606
|
+
// 如果存在点,则说明没有遇到 'Z',开始了一个新的多边形
|
|
2607
|
+
polylines.push(points);
|
|
2608
|
+
points = []; // 创建新的点
|
|
2609
|
+
}
|
|
2243
2610
|
|
|
2244
|
-
|
|
2245
|
-
|
|
2611
|
+
points.push([params[1], params[2]]);
|
|
2612
|
+
} else if (cmd === 'Z') {
|
|
2613
|
+
if (points.length) {
|
|
2614
|
+
// 存在点
|
|
2615
|
+
polygons.push(points);
|
|
2616
|
+
points = []; // 开始新的点集合
|
|
2617
|
+
} // 如果不存在点,同时 'Z',则说明是错误,不处理
|
|
2246
2618
|
|
|
2247
|
-
if (i) {
|
|
2248
|
-
// must be [segment,segment]
|
|
2249
|
-
subsegs = curveLength ? splitCubic(segmentData) : [segment, segment];
|
|
2250
2619
|
} else {
|
|
2251
|
-
|
|
2620
|
+
points.push([params[1], params[2]]);
|
|
2252
2621
|
}
|
|
2622
|
+
} // 说明 points 未放入 polygons 或者 polyline
|
|
2623
|
+
// 仅当只有一个 M,没有 Z 时会发生这种情况
|
|
2253
2624
|
|
|
2254
|
-
return {
|
|
2255
|
-
s: segment,
|
|
2256
|
-
ss: subsegs,
|
|
2257
|
-
l: curveLength
|
|
2258
|
-
};
|
|
2259
|
-
});
|
|
2260
|
-
}
|
|
2261
2625
|
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
}
|
|
2270
|
-
var l2 = c2.filter(function (x) {
|
|
2271
|
-
return x.l;
|
|
2272
|
-
}).length;
|
|
2273
|
-
var m1 = c1.filter(function (x) {
|
|
2274
|
-
return x.l;
|
|
2275
|
-
}).reduce(function (a, _ref) {
|
|
2276
|
-
var l = _ref.l;
|
|
2277
|
-
return a + l;
|
|
2278
|
-
}, 0) / l1 || 0;
|
|
2279
|
-
var m2 = c2.filter(function (x) {
|
|
2280
|
-
return x.l;
|
|
2281
|
-
}).reduce(function (a, _ref2) {
|
|
2282
|
-
var l = _ref2.l;
|
|
2283
|
-
return a + l;
|
|
2284
|
-
}, 0) / l2 || 0;
|
|
2285
|
-
var tl = TL || Math.max(L1, L2);
|
|
2286
|
-
var mm = [m1, m2];
|
|
2287
|
-
var dif = [tl - L1, tl - L2];
|
|
2288
|
-
var canSplit = 0;
|
|
2289
|
-
var result = [c1, c2].map(function (x, i) {
|
|
2290
|
-
return (// @ts-ignore
|
|
2291
|
-
x.l === tl ? x.map(function (y) {
|
|
2292
|
-
return y.s;
|
|
2293
|
-
}) : x.map(function (y, j) {
|
|
2294
|
-
canSplit = j && dif[i] && y.l >= mm[i];
|
|
2295
|
-
dif[i] -= canSplit ? 1 : 0;
|
|
2296
|
-
return canSplit ? y.ss : [y.s];
|
|
2297
|
-
}).flat()
|
|
2298
|
-
);
|
|
2299
|
-
});
|
|
2300
|
-
return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
|
|
2301
|
-
}
|
|
2302
|
-
function getDrawDirection(pathArray) {
|
|
2303
|
-
return getPathArea(pathArray) >= 0;
|
|
2626
|
+
if (points.length > 0) {
|
|
2627
|
+
polylines.push(points);
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
return {
|
|
2631
|
+
polygons: polygons,
|
|
2632
|
+
polylines: polylines
|
|
2633
|
+
};
|
|
2304
2634
|
}
|
|
2305
2635
|
|
|
2306
|
-
function
|
|
2307
|
-
|
|
2308
|
-
return 3 * ((y3 - y0) * (x1 + x2) - (x3 - x0) * (y1 + y2) + y1 * (x0 - x2) - x1 * (y0 - y2) + y3 * (x2 + x0 / 3) - x3 * (y2 + y0 / 3)) / 20;
|
|
2636
|
+
function isSamePoint(point1, point2) {
|
|
2637
|
+
return point1[0] === point2[0] && point1[1] === point2[1];
|
|
2309
2638
|
}
|
|
2310
2639
|
|
|
2311
|
-
function
|
|
2312
|
-
var
|
|
2313
|
-
var
|
|
2314
|
-
|
|
2315
|
-
var
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2640
|
+
function path2Segments(path) {
|
|
2641
|
+
var segments = [];
|
|
2642
|
+
var currentPoint = null; // 当前图形
|
|
2643
|
+
|
|
2644
|
+
var nextParams = null; // 下一节点的 path 参数
|
|
2645
|
+
// let startMovePoint = null; // 开始 M 的点,可能会有多个
|
|
2646
|
+
|
|
2647
|
+
var lastStartMovePointIndex = 0; // 最近一个开始点 M 的索引
|
|
2648
|
+
|
|
2649
|
+
var count = path.length;
|
|
2650
|
+
|
|
2651
|
+
for (var i = 0; i < count; i++) {
|
|
2652
|
+
var params = path[i];
|
|
2653
|
+
nextParams = path[i + 1];
|
|
2654
|
+
var command = params[0]; // 数学定义上的参数,便于后面的计算
|
|
2655
|
+
|
|
2656
|
+
var segment = {
|
|
2657
|
+
command: command,
|
|
2658
|
+
prePoint: currentPoint,
|
|
2659
|
+
params: params,
|
|
2660
|
+
startTangent: null,
|
|
2661
|
+
endTangent: null
|
|
2662
|
+
};
|
|
2663
|
+
|
|
2664
|
+
switch (command) {
|
|
2319
2665
|
case 'M':
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
y = my;
|
|
2325
|
-
return 0;
|
|
2666
|
+
// startMovePoint = [params[1], params[2]];
|
|
2667
|
+
lastStartMovePointIndex = i;
|
|
2668
|
+
break;
|
|
2669
|
+
}
|
|
2326
2670
|
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
len = getCubicSegArea.apply(0, [x, y].concat(seg.slice(1)));
|
|
2330
|
-
|
|
2331
|
-
var _seg$slice = seg.slice(-2);
|
|
2332
|
-
|
|
2333
|
-
x = _seg$slice[0];
|
|
2334
|
-
y = _seg$slice[1];
|
|
2335
|
-
return len;
|
|
2336
|
-
}
|
|
2337
|
-
}).reduce(function (a, b) {
|
|
2338
|
-
return a + b;
|
|
2339
|
-
}, 0);
|
|
2340
|
-
} // reverse CURVE based pathArray segments only
|
|
2341
|
-
|
|
2342
|
-
function reverseCurve(pathArray) {
|
|
2343
|
-
var rotatedCurve = pathArray.slice(1).map(function (x, i, curveOnly) {
|
|
2344
|
-
return (// @ts-ignore
|
|
2345
|
-
!i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1))
|
|
2346
|
-
);
|
|
2347
|
-
}) // @ts-ignore
|
|
2348
|
-
.map(function (x) {
|
|
2349
|
-
return x.map(function (y, i) {
|
|
2350
|
-
return x[x.length - i - 2 * (1 - i % 2)];
|
|
2351
|
-
});
|
|
2352
|
-
}).reverse(); // @ts-ignore
|
|
2671
|
+
var len = params.length;
|
|
2672
|
+
currentPoint = [params[len - 2], params[len - 1]]; // @ts-ignore
|
|
2353
2673
|
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
function clonePath(pathArray) {
|
|
2359
|
-
// @ts-ignore
|
|
2360
|
-
return pathArray.map(function (x) {
|
|
2361
|
-
if (Array.isArray(x)) {
|
|
2362
|
-
// @ts-ignore
|
|
2363
|
-
return clonePath(x);
|
|
2674
|
+
segment.currentPoint = currentPoint; // 如果当前点与最近一个 M 点相同,则最近一个 M 点的前一个点为当前点的前一个点
|
|
2675
|
+
|
|
2676
|
+
if (segments[lastStartMovePointIndex] && isSamePoint(currentPoint, segments[lastStartMovePointIndex].currentPoint)) {
|
|
2677
|
+
segments[lastStartMovePointIndex].prePoint = segment.prePoint;
|
|
2364
2678
|
}
|
|
2365
2679
|
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2680
|
+
var nextPoint = nextParams ? [nextParams[nextParams.length - 2], nextParams[nextParams.length - 1]] : null; // @ts-ignore
|
|
2681
|
+
|
|
2682
|
+
segment.nextPoint = nextPoint; // Add startTangent and endTangent
|
|
2369
2683
|
|
|
2370
|
-
|
|
2371
|
-
var segCount = a.length;
|
|
2372
|
-
var pointCount = segCount - 1;
|
|
2373
|
-
return a.map(function (f, idx) {
|
|
2374
|
-
return a.map(function (p, i) {
|
|
2375
|
-
var oldSegIdx = idx + i;
|
|
2376
|
-
var seg;
|
|
2684
|
+
var prePoint = segment.prePoint;
|
|
2377
2685
|
|
|
2378
|
-
|
|
2379
|
-
|
|
2686
|
+
if (command === 'C') {
|
|
2687
|
+
// 三次贝塞尔曲线有两个控制点
|
|
2688
|
+
var cp1 = [params[1], params[2]];
|
|
2689
|
+
var cp2 = [params[3], params[4]];
|
|
2690
|
+
segment.startTangent = [prePoint[0] - cp1[0], prePoint[1] - cp1[1]];
|
|
2691
|
+
segment.endTangent = [currentPoint[0] - cp2[0], currentPoint[1] - cp2[1]]; // horizontal line, eg. ['C', 100, 100, 100, 100, 200, 200]
|
|
2380
2692
|
|
|
2381
|
-
|
|
2693
|
+
if (segment.startTangent[0] === 0 && segment.startTangent[1] === 0) {
|
|
2694
|
+
segment.startTangent = [cp1[0] - cp2[0], cp1[1] - cp2[1]];
|
|
2382
2695
|
}
|
|
2383
2696
|
|
|
2384
|
-
if (
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
}
|
|
2697
|
+
if (segment.endTangent[0] === 0 && segment.endTangent[1] === 0) {
|
|
2698
|
+
segment.endTangent = [cp2[0] - cp1[0], cp2[1] - cp1[1]];
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2389
2701
|
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
}
|
|
2702
|
+
segments.push(segment);
|
|
2703
|
+
}
|
|
2393
2704
|
|
|
2394
|
-
|
|
2395
|
-
var segCount = a.length - 1;
|
|
2396
|
-
var lineLengths = [];
|
|
2397
|
-
var computedIndex = 0;
|
|
2398
|
-
var sumLensSqrd = 0;
|
|
2399
|
-
var rotations = getRotations(a);
|
|
2400
|
-
rotations.forEach(function (r, i) {
|
|
2401
|
-
a.slice(1).forEach(function (s, j) {
|
|
2402
|
-
// @ts-ignore
|
|
2403
|
-
sumLensSqrd += distanceSquareRoot(a[(i + j) % segCount].slice(-2), b[j % segCount].slice(-2));
|
|
2404
|
-
});
|
|
2405
|
-
lineLengths[i] = sumLensSqrd;
|
|
2406
|
-
sumLensSqrd = 0;
|
|
2407
|
-
});
|
|
2408
|
-
computedIndex = lineLengths.indexOf(Math.min.apply(null, lineLengths));
|
|
2409
|
-
return rotations[computedIndex];
|
|
2705
|
+
return segments;
|
|
2410
2706
|
}
|
|
2411
2707
|
|
|
2412
2708
|
function commandsToPathString(commands, object, applyLocalTransform) {
|
|
@@ -2498,7 +2794,11 @@ function rectToCommands(width, height, x, y, radius) {
|
|
|
2498
2794
|
trr = radius[1],
|
|
2499
2795
|
brr = radius[2],
|
|
2500
2796
|
blr = radius[3];
|
|
2501
|
-
|
|
2797
|
+
var signX = width > 0 ? 1 : -1;
|
|
2798
|
+
var signY = height > 0 ? 1 : -1; // sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
2799
|
+
|
|
2800
|
+
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
2801
|
+
return [['M', signX * tlr + x, y], ['L', width - signX * trr + x, y], trr ? ['A', trr, trr, 0, 0, sweepFlag, width + x, signY * trr + y] : null, ['L', width + x, height - signY * brr + y], brr ? ['A', brr, brr, 0, 0, sweepFlag, width + x - signX * brr, height + y] : null, ['L', x + signX * blr, height + y], blr ? ['A', blr, blr, 0, 0, sweepFlag, x, height + y - signY * blr] : null, ['L', x, signY * tlr + y], tlr ? ['A', tlr, tlr, 0, 0, sweepFlag, signX * tlr + x, y] : null, ['Z']].filter(function (command) {
|
|
2502
2802
|
return command;
|
|
2503
2803
|
});
|
|
2504
2804
|
}
|
|
@@ -2568,7 +2868,7 @@ function convertToPath(object, applyLocalTransform) {
|
|
|
2568
2868
|
return r.value !== 0;
|
|
2569
2869
|
});
|
|
2570
2870
|
commands = rectToCommands(width.value, height.value, x.value, y.value, hasRadius && radius.map(function (r) {
|
|
2571
|
-
return clamp(r.value, 0, Math.min(width.value / 2, height.value / 2));
|
|
2871
|
+
return clamp(r.value, 0, Math.min(Math.abs(width.value) / 2, Math.abs(height.value) / 2));
|
|
2572
2872
|
}));
|
|
2573
2873
|
break;
|
|
2574
2874
|
|
|
@@ -6634,12 +6934,11 @@ var CSSRGB = /*#__PURE__*/function (_CSSColorValue) {
|
|
|
6634
6934
|
return CSSRGB;
|
|
6635
6935
|
}(CSSColorValue);
|
|
6636
6936
|
|
|
6637
|
-
(function (
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
})(exports.GradientPatternType || (exports.GradientPatternType = {}));
|
|
6937
|
+
(function (GradientType) {
|
|
6938
|
+
GradientType[GradientType["Constant"] = 0] = "Constant";
|
|
6939
|
+
GradientType[GradientType["LinearGradient"] = 1] = "LinearGradient";
|
|
6940
|
+
GradientType[GradientType["RadialGradient"] = 2] = "RadialGradient";
|
|
6941
|
+
})(exports.GradientType || (exports.GradientType = {}));
|
|
6643
6942
|
|
|
6644
6943
|
var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
6645
6944
|
_inheritsLoose(CSSGradientValue, _CSSStyleValue);
|
|
@@ -6662,39 +6961,299 @@ var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) {
|
|
|
6662
6961
|
};
|
|
6663
6962
|
|
|
6664
6963
|
_proto.buildCSSText = function buildCSSText(n, p, result) {
|
|
6665
|
-
|
|
6964
|
+
return result;
|
|
6965
|
+
};
|
|
6966
|
+
|
|
6967
|
+
_proto.getType = function getType() {
|
|
6968
|
+
return exports.CSSStyleValueType.kColorType;
|
|
6969
|
+
};
|
|
6970
|
+
|
|
6971
|
+
return CSSGradientValue;
|
|
6972
|
+
}(CSSStyleValue);
|
|
6973
|
+
|
|
6974
|
+
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
6975
|
+
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
6976
|
+
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
|
|
6977
|
+
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
6978
|
+
|
|
6979
|
+
function spaceColorStops(colorStops) {
|
|
6980
|
+
var _colorStops$length;
|
|
6981
|
+
|
|
6982
|
+
var length = colorStops.length;
|
|
6983
|
+
colorStops[length - 1].length = (_colorStops$length = colorStops[length - 1].length) !== null && _colorStops$length !== void 0 ? _colorStops$length : {
|
|
6984
|
+
type: '%',
|
|
6985
|
+
value: '100'
|
|
6986
|
+
};
|
|
6987
|
+
|
|
6988
|
+
if (length > 1) {
|
|
6989
|
+
var _colorStops$0$length;
|
|
6990
|
+
|
|
6991
|
+
colorStops[0].length = (_colorStops$0$length = colorStops[0].length) !== null && _colorStops$0$length !== void 0 ? _colorStops$0$length : {
|
|
6992
|
+
type: '%',
|
|
6993
|
+
value: '0'
|
|
6994
|
+
};
|
|
6995
|
+
}
|
|
6996
|
+
|
|
6997
|
+
var previousIndex = 0;
|
|
6998
|
+
var previousOffset = Number(colorStops[0].length.value);
|
|
6999
|
+
|
|
7000
|
+
for (var i = 1; i < length; i++) {
|
|
7001
|
+
var _colorStops$i$length;
|
|
7002
|
+
|
|
7003
|
+
var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
|
|
7004
|
+
|
|
7005
|
+
if (!isNil(offset) && !isNil(previousOffset)) {
|
|
7006
|
+
for (var j = 1; j < i - previousIndex; j++) {
|
|
7007
|
+
colorStops[previousIndex + j].length = {
|
|
7008
|
+
type: '%',
|
|
7009
|
+
value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
|
|
7010
|
+
};
|
|
7011
|
+
}
|
|
7012
|
+
|
|
7013
|
+
previousIndex = i;
|
|
7014
|
+
previousOffset = Number(offset);
|
|
7015
|
+
}
|
|
7016
|
+
}
|
|
7017
|
+
} // The position of the gradient line's starting point.
|
|
7018
|
+
// different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
|
|
7019
|
+
|
|
7020
|
+
|
|
7021
|
+
var SideOrCornerToDegMap = {
|
|
7022
|
+
left: 270 - 90,
|
|
7023
|
+
top: 0 - 90,
|
|
7024
|
+
bottom: 180 - 90,
|
|
7025
|
+
right: 90 - 90,
|
|
7026
|
+
'left top': 315 - 90,
|
|
7027
|
+
'top left': 315 - 90,
|
|
7028
|
+
'left bottom': 225 - 90,
|
|
7029
|
+
'bottom left': 225 - 90,
|
|
7030
|
+
'right top': 45 - 90,
|
|
7031
|
+
'top right': 45 - 90,
|
|
7032
|
+
'right bottom': 135 - 90,
|
|
7033
|
+
'bottom right': 135 - 90
|
|
7034
|
+
};
|
|
7035
|
+
var angleToDeg = lodashEs.memoize(function (orientation) {
|
|
7036
|
+
var angle;
|
|
7037
|
+
|
|
7038
|
+
if (orientation.type === 'angular') {
|
|
7039
|
+
angle = Number(orientation.value);
|
|
7040
|
+
} else {
|
|
7041
|
+
angle = SideOrCornerToDegMap[orientation.value] || 0;
|
|
7042
|
+
}
|
|
7043
|
+
|
|
7044
|
+
return angle;
|
|
7045
|
+
});
|
|
7046
|
+
var positonToPercentage = lodashEs.memoize(function (position) {
|
|
7047
|
+
var cx = 0.5;
|
|
7048
|
+
var cy = 0.5;
|
|
7049
|
+
|
|
7050
|
+
if ((position === null || position === void 0 ? void 0 : position.type) === 'position') {
|
|
7051
|
+
var _position$value = position.value,
|
|
7052
|
+
x = _position$value.x,
|
|
7053
|
+
y = _position$value.y;
|
|
7054
|
+
|
|
7055
|
+
if ((x === null || x === void 0 ? void 0 : x.type) === 'position-keyword') {
|
|
7056
|
+
if (x.value === 'left') {
|
|
7057
|
+
cx = 0;
|
|
7058
|
+
} else if (x.value === 'center') {
|
|
7059
|
+
cx = 0.5;
|
|
7060
|
+
} else if (x.value === 'right') {
|
|
7061
|
+
cx = 1;
|
|
7062
|
+
} else if (x.value === 'top') {
|
|
7063
|
+
cy = 0;
|
|
7064
|
+
} else if (x.value === 'bottom') {
|
|
7065
|
+
cy = 1;
|
|
7066
|
+
}
|
|
7067
|
+
}
|
|
7068
|
+
|
|
7069
|
+
if ((y === null || y === void 0 ? void 0 : y.type) === 'position-keyword') {
|
|
7070
|
+
if (y.value === 'left') {
|
|
7071
|
+
cx = 0;
|
|
7072
|
+
} else if (y.value === 'center') {
|
|
7073
|
+
cy = 0.5;
|
|
7074
|
+
} else if (y.value === 'right') {
|
|
7075
|
+
cx = 1;
|
|
7076
|
+
} else if (y.value === 'top') {
|
|
7077
|
+
cy = 0;
|
|
7078
|
+
} else if (y.value === 'bottom') {
|
|
7079
|
+
cy = 1;
|
|
7080
|
+
}
|
|
7081
|
+
}
|
|
7082
|
+
|
|
7083
|
+
if ((x === null || x === void 0 ? void 0 : x.type) === '%') {
|
|
7084
|
+
cx = Number(x.value) / 100;
|
|
7085
|
+
}
|
|
7086
|
+
|
|
7087
|
+
if ((y === null || y === void 0 ? void 0 : y.type) === '%') {
|
|
7088
|
+
cy = Number(x.value) / 100;
|
|
7089
|
+
}
|
|
7090
|
+
}
|
|
7091
|
+
|
|
7092
|
+
return {
|
|
7093
|
+
cx: cx,
|
|
7094
|
+
cy: cy
|
|
7095
|
+
};
|
|
7096
|
+
});
|
|
7097
|
+
var parseGradient$1 = lodashEs.memoize(function (colorStr) {
|
|
7098
|
+
if (colorStr.indexOf('linear') > -1 || colorStr.indexOf('radial') > -1) {
|
|
7099
|
+
var ast = parseGradient(colorStr);
|
|
7100
|
+
return ast.map(function (_ref) {
|
|
7101
|
+
var type = _ref.type,
|
|
7102
|
+
orientation = _ref.orientation,
|
|
7103
|
+
colorStops = _ref.colorStops;
|
|
7104
|
+
spaceColorStops(colorStops);
|
|
7105
|
+
var steps = colorStops.map(function (colorStop) {
|
|
7106
|
+
// TODO: only support % for now, should calc percentage of axis length when using px/em
|
|
7107
|
+
return [Number(colorStop.length.value) / 100, colorStopToString(colorStop)];
|
|
7108
|
+
});
|
|
7109
|
+
|
|
7110
|
+
if (type === 'linear-gradient') {
|
|
7111
|
+
return new CSSGradientValue(exports.GradientType.LinearGradient, {
|
|
7112
|
+
angle: orientation ? angleToDeg(orientation) : 0,
|
|
7113
|
+
steps: steps,
|
|
7114
|
+
hash: colorStr
|
|
7115
|
+
});
|
|
7116
|
+
} else if (type === 'radial-gradient') {
|
|
7117
|
+
if (!orientation) {
|
|
7118
|
+
orientation = [{
|
|
7119
|
+
type: 'shape',
|
|
7120
|
+
value: 'circle'
|
|
7121
|
+
}];
|
|
7122
|
+
}
|
|
7123
|
+
|
|
7124
|
+
if (orientation[0].type === 'shape' && orientation[0].value === 'circle') {
|
|
7125
|
+
var _positonToPercentage = positonToPercentage(orientation[0].at),
|
|
7126
|
+
cx = _positonToPercentage.cx,
|
|
7127
|
+
cy = _positonToPercentage.cy;
|
|
7128
|
+
|
|
7129
|
+
return new CSSGradientValue(exports.GradientType.RadialGradient, {
|
|
7130
|
+
cx: cx,
|
|
7131
|
+
cy: cy,
|
|
7132
|
+
steps: steps,
|
|
7133
|
+
hash: colorStr
|
|
7134
|
+
});
|
|
7135
|
+
} // } else if (type === 'repeating-linear-gradient') {
|
|
7136
|
+
// } else if (type === 'repeating-radial-gradient') {
|
|
7137
|
+
|
|
7138
|
+
}
|
|
7139
|
+
});
|
|
7140
|
+
} // legacy format, should be deprecated later
|
|
7141
|
+
|
|
7142
|
+
|
|
7143
|
+
var type = colorStr[0];
|
|
7144
|
+
|
|
7145
|
+
if (colorStr[1] === '(' || colorStr[2] === '(') {
|
|
7146
|
+
if (type === 'l') {
|
|
7147
|
+
var arr = regexLG.exec(colorStr);
|
|
7148
|
+
|
|
7149
|
+
if (arr) {
|
|
7150
|
+
var _arr$2$match;
|
|
7151
|
+
|
|
7152
|
+
var steps = ((_arr$2$match = arr[2].match(regexColorStop)) === null || _arr$2$match === void 0 ? void 0 : _arr$2$match.map(function (stop) {
|
|
7153
|
+
return stop.split(':');
|
|
7154
|
+
})) || [];
|
|
7155
|
+
return [new CSSGradientValue(exports.GradientType.LinearGradient, {
|
|
7156
|
+
angle: parseFloat(arr[1]),
|
|
7157
|
+
steps: steps.map(function (_ref2) {
|
|
7158
|
+
var offset = _ref2[0],
|
|
7159
|
+
color = _ref2[1];
|
|
7160
|
+
return [Number(offset), color];
|
|
7161
|
+
}),
|
|
7162
|
+
hash: colorStr
|
|
7163
|
+
})];
|
|
7164
|
+
}
|
|
7165
|
+
} else if (type === 'r') {
|
|
7166
|
+
var parsedRadialGradient = parseRadialGradient(colorStr);
|
|
7167
|
+
|
|
7168
|
+
if (parsedRadialGradient) {
|
|
7169
|
+
if (isString(parsedRadialGradient)) {
|
|
7170
|
+
colorStr = parsedRadialGradient;
|
|
7171
|
+
} else {
|
|
7172
|
+
return [new CSSGradientValue(exports.GradientType.RadialGradient, parsedRadialGradient)];
|
|
7173
|
+
}
|
|
7174
|
+
}
|
|
7175
|
+
} else if (type === 'p') {
|
|
7176
|
+
return parsePattern(colorStr);
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
});
|
|
7180
|
+
|
|
7181
|
+
function parseRadialGradient(gradientStr) {
|
|
7182
|
+
var arr = regexRG.exec(gradientStr);
|
|
7183
|
+
|
|
7184
|
+
if (arr) {
|
|
7185
|
+
var _arr$4$match;
|
|
7186
|
+
|
|
7187
|
+
var steps = ((_arr$4$match = arr[4].match(regexColorStop)) === null || _arr$4$match === void 0 ? void 0 : _arr$4$match.map(function (stop) {
|
|
7188
|
+
return stop.split(':');
|
|
7189
|
+
})) || [];
|
|
7190
|
+
return {
|
|
7191
|
+
cx: 0.5,
|
|
7192
|
+
cy: 0.5,
|
|
7193
|
+
steps: steps.map(function (_ref3) {
|
|
7194
|
+
var offset = _ref3[0],
|
|
7195
|
+
color = _ref3[1];
|
|
7196
|
+
return [Number(offset), color];
|
|
7197
|
+
}),
|
|
7198
|
+
hash: gradientStr
|
|
7199
|
+
};
|
|
7200
|
+
}
|
|
7201
|
+
|
|
7202
|
+
return null;
|
|
7203
|
+
}
|
|
7204
|
+
|
|
7205
|
+
function parsePattern(patternStr) {
|
|
7206
|
+
var arr = regexPR.exec(patternStr);
|
|
7207
|
+
|
|
7208
|
+
if (arr) {
|
|
7209
|
+
var repetition = arr[1];
|
|
7210
|
+
var src = arr[2];
|
|
7211
|
+
|
|
7212
|
+
switch (repetition) {
|
|
7213
|
+
case 'a':
|
|
7214
|
+
repetition = 'repeat';
|
|
7215
|
+
break;
|
|
7216
|
+
|
|
7217
|
+
case 'x':
|
|
7218
|
+
repetition = 'repeat-x';
|
|
7219
|
+
break;
|
|
7220
|
+
|
|
7221
|
+
case 'y':
|
|
7222
|
+
repetition = 'repeat-y';
|
|
7223
|
+
break;
|
|
7224
|
+
|
|
7225
|
+
case 'n':
|
|
7226
|
+
repetition = 'no-repeat';
|
|
7227
|
+
break;
|
|
6666
7228
|
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
return step.join(',');
|
|
6670
|
-
}).join(',') + ")";
|
|
6671
|
-
} else if (this.type === exports.GradientPatternType.RadialGradient) {
|
|
6672
|
-
text = "radial-gradient(" + this.value.steps.map(function (step) {
|
|
6673
|
-
return step.join(',');
|
|
6674
|
-
}).join(',') + ")";
|
|
6675
|
-
} else if (this.type === exports.GradientPatternType.Pattern) {
|
|
6676
|
-
text = "url(" + this.value.src + ")";
|
|
7229
|
+
default:
|
|
7230
|
+
repetition = 'no-repeat';
|
|
6677
7231
|
}
|
|
6678
7232
|
|
|
6679
|
-
return
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
}
|
|
7233
|
+
return {
|
|
7234
|
+
image: src,
|
|
7235
|
+
// @ts-ignore
|
|
7236
|
+
repetition: repetition
|
|
7237
|
+
};
|
|
7238
|
+
}
|
|
6685
7239
|
|
|
6686
|
-
return
|
|
6687
|
-
}
|
|
7240
|
+
return null;
|
|
7241
|
+
}
|
|
6688
7242
|
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
7243
|
+
function isPattern(object) {
|
|
7244
|
+
return isObject(object) && !!object.image;
|
|
7245
|
+
}
|
|
6693
7246
|
/**
|
|
6694
7247
|
* @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
|
|
6695
7248
|
*/
|
|
6696
7249
|
|
|
6697
|
-
|
|
7250
|
+
var parseColor = lodashEs.memoize(function (colorStr) {
|
|
7251
|
+
if (isPattern(colorStr)) {
|
|
7252
|
+
return _extends({
|
|
7253
|
+
repetition: 'repeat'
|
|
7254
|
+
}, colorStr);
|
|
7255
|
+
}
|
|
7256
|
+
|
|
6698
7257
|
if (isNil(colorStr)) {
|
|
6699
7258
|
colorStr = '';
|
|
6700
7259
|
}
|
|
@@ -6705,34 +7264,13 @@ function parseColor(colorStr) {
|
|
|
6705
7264
|
} else if (colorStr === 'currentColor') {
|
|
6706
7265
|
// @see https://github.com/adobe-webplatform/Snap.svg/issues/526
|
|
6707
7266
|
colorStr = 'black';
|
|
6708
|
-
}
|
|
6709
|
-
|
|
6710
|
-
var type = colorStr[0];
|
|
7267
|
+
} // support CSS gradient syntax
|
|
6711
7268
|
|
|
6712
|
-
if (colorStr[1] === '(' || colorStr[2] === '(') {
|
|
6713
|
-
if (type === 'l') {
|
|
6714
|
-
var parsedLineGradient = parseLineGradient(colorStr);
|
|
6715
|
-
|
|
6716
|
-
if (parsedLineGradient) {
|
|
6717
|
-
return new CSSGradientValue(exports.GradientPatternType.LinearGradient, parsedLineGradient);
|
|
6718
|
-
}
|
|
6719
|
-
} else if (type === 'r') {
|
|
6720
|
-
var parsedRadialGradient = parseRadialGradient(colorStr);
|
|
6721
7269
|
|
|
6722
|
-
|
|
6723
|
-
if (isString(parsedRadialGradient)) {
|
|
6724
|
-
colorStr = parsedRadialGradient;
|
|
6725
|
-
} else {
|
|
6726
|
-
return new CSSGradientValue(exports.GradientPatternType.RadialGradient, parsedRadialGradient);
|
|
6727
|
-
}
|
|
6728
|
-
}
|
|
6729
|
-
} else if (type === 'p') {
|
|
6730
|
-
var pattern = parsePattern(colorStr);
|
|
7270
|
+
var g = parseGradient$1(colorStr);
|
|
6731
7271
|
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
}
|
|
6735
|
-
}
|
|
7272
|
+
if (g) {
|
|
7273
|
+
return g;
|
|
6736
7274
|
} // constants
|
|
6737
7275
|
|
|
6738
7276
|
|
|
@@ -6755,7 +7293,7 @@ function parseColor(colorStr) {
|
|
|
6755
7293
|
// (color && `rgba(${color.r || 0},${color.g || 0},${color.b || 0},${color.opacity})`) ||
|
|
6756
7294
|
// 'rgba(0,0,0,0)',
|
|
6757
7295
|
// };
|
|
6758
|
-
}
|
|
7296
|
+
});
|
|
6759
7297
|
function mergeColors(left, right) {
|
|
6760
7298
|
// only support constant value, exclude gradient & pattern
|
|
6761
7299
|
if (!(left instanceof CSSRGB) || !(right instanceof CSSRGB)) {
|
|
@@ -6776,149 +7314,6 @@ function mergeColors(left, right) {
|
|
|
6776
7314
|
}];
|
|
6777
7315
|
}
|
|
6778
7316
|
|
|
6779
|
-
function parsePattern(patternStr) {
|
|
6780
|
-
var arr = regexPR.exec(patternStr);
|
|
6781
|
-
|
|
6782
|
-
if (arr) {
|
|
6783
|
-
var repetition = arr[1];
|
|
6784
|
-
var src = arr[2];
|
|
6785
|
-
|
|
6786
|
-
switch (repetition) {
|
|
6787
|
-
case 'a':
|
|
6788
|
-
repetition = 'repeat';
|
|
6789
|
-
break;
|
|
6790
|
-
|
|
6791
|
-
case 'x':
|
|
6792
|
-
repetition = 'repeat-x';
|
|
6793
|
-
break;
|
|
6794
|
-
|
|
6795
|
-
case 'y':
|
|
6796
|
-
repetition = 'repeat-y';
|
|
6797
|
-
break;
|
|
6798
|
-
|
|
6799
|
-
case 'n':
|
|
6800
|
-
repetition = 'no-repeat';
|
|
6801
|
-
break;
|
|
6802
|
-
|
|
6803
|
-
default:
|
|
6804
|
-
repetition = 'no-repeat';
|
|
6805
|
-
}
|
|
6806
|
-
|
|
6807
|
-
return {
|
|
6808
|
-
src: src,
|
|
6809
|
-
repetition: repetition,
|
|
6810
|
-
hash: patternStr
|
|
6811
|
-
};
|
|
6812
|
-
}
|
|
6813
|
-
|
|
6814
|
-
return null;
|
|
6815
|
-
}
|
|
6816
|
-
|
|
6817
|
-
function parseLineGradient(gradientStr) {
|
|
6818
|
-
var arr = regexLG.exec(gradientStr);
|
|
6819
|
-
|
|
6820
|
-
if (arr) {
|
|
6821
|
-
var _arr$2$match;
|
|
6822
|
-
|
|
6823
|
-
var angle = parseFloat(arr[1]) % 360 * (Math.PI / 180);
|
|
6824
|
-
var steps = ((_arr$2$match = arr[2].match(regexColorStop)) === null || _arr$2$match === void 0 ? void 0 : _arr$2$match.map(function (stop) {
|
|
6825
|
-
return stop.split(':');
|
|
6826
|
-
})) || [];
|
|
6827
|
-
var maxX = 1,
|
|
6828
|
-
maxY = 1;
|
|
6829
|
-
var minX = 0,
|
|
6830
|
-
minY = 0;
|
|
6831
|
-
var start;
|
|
6832
|
-
var end;
|
|
6833
|
-
|
|
6834
|
-
if (angle >= 0 && angle < 1 / 2 * Math.PI) {
|
|
6835
|
-
start = {
|
|
6836
|
-
x: minX,
|
|
6837
|
-
y: minY
|
|
6838
|
-
};
|
|
6839
|
-
end = {
|
|
6840
|
-
x: maxX,
|
|
6841
|
-
y: maxY
|
|
6842
|
-
};
|
|
6843
|
-
} else if (1 / 2 * Math.PI <= angle && angle < Math.PI) {
|
|
6844
|
-
start = {
|
|
6845
|
-
x: maxX,
|
|
6846
|
-
y: minY
|
|
6847
|
-
};
|
|
6848
|
-
end = {
|
|
6849
|
-
x: minX,
|
|
6850
|
-
y: maxY
|
|
6851
|
-
};
|
|
6852
|
-
} else if (Math.PI <= angle && angle < 3 / 2 * Math.PI) {
|
|
6853
|
-
start = {
|
|
6854
|
-
x: maxX,
|
|
6855
|
-
y: maxY
|
|
6856
|
-
};
|
|
6857
|
-
end = {
|
|
6858
|
-
x: minX,
|
|
6859
|
-
y: minY
|
|
6860
|
-
};
|
|
6861
|
-
} else {
|
|
6862
|
-
start = {
|
|
6863
|
-
x: minX,
|
|
6864
|
-
y: maxY
|
|
6865
|
-
};
|
|
6866
|
-
end = {
|
|
6867
|
-
x: maxX,
|
|
6868
|
-
y: minY
|
|
6869
|
-
};
|
|
6870
|
-
}
|
|
6871
|
-
|
|
6872
|
-
var tanTheta = Math.tan(angle);
|
|
6873
|
-
var tanTheta2 = tanTheta * tanTheta;
|
|
6874
|
-
var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
|
|
6875
|
-
var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
|
|
6876
|
-
return {
|
|
6877
|
-
x0: start.x,
|
|
6878
|
-
y0: start.y,
|
|
6879
|
-
x1: x,
|
|
6880
|
-
y1: y,
|
|
6881
|
-
steps: steps,
|
|
6882
|
-
hash: gradientStr
|
|
6883
|
-
};
|
|
6884
|
-
}
|
|
6885
|
-
|
|
6886
|
-
return null;
|
|
6887
|
-
}
|
|
6888
|
-
|
|
6889
|
-
function parseRadialGradient(gradientStr) {
|
|
6890
|
-
var arr = regexRG.exec(gradientStr);
|
|
6891
|
-
|
|
6892
|
-
if (arr) {
|
|
6893
|
-
var _arr$4$match;
|
|
6894
|
-
|
|
6895
|
-
var fx = parseFloat(arr[1]);
|
|
6896
|
-
var fy = parseFloat(arr[2]);
|
|
6897
|
-
var fr = parseFloat(arr[3]);
|
|
6898
|
-
var steps = ((_arr$4$match = arr[4].match(regexColorStop)) === null || _arr$4$match === void 0 ? void 0 : _arr$4$match.map(function (stop) {
|
|
6899
|
-
return stop.split(':');
|
|
6900
|
-
})) || []; // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
|
|
6901
|
-
|
|
6902
|
-
if (fr === 0) {
|
|
6903
|
-
var colors = arr[4].match(regexColorStop);
|
|
6904
|
-
return colors[colors.length - 1].split(':')[1];
|
|
6905
|
-
}
|
|
6906
|
-
|
|
6907
|
-
return {
|
|
6908
|
-
x0: fx,
|
|
6909
|
-
y0: fy,
|
|
6910
|
-
r0: 0,
|
|
6911
|
-
x1: 0.5,
|
|
6912
|
-
y1: 0.5,
|
|
6913
|
-
r1: fr,
|
|
6914
|
-
steps: steps,
|
|
6915
|
-
hash: gradientStr
|
|
6916
|
-
};
|
|
6917
|
-
}
|
|
6918
|
-
|
|
6919
|
-
return null;
|
|
6920
|
-
}
|
|
6921
|
-
|
|
6922
7317
|
/**
|
|
6923
7318
|
* Axis-Aligned Bounding Box
|
|
6924
7319
|
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
@@ -7632,8 +8027,7 @@ function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
|
7632
8027
|
if (valueWithUnit.unit === exports.UnitType.kPixels) {
|
|
7633
8028
|
return Number(valueWithUnit.value);
|
|
7634
8029
|
} else if (valueWithUnit.unit === exports.UnitType.kPercentage && target) {
|
|
7635
|
-
|
|
7636
|
-
var bounds = target.getGeometryBounds();
|
|
8030
|
+
var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() : target.getGeometryBounds();
|
|
7637
8031
|
var size = 0;
|
|
7638
8032
|
|
|
7639
8033
|
if (!AABB.isEmpty(bounds)) {
|
|
@@ -7708,31 +8102,40 @@ function mergeNumberLists(left, right) {
|
|
|
7708
8102
|
}
|
|
7709
8103
|
|
|
7710
8104
|
function parsePath(path, object) {
|
|
7711
|
-
var absolutePath
|
|
8105
|
+
var absolutePath;
|
|
8106
|
+
|
|
8107
|
+
try {
|
|
8108
|
+
absolutePath = util.normalizePath(path);
|
|
8109
|
+
} catch (e) {
|
|
8110
|
+
absolutePath = util.normalizePath('');
|
|
8111
|
+
console.error("[g]: Invalid SVG Path definition: " + path);
|
|
8112
|
+
}
|
|
8113
|
+
|
|
7712
8114
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
7713
|
-
var clonedAbsolutePath = absolutePath.slice();
|
|
7714
8115
|
|
|
7715
|
-
var _extractPolygons = extractPolygons(
|
|
8116
|
+
var _extractPolygons = extractPolygons(absolutePath),
|
|
7716
8117
|
polygons = _extractPolygons.polygons,
|
|
7717
8118
|
polylines = _extractPolygons.polylines; // convert to curves to do morphing & picking later
|
|
7718
8119
|
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
7719
8120
|
|
|
7720
8121
|
|
|
7721
|
-
var _path2Curve = util.path2Curve(
|
|
8122
|
+
var _path2Curve = util.path2Curve(absolutePath, true),
|
|
7722
8123
|
curve = _path2Curve[0],
|
|
7723
|
-
zCommandIndexes = _path2Curve[1];
|
|
8124
|
+
zCommandIndexes = _path2Curve[1]; // for later use
|
|
7724
8125
|
|
|
7725
|
-
var segments = util.path2Segments(clonedAbsolutePath);
|
|
7726
8126
|
|
|
7727
|
-
var
|
|
7728
|
-
totalLength = _calcLength.totalLength,
|
|
7729
|
-
curveSegments = _calcLength.curveSegments;
|
|
8127
|
+
var segments = path2Segments(curve);
|
|
7730
8128
|
|
|
7731
|
-
var
|
|
8129
|
+
var _getPathBBoxTotalLeng = util.getPathBBoxTotalLength(absolutePath),
|
|
8130
|
+
x = _getPathBBoxTotalLeng.x,
|
|
8131
|
+
y = _getPathBBoxTotalLeng.y,
|
|
8132
|
+
width = _getPathBBoxTotalLeng.width,
|
|
8133
|
+
height = _getPathBBoxTotalLeng.height,
|
|
8134
|
+
length = _getPathBBoxTotalLeng.length;
|
|
7732
8135
|
|
|
7733
8136
|
if (object) {
|
|
7734
|
-
object.parsedStyle.defX =
|
|
7735
|
-
object.parsedStyle.defY =
|
|
8137
|
+
object.parsedStyle.defX = x;
|
|
8138
|
+
object.parsedStyle.defY = y;
|
|
7736
8139
|
}
|
|
7737
8140
|
|
|
7738
8141
|
return {
|
|
@@ -7742,169 +8145,22 @@ function parsePath(path, object) {
|
|
|
7742
8145
|
polygons: polygons,
|
|
7743
8146
|
polylines: polylines,
|
|
7744
8147
|
curve: curve,
|
|
7745
|
-
totalLength:
|
|
7746
|
-
curveSegments: curveSegments,
|
|
8148
|
+
totalLength: length,
|
|
7747
8149
|
zCommandIndexes: zCommandIndexes,
|
|
7748
|
-
rect:
|
|
7749
|
-
};
|
|
7750
|
-
}
|
|
7751
|
-
|
|
7752
|
-
function hasArcOrBezier(path) {
|
|
7753
|
-
var hasArc = false;
|
|
7754
|
-
var count = path.length;
|
|
7755
|
-
|
|
7756
|
-
for (var i = 0; i < count; i++) {
|
|
7757
|
-
var params = path[i];
|
|
7758
|
-
var cmd = params[0];
|
|
7759
|
-
|
|
7760
|
-
if (cmd === 'C' || cmd === 'A' || cmd === 'Q') {
|
|
7761
|
-
hasArc = true;
|
|
7762
|
-
break;
|
|
7763
|
-
}
|
|
7764
|
-
}
|
|
7765
|
-
|
|
7766
|
-
return hasArc;
|
|
7767
|
-
}
|
|
7768
|
-
|
|
7769
|
-
function extractPolygons(pathArray) {
|
|
7770
|
-
var polygons = [];
|
|
7771
|
-
var polylines = [];
|
|
7772
|
-
var points = []; // 防止第一个命令不是 'M'
|
|
7773
|
-
|
|
7774
|
-
for (var i = 0; i < pathArray.length; i++) {
|
|
7775
|
-
var params = pathArray[i];
|
|
7776
|
-
var cmd = params[0];
|
|
7777
|
-
|
|
7778
|
-
if (cmd === 'M') {
|
|
7779
|
-
// 遇到 'M' 判定是否是新数组,新数组中没有点
|
|
7780
|
-
if (points.length) {
|
|
7781
|
-
// 如果存在点,则说明没有遇到 'Z',开始了一个新的多边形
|
|
7782
|
-
polylines.push(points);
|
|
7783
|
-
points = []; // 创建新的点
|
|
7784
|
-
}
|
|
7785
|
-
|
|
7786
|
-
points.push([params[1], params[2]]);
|
|
7787
|
-
} else if (cmd === 'Z') {
|
|
7788
|
-
if (points.length) {
|
|
7789
|
-
// 存在点
|
|
7790
|
-
polygons.push(points);
|
|
7791
|
-
points = []; // 开始新的点集合
|
|
7792
|
-
} // 如果不存在点,同时 'Z',则说明是错误,不处理
|
|
7793
|
-
|
|
7794
|
-
} else {
|
|
7795
|
-
points.push([params[1], params[2]]);
|
|
7796
|
-
}
|
|
7797
|
-
} // 说明 points 未放入 polygons 或者 polyline
|
|
7798
|
-
// 仅当只有一个 M,没有 Z 时会发生这种情况
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
if (points.length > 0) {
|
|
7802
|
-
polylines.push(points);
|
|
7803
|
-
}
|
|
7804
|
-
|
|
7805
|
-
return {
|
|
7806
|
-
polygons: polygons,
|
|
7807
|
-
polylines: polylines
|
|
7808
|
-
};
|
|
7809
|
-
}
|
|
7810
|
-
|
|
7811
|
-
function calcLength(curve) {
|
|
7812
|
-
var totalLength = 0;
|
|
7813
|
-
var tempLength = 0; // 每段 curve 对应起止点的长度比例列表,形如: [[0, 0.25], [0.25, 0.6]. [0.6, 0.9], [0.9, 1]]
|
|
7814
|
-
|
|
7815
|
-
var curveSegments = [];
|
|
7816
|
-
var segmentT;
|
|
7817
|
-
var segmentL;
|
|
7818
|
-
var segmentN;
|
|
7819
|
-
var l;
|
|
7820
|
-
|
|
7821
|
-
if (!curve) {
|
|
7822
|
-
return {
|
|
7823
|
-
curveSegments: [],
|
|
7824
|
-
totalLength: totalLength
|
|
7825
|
-
};
|
|
7826
|
-
}
|
|
7827
|
-
|
|
7828
|
-
curve.forEach(function (segment, i) {
|
|
7829
|
-
segmentN = curve[i + 1];
|
|
7830
|
-
l = segment.length;
|
|
7831
|
-
|
|
7832
|
-
if (segmentN) {
|
|
7833
|
-
totalLength += gMath.Cubic.length(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]) || 0;
|
|
7834
|
-
}
|
|
7835
|
-
});
|
|
7836
|
-
|
|
7837
|
-
if (totalLength === 0) {
|
|
7838
|
-
return {
|
|
7839
|
-
curveSegments: [],
|
|
7840
|
-
totalLength: totalLength
|
|
7841
|
-
};
|
|
7842
|
-
}
|
|
7843
|
-
|
|
7844
|
-
curve.forEach(function (segment, i) {
|
|
7845
|
-
segmentN = curve[i + 1];
|
|
7846
|
-
l = segment.length;
|
|
7847
|
-
|
|
7848
|
-
if (segmentN) {
|
|
7849
|
-
segmentT = [];
|
|
7850
|
-
segmentT[0] = tempLength / totalLength;
|
|
7851
|
-
segmentL = gMath.Cubic.length(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]); // 当 path 不连续时,segmentL 可能为空,为空时需要作为 0 处理
|
|
7852
|
-
|
|
7853
|
-
tempLength += segmentL || 0;
|
|
7854
|
-
segmentT[1] = tempLength / totalLength;
|
|
7855
|
-
curveSegments.push(segmentT);
|
|
7856
|
-
}
|
|
7857
|
-
});
|
|
7858
|
-
return {
|
|
7859
|
-
curveSegments: curveSegments,
|
|
7860
|
-
totalLength: totalLength
|
|
8150
|
+
rect: new Rectangle(x, y, width, height)
|
|
7861
8151
|
};
|
|
7862
8152
|
}
|
|
7863
|
-
|
|
7864
|
-
function getPathBBox(segments) {
|
|
7865
|
-
var x = 0;
|
|
7866
|
-
var y = 0;
|
|
7867
|
-
var X = [];
|
|
7868
|
-
var Y = [];
|
|
7869
|
-
segments.forEach(function (segment) {
|
|
7870
|
-
var _segment$slice = segment.slice(-2),
|
|
7871
|
-
s1 = _segment$slice[0],
|
|
7872
|
-
s2 = _segment$slice[1];
|
|
7873
|
-
|
|
7874
|
-
if (segment[0] === 'M') {
|
|
7875
|
-
x = s1;
|
|
7876
|
-
y = s2;
|
|
7877
|
-
X.push(s1);
|
|
7878
|
-
Y.push(s2);
|
|
7879
|
-
} else if (segment[0] === 'C') {
|
|
7880
|
-
// @ts-ignore
|
|
7881
|
-
var dim = gMath.Cubic.box.apply(gMath.Cubic, [x, y].concat(segment.slice(1)));
|
|
7882
|
-
X = X.concat(dim.x, dim.x + dim.width);
|
|
7883
|
-
Y = Y.concat(dim.y, dim.y + dim.height);
|
|
7884
|
-
x = s1;
|
|
7885
|
-
y = s2;
|
|
7886
|
-
}
|
|
7887
|
-
});
|
|
7888
|
-
var xTop = Math.min.apply(0, X);
|
|
7889
|
-
var yTop = Math.min.apply(0, Y);
|
|
7890
|
-
var xBot = Math.max.apply(0, X);
|
|
7891
|
-
var yBot = Math.max.apply(0, Y);
|
|
7892
|
-
var width = xBot - xTop;
|
|
7893
|
-
var height = yBot - yTop;
|
|
7894
|
-
return new Rectangle(xTop, yTop, width, height);
|
|
7895
|
-
}
|
|
7896
|
-
|
|
7897
8153
|
function mergePaths(left, right, object) {
|
|
7898
8154
|
var curve1 = left.curve;
|
|
7899
8155
|
var curve2 = right.curve;
|
|
7900
8156
|
var curves = [curve1, curve2];
|
|
7901
8157
|
|
|
7902
8158
|
if (curve1.length !== curve2.length) {
|
|
7903
|
-
curves = equalizeSegments(curve1, curve2);
|
|
8159
|
+
curves = util.equalizeSegments(curve1, curve2);
|
|
7904
8160
|
}
|
|
7905
8161
|
|
|
7906
|
-
var curve0 = getDrawDirection(curves[0]) !== getDrawDirection(curves[1]) ? reverseCurve(curves[0]) : clonePath(curves[0]);
|
|
7907
|
-
return [curve0, getRotatedCurve(curves[1], curve0), function (pathArray) {
|
|
8162
|
+
var curve0 = util.getDrawDirection(curves[0]) !== util.getDrawDirection(curves[1]) ? util.reverseCurve(curves[0]) : util.clonePath(curves[0]);
|
|
8163
|
+
return [curve0, util.getRotatedCurve(curves[1], curve0), function (pathArray) {
|
|
7908
8164
|
// need converting to path string?
|
|
7909
8165
|
return pathArray;
|
|
7910
8166
|
}];
|
|
@@ -11829,37 +12085,13 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
11829
12085
|
;
|
|
11830
12086
|
|
|
11831
12087
|
_proto.getPoint = function getPoint(ratio) {
|
|
11832
|
-
var
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
if (!this.parsedStyle.path.curveSegments.length) {
|
|
11837
|
-
if (curve) {
|
|
11838
|
-
return new Point(curve[0][1], curve[0][2]);
|
|
11839
|
-
}
|
|
12088
|
+
var _this$parsedStyle$pat = this.parsedStyle.path,
|
|
12089
|
+
totalLength = _this$parsedStyle$pat.totalLength,
|
|
12090
|
+
absolutePath = _this$parsedStyle$pat.absolutePath;
|
|
11840
12091
|
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
this.parsedStyle.path.curveSegments.forEach(function (v, i) {
|
|
11845
|
-
if (ratio >= v[0] && ratio <= v[1]) {
|
|
11846
|
-
subt = (ratio - v[0]) / (v[1] - v[0]);
|
|
11847
|
-
index = i;
|
|
11848
|
-
}
|
|
11849
|
-
});
|
|
11850
|
-
var seg = curve[index];
|
|
11851
|
-
|
|
11852
|
-
if (isNil(seg) || isNil(index)) {
|
|
11853
|
-
return null;
|
|
11854
|
-
}
|
|
11855
|
-
|
|
11856
|
-
var l = seg.length;
|
|
11857
|
-
var nextSeg = curve[index + 1];
|
|
11858
|
-
|
|
11859
|
-
var _CubicUtil$pointAt = gMath.Cubic.pointAt( // @ts-ignore
|
|
11860
|
-
seg[l - 2], seg[l - 1], nextSeg[1], nextSeg[2], nextSeg[3], nextSeg[4], nextSeg[5], nextSeg[6], subt),
|
|
11861
|
-
x = _CubicUtil$pointAt.x,
|
|
11862
|
-
y = _CubicUtil$pointAt.y;
|
|
12092
|
+
var _getPointAtLength = util.getPointAtLength(absolutePath, ratio * totalLength),
|
|
12093
|
+
x = _getPointAtLength.x,
|
|
12094
|
+
y = _getPointAtLength.y;
|
|
11863
12095
|
|
|
11864
12096
|
return new Point(x, y);
|
|
11865
12097
|
}
|
|
@@ -13234,6 +13466,7 @@ function dispatchCallbacks() {
|
|
|
13234
13466
|
scale: [1, 10],
|
|
13235
13467
|
}
|
|
13236
13468
|
*/
|
|
13469
|
+
|
|
13237
13470
|
function convertToArrayForm(effectInput) {
|
|
13238
13471
|
var normalizedEffectInput = [];
|
|
13239
13472
|
|
|
@@ -13346,7 +13579,7 @@ function normalizeKeyframes(effectInput, timing) {
|
|
|
13346
13579
|
for (var i = 0; i < keyframes.length; i++) {
|
|
13347
13580
|
var offset = keyframes[i].offset;
|
|
13348
13581
|
|
|
13349
|
-
if (offset
|
|
13582
|
+
if (!isNil(offset)) {
|
|
13350
13583
|
if (offset < previousOffset) {
|
|
13351
13584
|
throw new TypeError('Keyframes are not loosely sorted by offset. Sort or specify offsets.');
|
|
13352
13585
|
}
|
|
@@ -13377,15 +13610,15 @@ function normalizeKeyframes(effectInput, timing) {
|
|
|
13377
13610
|
var previousOffset = Number(keyframes[0].computedOffset);
|
|
13378
13611
|
|
|
13379
13612
|
for (var _i = 1; _i < length; _i++) {
|
|
13380
|
-
var _offset =
|
|
13613
|
+
var _offset = keyframes[_i].computedOffset;
|
|
13381
13614
|
|
|
13382
|
-
if (_offset
|
|
13615
|
+
if (!isNil(_offset) && !isNil(previousOffset)) {
|
|
13383
13616
|
for (var j = 1; j < _i - previousIndex; j++) {
|
|
13384
|
-
keyframes[previousIndex + j].computedOffset = previousOffset + (_offset - previousOffset) * j / (_i - previousIndex);
|
|
13617
|
+
keyframes[previousIndex + j].computedOffset = previousOffset + (Number(_offset) - previousOffset) * j / (_i - previousIndex);
|
|
13385
13618
|
}
|
|
13386
13619
|
|
|
13387
13620
|
previousIndex = _i;
|
|
13388
|
-
previousOffset = _offset;
|
|
13621
|
+
previousOffset = Number(_offset);
|
|
13389
13622
|
}
|
|
13390
13623
|
}
|
|
13391
13624
|
}
|
|
@@ -17911,143 +18144,6 @@ exports.PathUpdater = tslib.__decorate([manaSyringe.singleton({
|
|
|
17911
18144
|
named: exports.Shape.PATH
|
|
17912
18145
|
}
|
|
17913
18146
|
})], exports.PathUpdater);
|
|
17914
|
-
// let xArr = [];
|
|
17915
|
-
// let yArr = [];
|
|
17916
|
-
// const segmentsWithAngle = [];
|
|
17917
|
-
// for (let i = 0; i < segments.length; i++) {
|
|
17918
|
-
// const segment = segments[i];
|
|
17919
|
-
// const { currentPoint, params, prePoint } = segment;
|
|
17920
|
-
// let box;
|
|
17921
|
-
// switch (segment.command) {
|
|
17922
|
-
// case 'Q':
|
|
17923
|
-
// box = QuadUtil.box(prePoint[0], prePoint[1], params[1], params[2], params[3], params[4]);
|
|
17924
|
-
// break;
|
|
17925
|
-
// case 'C':
|
|
17926
|
-
// box = CubicUtil.box(
|
|
17927
|
-
// prePoint[0],
|
|
17928
|
-
// prePoint[1],
|
|
17929
|
-
// params[1],
|
|
17930
|
-
// params[2],
|
|
17931
|
-
// params[3],
|
|
17932
|
-
// params[4],
|
|
17933
|
-
// params[5],
|
|
17934
|
-
// params[6],
|
|
17935
|
-
// );
|
|
17936
|
-
// break;
|
|
17937
|
-
// case 'A':
|
|
17938
|
-
// // eslint-disable-next-line no-case-declarations
|
|
17939
|
-
// const { arcParams } = segment;
|
|
17940
|
-
// box = EllipseArcUtil.box(
|
|
17941
|
-
// arcParams.cx,
|
|
17942
|
-
// arcParams.cy,
|
|
17943
|
-
// arcParams.rx,
|
|
17944
|
-
// arcParams.ry,
|
|
17945
|
-
// arcParams.xRotation,
|
|
17946
|
-
// arcParams.startAngle,
|
|
17947
|
-
// arcParams.endAngle,
|
|
17948
|
-
// );
|
|
17949
|
-
// break;
|
|
17950
|
-
// default:
|
|
17951
|
-
// xArr.push(currentPoint[0]);
|
|
17952
|
-
// yArr.push(currentPoint[1]);
|
|
17953
|
-
// break;
|
|
17954
|
-
// }
|
|
17955
|
-
// if (box) {
|
|
17956
|
-
// segment.box = box;
|
|
17957
|
-
// xArr.push(box.x, box.x + box.width);
|
|
17958
|
-
// yArr.push(box.y, box.y + box.height);
|
|
17959
|
-
// }
|
|
17960
|
-
// if (
|
|
17961
|
-
// lineWidth &&
|
|
17962
|
-
// (segment.command === 'L' || segment.command === 'M') &&
|
|
17963
|
-
// segment.prePoint &&
|
|
17964
|
-
// segment.nextPoint
|
|
17965
|
-
// ) {
|
|
17966
|
-
// segmentsWithAngle.push(segment);
|
|
17967
|
-
// }
|
|
17968
|
-
// }
|
|
17969
|
-
// // bbox calculation should ignore NaN for path attribute
|
|
17970
|
-
// // ref: https://github.com/antvis/g/issues/210
|
|
17971
|
-
// xArr = xArr.filter((item) => !Number.isNaN(item));
|
|
17972
|
-
// yArr = yArr.filter((item) => !Number.isNaN(item));
|
|
17973
|
-
// let minX = min(xArr);
|
|
17974
|
-
// let minY = min(yArr);
|
|
17975
|
-
// let maxX = max(xArr);
|
|
17976
|
-
// let maxY = max(yArr);
|
|
17977
|
-
// if (segmentsWithAngle.length === 0) {
|
|
17978
|
-
// return {
|
|
17979
|
-
// x: minX,
|
|
17980
|
-
// y: minY,
|
|
17981
|
-
// width: maxX - minX,
|
|
17982
|
-
// height: maxY - minY,
|
|
17983
|
-
// };
|
|
17984
|
-
// }
|
|
17985
|
-
// for (let i = 0; i < segmentsWithAngle.length; i++) {
|
|
17986
|
-
// const segment = segmentsWithAngle[i];
|
|
17987
|
-
// const { currentPoint } = segment;
|
|
17988
|
-
// let extra;
|
|
17989
|
-
// if (currentPoint[0] === minX) {
|
|
17990
|
-
// extra = getExtraFromSegmentWithAngle(segment, lineWidth);
|
|
17991
|
-
// minX -= extra.xExtra;
|
|
17992
|
-
// } else if (currentPoint[0] === maxX) {
|
|
17993
|
-
// extra = getExtraFromSegmentWithAngle(segment, lineWidth);
|
|
17994
|
-
// maxX += extra.xExtra;
|
|
17995
|
-
// }
|
|
17996
|
-
// if (currentPoint[1] === minY) {
|
|
17997
|
-
// extra = getExtraFromSegmentWithAngle(segment, lineWidth);
|
|
17998
|
-
// minY -= extra.yExtra;
|
|
17999
|
-
// } else if (currentPoint[1] === maxY) {
|
|
18000
|
-
// extra = getExtraFromSegmentWithAngle(segment, lineWidth);
|
|
18001
|
-
// maxY += extra.yExtra;
|
|
18002
|
-
// }
|
|
18003
|
-
// }
|
|
18004
|
-
// return {
|
|
18005
|
-
// x: minX,
|
|
18006
|
-
// y: minY,
|
|
18007
|
-
// width: maxX - minX,
|
|
18008
|
-
// height: maxY - minY,
|
|
18009
|
-
// };
|
|
18010
|
-
// }
|
|
18011
|
-
// function getExtraFromSegmentWithAngle(segment: any, lineWidth: number) {
|
|
18012
|
-
// const { prePoint, currentPoint, nextPoint } = segment;
|
|
18013
|
-
// const currentAndPre =
|
|
18014
|
-
// Math.pow(currentPoint[0] - prePoint[0], 2) + Math.pow(currentPoint[1] - prePoint[1], 2);
|
|
18015
|
-
// const currentAndNext =
|
|
18016
|
-
// Math.pow(currentPoint[0] - nextPoint[0], 2) + Math.pow(currentPoint[1] - nextPoint[1], 2);
|
|
18017
|
-
// const preAndNext =
|
|
18018
|
-
// Math.pow(prePoint[0] - nextPoint[0], 2) + Math.pow(prePoint[1] - nextPoint[1], 2);
|
|
18019
|
-
// // 以 currentPoint 为顶点的夹角
|
|
18020
|
-
// const currentAngle = Math.acos(
|
|
18021
|
-
// (currentAndPre + currentAndNext - preAndNext) /
|
|
18022
|
-
// (2 * Math.sqrt(currentAndPre) * Math.sqrt(currentAndNext)),
|
|
18023
|
-
// );
|
|
18024
|
-
// // 夹角为空、 0 或 PI 时,不需要计算夹角处的额外宽度
|
|
18025
|
-
// // 注意: 由于计算精度问题,夹角为 0 的情况计算出来的角度可能是一个很小的值,还需要判断其与 0 是否近似相等
|
|
18026
|
-
// if (!currentAngle || Math.sin(currentAngle) === 0 || isNumberEqual(currentAngle, 0)) {
|
|
18027
|
-
// return {
|
|
18028
|
-
// xExtra: 0,
|
|
18029
|
-
// yExtra: 0,
|
|
18030
|
-
// };
|
|
18031
|
-
// }
|
|
18032
|
-
// let xAngle = Math.abs(Math.atan2(nextPoint[1] - currentPoint[1], nextPoint[0] - currentPoint[0]));
|
|
18033
|
-
// let yAngle = Math.abs(Math.atan2(nextPoint[0] - currentPoint[0], nextPoint[1] - currentPoint[1]));
|
|
18034
|
-
// // 将夹角转为锐角
|
|
18035
|
-
// xAngle = xAngle > Math.PI / 2 ? Math.PI - xAngle : xAngle;
|
|
18036
|
-
// yAngle = yAngle > Math.PI / 2 ? Math.PI - yAngle : yAngle;
|
|
18037
|
-
// // 这里不考虑在水平和垂直方向的投影,直接使用最大差值
|
|
18038
|
-
// // 由于上层统一加减了二分之一线宽,这里需要进行弥补
|
|
18039
|
-
// const extra = {
|
|
18040
|
-
// // 水平方向投影
|
|
18041
|
-
// xExtra:
|
|
18042
|
-
// Math.cos(currentAngle / 2 - xAngle) * ((lineWidth / 2) * (1 / Math.sin(currentAngle / 2))) -
|
|
18043
|
-
// lineWidth / 2 || 0,
|
|
18044
|
-
// // 垂直方向投影
|
|
18045
|
-
// yExtra:
|
|
18046
|
-
// Math.cos(yAngle - currentAngle / 2) * ((lineWidth / 2) * (1 / Math.sin(currentAngle / 2))) -
|
|
18047
|
-
// lineWidth / 2 || 0,
|
|
18048
|
-
// };
|
|
18049
|
-
// return extra;
|
|
18050
|
-
// }
|
|
18051
18147
|
|
|
18052
18148
|
/**
|
|
18053
18149
|
* @see /zh/docs/api/basic/display-object#clippath
|
|
@@ -18500,7 +18596,6 @@ exports.CSSPropertyPath = /*#__PURE__*/function () {
|
|
|
18500
18596
|
polylines: [],
|
|
18501
18597
|
curve: [],
|
|
18502
18598
|
totalLength: 0,
|
|
18503
|
-
curveSegments: [],
|
|
18504
18599
|
zCommandIndexes: [],
|
|
18505
18600
|
rect: new Rectangle(0, 0, 0, 0)
|
|
18506
18601
|
};
|
|
@@ -18841,28 +18936,6 @@ exports.CSSPropertyZIndex = tslib.__decorate([manaSyringe.singleton({
|
|
|
18841
18936
|
}
|
|
18842
18937
|
})], exports.CSSPropertyZIndex);
|
|
18843
18938
|
|
|
18844
|
-
// [PropertySyntax.COORDINATE]: CSSPropertyLocalPosition,
|
|
18845
|
-
// [PropertySyntax.ANGLE]: CSSPropertyAngle,
|
|
18846
|
-
// [PropertySyntax.COLOR]: CSSPropertyColor,
|
|
18847
|
-
// [PropertySyntax.PAINT]: CSSPropertyColor,
|
|
18848
|
-
// [PropertySyntax.OPACITY_VALUE]: CSSPropertyOpacity,
|
|
18849
|
-
// [PropertySyntax.LENGTH_PERCENTAGE]: CSSPropertyLengthOrPercentage,
|
|
18850
|
-
// [PropertySyntax.LENGTH_PERCENTAGE_12]: CSSPropertyLengthOrPercentage12,
|
|
18851
|
-
// [PropertySyntax.LENGTH_PERCENTAGE_14]: CSSPropertyLengthOrPercentage14,
|
|
18852
|
-
// [PropertySyntax.SHADOW_BLUR]: CSSPropertyShadowBlur,
|
|
18853
|
-
// [PropertySyntax.LIST_OF_POINTS]: CSSPropertyPoints,
|
|
18854
|
-
// [PropertySyntax.PATH]: CSSPropertyPath,
|
|
18855
|
-
// [PropertySyntax.FILTER]: CSSPropertyFilter,
|
|
18856
|
-
// [PropertySyntax.Z_INDEX]: CSSPropertyZIndex,
|
|
18857
|
-
// [PropertySyntax.OFFSET_PATH]: CSSPropertyOffsetPath,
|
|
18858
|
-
// [PropertySyntax.OFFSET_DISTANCE]: CSSPropertyOffsetDistance,
|
|
18859
|
-
// [PropertySyntax.CLIP_PATH]: CSSPropertyClipPath,
|
|
18860
|
-
// [PropertySyntax.TRANSFORM]: CSSPropertyTransform,
|
|
18861
|
-
// [PropertySyntax.TRANSFORM_ORIGIN]: CSSPropertyTransformOrigin,
|
|
18862
|
-
// [PropertySyntax.TEXT]: CSSPropertyText,
|
|
18863
|
-
// [PropertySyntax.TEXT_TRANSFORM]: CSSPropertyTextTransform,
|
|
18864
|
-
// };
|
|
18865
|
-
|
|
18866
18939
|
/**
|
|
18867
18940
|
* Blink used them in code generation(css_properties.json5)
|
|
18868
18941
|
*/
|
|
@@ -19628,10 +19701,14 @@ exports.DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
19628
19701
|
_geometryUpdater$upda4 = _geometryUpdater$upda.offsetY,
|
|
19629
19702
|
offsetY = _geometryUpdater$upda4 === void 0 ? 0 : _geometryUpdater$upda4,
|
|
19630
19703
|
_geometryUpdater$upda5 = _geometryUpdater$upda.offsetZ,
|
|
19631
|
-
offsetZ = _geometryUpdater$upda5 === void 0 ? 0 : _geometryUpdater$upda5; //
|
|
19704
|
+
offsetZ = _geometryUpdater$upda5 === void 0 ? 0 : _geometryUpdater$upda5; // account for negative width / height of Rect
|
|
19705
|
+
// @see https://github.com/antvis/g/issues/957
|
|
19706
|
+
|
|
19632
19707
|
|
|
19708
|
+
var flipY = width < 0;
|
|
19709
|
+
var flipX = height < 0; // init with content box
|
|
19633
19710
|
|
|
19634
|
-
var halfExtents = glMatrix.vec3.fromValues(width / 2, height / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
|
|
19711
|
+
var halfExtents = glMatrix.vec3.fromValues(Math.abs(width) / 2, Math.abs(height) / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
|
|
19635
19712
|
|
|
19636
19713
|
var lineWidth = parsedStyle.lineWidth,
|
|
19637
19714
|
increasedLineWidthForHitTesting = parsedStyle.increasedLineWidthForHitTesting,
|
|
@@ -19645,10 +19722,18 @@ exports.DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
19645
19722
|
delete parsedStyle.anchor;
|
|
19646
19723
|
}
|
|
19647
19724
|
|
|
19648
|
-
var center = glMatrix.vec3.fromValues((1 - (anchor && anchor[0].value || 0) * 2) *
|
|
19725
|
+
var center = glMatrix.vec3.fromValues((1 - (anchor && anchor[0].value || 0) * 2) * width / 2 + offsetX, (1 - (anchor && anchor[1].value || 0) * 2) * height / 2 + offsetY, (1 - (anchor && ((_anchor$ = anchor[2]) === null || _anchor$ === void 0 ? void 0 : _anchor$.value) || 0) * 2) * halfExtents[2] + offsetZ); // update geometry's AABB
|
|
19726
|
+
|
|
19727
|
+
geometry.contentBounds.update(center, halfExtents); // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
|
|
19728
|
+
|
|
19729
|
+
var expansion = object.nodeName === exports.Shape.POLYLINE || object.nodeName === exports.Shape.POLYGON || object.nodeName === exports.Shape.PATH ? Math.SQRT2 : 0.5; // if (lineCap?.value === 'square') {
|
|
19730
|
+
// expansion = Math.SQRT1_2;
|
|
19731
|
+
// }
|
|
19732
|
+
// if (lineJoin?.value === 'miter' && expansion < Math.SQRT2 * miterLimit) {
|
|
19733
|
+
// expansion = Math.SQRT1_2 * miterLimit;
|
|
19734
|
+
// }
|
|
19649
19735
|
|
|
19650
|
-
|
|
19651
|
-
var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2; // append border
|
|
19736
|
+
var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) * expansion; // append border
|
|
19652
19737
|
|
|
19653
19738
|
glMatrix.vec3.add(halfExtents, halfExtents, glMatrix.vec3.fromValues(halfLineWidth, halfLineWidth, 0));
|
|
19654
19739
|
geometry.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
|
|
@@ -19707,10 +19792,10 @@ exports.DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
19707
19792
|
});
|
|
19708
19793
|
anchor = parsedStyle.anchor; // set transform origin
|
|
19709
19794
|
|
|
19710
|
-
var usedOriginXValue = convertPercentUnit(transformOrigin[0], 0, object);
|
|
19711
|
-
var usedOriginYValue = convertPercentUnit(transformOrigin[1], 1, object);
|
|
19712
|
-
usedOriginXValue
|
|
19713
|
-
usedOriginYValue
|
|
19795
|
+
var usedOriginXValue = (flipY ? -1 : 1) * convertPercentUnit(transformOrigin[0], 0, object);
|
|
19796
|
+
var usedOriginYValue = (flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
|
|
19797
|
+
usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0].value || 0) * geometry.contentBounds.halfExtents[0] * 2;
|
|
19798
|
+
usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1].value || 0) * geometry.contentBounds.halfExtents[1] * 2;
|
|
19714
19799
|
object.setOrigin(usedOriginXValue, usedOriginYValue);
|
|
19715
19800
|
object.dispatchEvent(new CustomEvent(exports.ElementEvent.GEOMETRY_BOUNDS_CHANGED));
|
|
19716
19801
|
dirtifyToRoot(object);
|
|
@@ -21269,7 +21354,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
21269
21354
|
}
|
|
21270
21355
|
});
|
|
21271
21356
|
} else {
|
|
21272
|
-
console.
|
|
21357
|
+
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);
|
|
21273
21358
|
}
|
|
21274
21359
|
};
|
|
21275
21360
|
|
|
@@ -21469,8 +21554,10 @@ exports.camelCase = camelCase;
|
|
|
21469
21554
|
exports.clamp = clamp;
|
|
21470
21555
|
exports.clampedMergeNumbers = clampedMergeNumbers;
|
|
21471
21556
|
exports.cleanExistedCanvas = cleanExistedCanvas;
|
|
21472
|
-
exports.
|
|
21557
|
+
exports.colorStopToString = colorStopToString;
|
|
21473
21558
|
exports.compareAnimations = compareAnimations;
|
|
21559
|
+
exports.computeLinearGradient = computeLinearGradient;
|
|
21560
|
+
exports.computeRadialGradient = computeRadialGradient;
|
|
21474
21561
|
exports.convertAngleUnit = convertAngleUnit;
|
|
21475
21562
|
exports.convertEffectInput = convertEffectInput;
|
|
21476
21563
|
exports.convertPercentUnit = convertPercentUnit;
|
|
@@ -21482,22 +21569,20 @@ exports.deg2rad = deg2rad;
|
|
|
21482
21569
|
exports.deg2turn = deg2turn;
|
|
21483
21570
|
exports.dirtifyToRoot = dirtifyToRoot;
|
|
21484
21571
|
exports.equalSet = equalSet;
|
|
21485
|
-
exports.
|
|
21572
|
+
exports.extractPolygons = extractPolygons;
|
|
21486
21573
|
exports.formatAttribute = formatAttribute;
|
|
21487
21574
|
exports.fromRotationTranslationScale = fromRotationTranslationScale;
|
|
21488
21575
|
exports.getAngle = getAngle;
|
|
21489
|
-
exports.getDrawDirection = getDrawDirection;
|
|
21490
21576
|
exports.getEasingFunction = getEasingFunction;
|
|
21491
21577
|
exports.getEuler = getEuler;
|
|
21492
21578
|
exports.getHeight = getHeight;
|
|
21493
|
-
exports.getPathArea = getPathArea;
|
|
21494
|
-
exports.getRotatedCurve = getRotatedCurve;
|
|
21495
21579
|
exports.getRotationInRadians = getRotationInRadians;
|
|
21496
21580
|
exports.getScaling = getScaling;
|
|
21497
21581
|
exports.getStyle = getStyle;
|
|
21498
21582
|
exports.getTranslation = getTranslation;
|
|
21499
21583
|
exports.getWidth = getWidth;
|
|
21500
21584
|
exports.grad2deg = grad2deg;
|
|
21585
|
+
exports.hasArcOrBezier = hasArcOrBezier;
|
|
21501
21586
|
exports.isBoolean = isBoolean;
|
|
21502
21587
|
exports.isBrowser = isBrowser;
|
|
21503
21588
|
exports.isComparison = isComparison;
|
|
@@ -21505,6 +21590,7 @@ exports.isFunction = isFunction;
|
|
|
21505
21590
|
exports.isNil = isNil;
|
|
21506
21591
|
exports.isNumber = isNumber;
|
|
21507
21592
|
exports.isObject = isObject;
|
|
21593
|
+
exports.isPattern = isPattern;
|
|
21508
21594
|
exports.isString = isString;
|
|
21509
21595
|
exports.isUndefined = isUndefined;
|
|
21510
21596
|
exports.layoutEngine = layoutEngine;
|
|
@@ -21527,6 +21613,7 @@ exports.parseColor = parseColor;
|
|
|
21527
21613
|
exports.parseDimension = parseDimension;
|
|
21528
21614
|
exports.parseDimensionArray = parseDimensionArray;
|
|
21529
21615
|
exports.parseFilter = parseFilter;
|
|
21616
|
+
exports.parseGradient = parseGradient;
|
|
21530
21617
|
exports.parseLength = parseLength;
|
|
21531
21618
|
exports.parseLengthOrPercentage = parseLengthOrPercentage;
|
|
21532
21619
|
exports.parseNumber = parseNumber;
|
|
@@ -21537,8 +21624,8 @@ exports.parsePoints = parsePoints;
|
|
|
21537
21624
|
exports.parseTransform = parseTransform;
|
|
21538
21625
|
exports.parseTransformOrigin = parseTransformOrigin;
|
|
21539
21626
|
exports.parserPercentage = parserPercentage;
|
|
21627
|
+
exports.path2Segments = path2Segments;
|
|
21540
21628
|
exports.rad2deg = rad2deg;
|
|
21541
|
-
exports.reverseCurve = reverseCurve;
|
|
21542
21629
|
exports.setDOMSize = setDOMSize;
|
|
21543
21630
|
exports.sortByZIndex = sortByZIndex;
|
|
21544
21631
|
exports.toFontString = toFontString;
|