@antv/g 5.4.0 → 5.5.0

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/index.umd.js CHANGED
@@ -4723,6 +4723,17 @@
4723
4723
  PERFORMANCE OF THIS SOFTWARE.
4724
4724
  ***************************************************************************** */
4725
4725
 
4726
+ var __assign = function() {
4727
+ __assign = Object.assign || function __assign(t) {
4728
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4729
+ s = arguments[i];
4730
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
4731
+ }
4732
+ return t;
4733
+ };
4734
+ return __assign.apply(this, arguments);
4735
+ };
4736
+
4726
4737
  function __decorate(decorators, target, key, desc) {
4727
4738
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4728
4739
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4736,6 +4747,16 @@
4736
4747
 
4737
4748
  function __metadata(metadataKey, metadataValue) {
4738
4749
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
4750
+ }
4751
+
4752
+ function __spreadArray(to, from, pack) {
4753
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4754
+ if (ar || !(i in from)) {
4755
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4756
+ ar[i] = from[i];
4757
+ }
4758
+ }
4759
+ return to.concat(ar || Array.prototype.slice.call(from));
4739
4760
  }
4740
4761
 
4741
4762
  function _regeneratorRuntime() {
@@ -7567,6 +7588,33 @@
7567
7588
 
7568
7589
  return out;
7569
7590
  }
7591
+ /**
7592
+ * Creates a new vec2 initialized with the given values
7593
+ *
7594
+ * @param {Number} x X component
7595
+ * @param {Number} y Y component
7596
+ * @returns {vec2} a new 2D vector
7597
+ */
7598
+
7599
+ function fromValues$4(x, y) {
7600
+ var out = new ARRAY_TYPE(2);
7601
+ out[0] = x;
7602
+ out[1] = y;
7603
+ return out;
7604
+ }
7605
+ /**
7606
+ * Copy the values from one vec2 to another
7607
+ *
7608
+ * @param {vec2} out the receiving vector
7609
+ * @param {ReadonlyVec2} a the source vector
7610
+ * @returns {vec2} out
7611
+ */
7612
+
7613
+ function copy$4(out, a) {
7614
+ out[0] = a[0];
7615
+ out[1] = a[1];
7616
+ return out;
7617
+ }
7570
7618
  /**
7571
7619
  * Normalize a vec2
7572
7620
  *
@@ -7897,7 +7945,7 @@
7897
7945
  return "-" + letter.toLowerCase();
7898
7946
  }); // Remove first dash
7899
7947
 
7900
- return str.charAt(0) === '-' ? str.substr(1) : str;
7948
+ return str.charAt(0) === '-' ? str.substring(1) : str;
7901
7949
  };
7902
7950
  /**
7903
7951
  Easing Functions from anime.js, they are tried and true, so, its better to use them instead of other alternatives
@@ -8990,20 +9038,45 @@
8990
9038
  return timing.easingFunction(directedProgress);
8991
9039
  }
8992
9040
 
8993
- var cache = {};
8994
- function camelCase(str) {
8995
- if (str === void 0) {
8996
- str = '';
9041
+ /**
9042
+ * @see https://github.com/lodash/lodash/blob/master/memoize.js
9043
+ */
9044
+ function memoize(func, resolver) {
9045
+ if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
9046
+ throw new TypeError('Expected a function');
8997
9047
  }
8998
9048
 
8999
- if (!cache[str]) {
9000
- cache[str] = str.replace(/-([a-z])/g, function (g) {
9001
- return g[1].toUpperCase();
9002
- });
9003
- }
9049
+ var memoized = function memoized() {
9050
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9051
+ args[_key] = arguments[_key];
9052
+ }
9004
9053
 
9005
- return cache[str];
9054
+ var key = resolver ? resolver.apply(this, args) : args[0];
9055
+ var cache = memoized.cache;
9056
+
9057
+ if (cache.has(key)) {
9058
+ return cache.get(key);
9059
+ }
9060
+
9061
+ var result = func.apply(this, args);
9062
+ memoized.cache = cache.set(key, result) || cache;
9063
+ return result;
9064
+ };
9065
+
9066
+ memoized.cache = new (memoize.Cache || Map)();
9067
+ return memoized;
9006
9068
  }
9069
+ memoize.Cache = Map;
9070
+
9071
+ var camelCase = memoize(function (str) {
9072
+ if (str === void 0) {
9073
+ str = '';
9074
+ }
9075
+
9076
+ return str.replace(/-([a-z])/g, function (g) {
9077
+ return g[1].toUpperCase();
9078
+ });
9079
+ });
9007
9080
  function isString(str) {
9008
9081
  if (!isNil(str) && typeof str === 'string') {
9009
9082
  return true;
@@ -9209,45 +9282,33 @@
9209
9282
  alias: 'img'
9210
9283
  }
9211
9284
  };
9212
- function formatAttribute(name, value) {
9213
- var _map$values;
9214
-
9285
+ var formatAttributeName = memoize(function (name) {
9215
9286
  var attributeName = camelCase(name);
9216
9287
  var map = FORMAT_ATTR_MAP[attributeName];
9217
9288
  attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
9218
- var attributeValue = (map === null || map === void 0 ? void 0 : (_map$values = map.values) === null || _map$values === void 0 ? void 0 : _map$values[value]) || value;
9219
- return [attributeName, attributeValue];
9220
- }
9221
-
9222
- /**
9223
- * @see https://github.com/lodash/lodash/blob/master/memoize.js
9224
- */
9225
- function memoize(func, resolver) {
9226
- if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
9227
- throw new TypeError('Expected a function');
9228
- }
9229
-
9230
- var memoized = function memoized() {
9231
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9232
- args[_key] = arguments[_key];
9233
- }
9234
-
9235
- var key = resolver ? resolver.apply(this, args) : args[0];
9236
- var cache = memoized.cache;
9237
-
9238
- if (cache.has(key)) {
9239
- return cache.get(key);
9240
- }
9289
+ return [attributeName, map];
9290
+ });
9291
+ function formatAttribute(name, value) {
9292
+ var _map$values;
9241
9293
 
9242
- var result = func.apply(this, args);
9243
- memoized.cache = cache.set(key, result) || cache;
9244
- return result;
9245
- };
9294
+ var _formatAttributeName = formatAttributeName(name),
9295
+ attributeName = _formatAttributeName[0],
9296
+ map = _formatAttributeName[1];
9246
9297
 
9247
- memoized.cache = new (memoize.Cache || Map)();
9248
- return memoized;
9249
- }
9250
- memoize.Cache = Map;
9298
+ var attributeValue = isString(value) && (map === null || map === void 0 ? void 0 : (_map$values = map.values) === null || _map$values === void 0 ? void 0 : _map$values[value]) || value;
9299
+ return [attributeName, attributeValue];
9300
+ } // export const formatAttribute = memoize(
9301
+ // (name: string, value: any): [string, any] => {
9302
+ // let attributeName = camelCase(name);
9303
+ // const map = FORMAT_ATTR_MAP[attributeName];
9304
+ // attributeName = map?.alias || attributeName;
9305
+ // const attributeValue = map?.values?.[value] || value;
9306
+ // return [attributeName, attributeValue];
9307
+ // },
9308
+ // (name: string, value: any) => {
9309
+ // return `${name}${value}`;
9310
+ // },
9311
+ // );
9251
9312
 
9252
9313
  (function (Shape) {
9253
9314
  Shape["GROUP"] = "g";
@@ -15543,10 +15604,40 @@
15543
15604
  }
15544
15605
 
15545
15606
  function clonePath(path) {
15546
- return path.map((x) => (Array.isArray(x) ? [...x] : x));
15607
+ return path.map(function (x) { return (Array.isArray(x) ? __spreadArray([], x, true) : x); });
15547
15608
  }
15548
15609
 
15549
- const paramsParser = {
15610
+ /**
15611
+ * Rounds the values of a `PathArray` instance to
15612
+ * a specified amount of decimals and returns it.
15613
+ */
15614
+ function roundPath(path, round) {
15615
+ if (round === 'off')
15616
+ return clonePath(path);
15617
+ // to round values to the power
15618
+ // the `round` value must be integer
15619
+ var pow = typeof round === 'number' && round >= 1 ? Math.pow(10, round) : 1;
15620
+ return path.map(function (pi) {
15621
+ var values = pi
15622
+ .slice(1)
15623
+ .map(Number)
15624
+ .map(function (n) { return (round ? Math.round(n * pow) / pow : Math.round(n)); });
15625
+ return __spreadArray([pi[0]], values, true);
15626
+ });
15627
+ }
15628
+
15629
+ /**
15630
+ * Returns a valid `d` attribute string value created
15631
+ * by rounding values and concatenating the `pathArray` segments.
15632
+ */
15633
+ function path2String(path, round) {
15634
+ if (round === void 0) { round = 'off'; }
15635
+ return roundPath(path, round)
15636
+ .map(function (x) { return x[0] + x.slice(1).join(' '); })
15637
+ .join('');
15638
+ }
15639
+
15640
+ var paramsParser = {
15550
15641
  x1: 0,
15551
15642
  y1: 0,
15552
15643
  x2: 0,
@@ -15560,9 +15651,9 @@
15560
15651
  function fixArc(pathArray, allPathCommands, i) {
15561
15652
  if (pathArray[i].length > 7) {
15562
15653
  pathArray[i].shift();
15563
- const pi = pathArray[i];
15654
+ var pi = pathArray[i];
15564
15655
  // const ni = i + 1;
15565
- let ni = i;
15656
+ var ni = i;
15566
15657
  while (pi.length) {
15567
15658
  // if created multiple C:s, their original seg is saved
15568
15659
  allPathCommands[i] = 'A';
@@ -15573,7 +15664,7 @@
15573
15664
  }
15574
15665
  }
15575
15666
 
15576
- const paramsCount = {
15667
+ var paramsCount = {
15577
15668
  a: 7,
15578
15669
  c: 6,
15579
15670
  h: 1,
@@ -15592,8 +15683,8 @@
15592
15683
  */
15593
15684
  function isPathArray(path) {
15594
15685
  return (Array.isArray(path) &&
15595
- path.every((seg) => {
15596
- const lk = seg[0].toLowerCase();
15686
+ path.every(function (seg) {
15687
+ var lk = seg[0].toLowerCase();
15597
15688
  return paramsCount[lk] === seg.length - 1 && 'achlmqstvz'.includes(lk);
15598
15689
  }));
15599
15690
  }
@@ -15605,7 +15696,10 @@
15605
15696
  function isAbsoluteArray(path) {
15606
15697
  return (isPathArray(path) &&
15607
15698
  // @ts-ignore -- `isPathArray` also checks if it's `Array`
15608
- path.every(([x]) => x === x.toUpperCase()));
15699
+ path.every(function (_a) {
15700
+ var x = _a[0];
15701
+ return x === x.toUpperCase();
15702
+ }));
15609
15703
  }
15610
15704
 
15611
15705
  /**
@@ -15614,28 +15708,31 @@
15614
15708
  * with absolute values.
15615
15709
  */
15616
15710
  function isNormalizedArray(path) {
15617
- return isAbsoluteArray(path) && path.every(([pc]) => 'ACLMQZ'.includes(pc));
15711
+ return isAbsoluteArray(path) && path.every(function (_a) {
15712
+ var pc = _a[0];
15713
+ return 'ACLMQZ'.includes(pc);
15714
+ });
15618
15715
  }
15619
15716
 
15620
15717
  /**
15621
15718
  * Breaks the parsing of a pathString once a segment is finalized.
15622
15719
  */
15623
15720
  function finalizeSegment(path) {
15624
- let pathCommand = path.pathValue[path.segmentStart];
15625
- let LK = pathCommand.toLowerCase();
15626
- const { data } = path;
15721
+ var pathCommand = path.pathValue[path.segmentStart];
15722
+ var LK = pathCommand.toLowerCase();
15723
+ var data = path.data;
15627
15724
  while (data.length >= paramsCount[LK]) {
15628
15725
  // overloaded `moveTo`
15629
15726
  // https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts
15630
15727
  if (LK === 'm' && data.length > 2) {
15631
15728
  // @ts-ignore
15632
- path.segments.push([pathCommand, ...data.splice(0, 2)]);
15729
+ path.segments.push(__spreadArray([pathCommand], data.splice(0, 2), true));
15633
15730
  LK = 'l';
15634
15731
  pathCommand = pathCommand === 'm' ? 'l' : 'L';
15635
15732
  }
15636
15733
  else {
15637
15734
  // @ts-ignore
15638
- path.segments.push([pathCommand, ...data.splice(0, paramsCount[LK])]);
15735
+ path.segments.push(__spreadArray([pathCommand], data.splice(0, paramsCount[LK]), true));
15639
15736
  }
15640
15737
  if (!paramsCount[LK]) {
15641
15738
  break;
@@ -15648,8 +15745,8 @@
15648
15745
  * Usually a `large-arc-flag` or `sweep-flag`.
15649
15746
  */
15650
15747
  function scanFlag(path) {
15651
- const { index, pathValue } = path;
15652
- const code = pathValue.charCodeAt(index);
15748
+ var index = path.index, pathValue = path.pathValue;
15749
+ var code = pathValue.charCodeAt(index);
15653
15750
  if (code === 0x30 /* 0 */) {
15654
15751
  path.param = 0;
15655
15752
  path.index += 1;
@@ -15660,7 +15757,7 @@
15660
15757
  path.index += 1;
15661
15758
  return;
15662
15759
  }
15663
- path.err = `[path-util]: invalid Arc flag "${pathValue[index]}", expecting 0 or 1 at index ${index}`;
15760
+ path.err = "[path-util]: invalid Arc flag \"" + pathValue[index] + "\", expecting 0 or 1 at index " + index;
15664
15761
  }
15665
15762
 
15666
15763
  /**
@@ -15679,16 +15776,16 @@
15679
15776
  * every path command, negative numbers or floating point numbers.
15680
15777
  */
15681
15778
  function scanParam(path) {
15682
- const { max, pathValue, index: start } = path;
15683
- let index = start;
15684
- let zeroFirst = false;
15685
- let hasCeiling = false;
15686
- let hasDecimal = false;
15687
- let hasDot = false;
15688
- let ch;
15779
+ var max = path.max, pathValue = path.pathValue, start = path.index;
15780
+ var index = start;
15781
+ var zeroFirst = false;
15782
+ var hasCeiling = false;
15783
+ var hasDecimal = false;
15784
+ var hasDot = false;
15785
+ var ch;
15689
15786
  if (index >= max) {
15690
15787
  // path.err = 'SvgPath: missed param (at pos ' + index + ')';
15691
- path.err = `[path-util]: Invalid path value at index ${index}, "pathValue" is missing param`;
15788
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"pathValue\" is missing param";
15692
15789
  return;
15693
15790
  }
15694
15791
  ch = pathValue.charCodeAt(index);
@@ -15701,7 +15798,7 @@
15701
15798
  // https://github.com/ariya/esprimas
15702
15799
  if (!isDigit(ch) && ch !== 0x2e /* . */) {
15703
15800
  // path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
15704
- path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" is not a number`;
15801
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" is not a number";
15705
15802
  return;
15706
15803
  }
15707
15804
  if (ch !== 0x2e /* . */) {
@@ -15713,7 +15810,7 @@
15713
15810
  if (ch && isDigit(ch)) {
15714
15811
  // path.err = 'SvgPath: numbers started with `0` such as `09`
15715
15812
  // are illegal (at pos ' + start + ')';
15716
- path.err = `[path-util]: Invalid path value at index ${start}, "${pathValue[start]}" illegal number`;
15813
+ path.err = "[path-util]: Invalid path value at index " + start + ", \"" + pathValue[start] + "\" illegal number";
15717
15814
  return;
15718
15815
  }
15719
15816
  }
@@ -15734,7 +15831,7 @@
15734
15831
  }
15735
15832
  if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {
15736
15833
  if (hasDot && !hasCeiling && !hasDecimal) {
15737
- path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" invalid float exponent`;
15834
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" invalid float exponent";
15738
15835
  return;
15739
15836
  }
15740
15837
  index += 1;
@@ -15748,7 +15845,7 @@
15748
15845
  }
15749
15846
  }
15750
15847
  else {
15751
- path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" invalid integer exponent`;
15848
+ path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" invalid integer exponent";
15752
15849
  return;
15753
15850
  }
15754
15851
  }
@@ -15760,7 +15857,7 @@
15760
15857
  * Checks if the character is a space.
15761
15858
  */
15762
15859
  function isSpace(ch) {
15763
- const specialSpaces = [
15860
+ var specialSpaces = [
15764
15861
  0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f,
15765
15862
  0x205f, 0x3000, 0xfeff,
15766
15863
  ];
@@ -15784,7 +15881,7 @@
15784
15881
  * space character.
15785
15882
  */
15786
15883
  function skipSpaces(path) {
15787
- const { pathValue, max } = path;
15884
+ var pathValue = path.pathValue, max = path.max;
15788
15885
  while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {
15789
15886
  path.index += 1;
15790
15887
  }
@@ -15825,12 +15922,12 @@
15825
15922
  * where a segment starts and where it ends.
15826
15923
  */
15827
15924
  function scanSegment(path) {
15828
- const { max, pathValue, index } = path;
15829
- const cmdCode = pathValue.charCodeAt(index);
15830
- const reqParams = paramsCount[pathValue[index].toLowerCase()];
15925
+ var max = path.max, pathValue = path.pathValue, index = path.index;
15926
+ var cmdCode = pathValue.charCodeAt(index);
15927
+ var reqParams = paramsCount[pathValue[index].toLowerCase()];
15831
15928
  path.segmentStart = index;
15832
15929
  if (!isPathCommand(cmdCode)) {
15833
- path.err = `[path-util]: Invalid path value "${pathValue[index]}" is not a path command`;
15930
+ path.err = "[path-util]: Invalid path value \"" + pathValue[index] + "\" is not a path command";
15834
15931
  return;
15835
15932
  }
15836
15933
  path.index += 1;
@@ -15842,7 +15939,7 @@
15842
15939
  return;
15843
15940
  }
15844
15941
  for (;;) {
15845
- for (let i = reqParams; i > 0; i -= 1) {
15942
+ for (var i = reqParams; i > 0; i -= 1) {
15846
15943
  if (isArcCommand(cmdCode) && (i === 3 || i === 4))
15847
15944
  scanFlag(path);
15848
15945
  else
@@ -15873,8 +15970,8 @@
15873
15970
  * The `PathParser` is used by the `parsePathString` static method
15874
15971
  * to generate a `pathArray`.
15875
15972
  */
15876
- class PathParser {
15877
- constructor(pathString) {
15973
+ var PathParser = /** @class */ (function () {
15974
+ function PathParser(pathString) {
15878
15975
  this.pathValue = pathString;
15879
15976
  // @ts-ignore
15880
15977
  this.segments = [];
@@ -15885,7 +15982,8 @@
15885
15982
  this.data = [];
15886
15983
  this.err = '';
15887
15984
  }
15888
- }
15985
+ return PathParser;
15986
+ }());
15889
15987
 
15890
15988
  /**
15891
15989
  * Parses a path string value and returns an array
@@ -15895,7 +15993,7 @@
15895
15993
  if (isPathArray(pathInput)) {
15896
15994
  return clonePath(pathInput);
15897
15995
  }
15898
- const path = new PathParser(pathInput);
15996
+ var path = new PathParser(pathInput);
15899
15997
  skipSpaces(path);
15900
15998
  while (path.index < path.max && !path.err.length) {
15901
15999
  scanSegment(path);
@@ -15907,26 +16005,26 @@
15907
16005
  if (isAbsoluteArray(pathInput)) {
15908
16006
  return clonePath(pathInput);
15909
16007
  }
15910
- const path = parsePathString(pathInput);
16008
+ var path = parsePathString(pathInput);
15911
16009
  // if (!path || !path.length) {
15912
16010
  // return [['M', 0, 0]];
15913
16011
  // }
15914
- let x = 0;
15915
- let y = 0;
15916
- let mx = 0;
15917
- let my = 0;
16012
+ var x = 0;
16013
+ var y = 0;
16014
+ var mx = 0;
16015
+ var my = 0;
15918
16016
  // @ts-ignore
15919
- return path.map((segment) => {
15920
- const values = segment.slice(1).map(Number);
15921
- const [pathCommand] = segment;
15922
- const absCommand = pathCommand.toUpperCase();
16017
+ return path.map(function (segment) {
16018
+ var values = segment.slice(1).map(Number);
16019
+ var pathCommand = segment[0];
16020
+ var absCommand = pathCommand.toUpperCase();
15923
16021
  if (pathCommand === 'M') {
15924
- [x, y] = values;
16022
+ x = values[0], y = values[1];
15925
16023
  mx = x;
15926
16024
  my = y;
15927
16025
  return ['M', x, y];
15928
16026
  }
15929
- let absoluteSegment;
16027
+ var absoluteSegment;
15930
16028
  if (pathCommand !== absCommand) {
15931
16029
  switch (absCommand) {
15932
16030
  case 'A':
@@ -15950,26 +16048,26 @@
15950
16048
  default: {
15951
16049
  // use brakets for `eslint: no-case-declaration`
15952
16050
  // https://stackoverflow.com/a/50753272/803358
15953
- const absValues = values.map((n, j) => n + (j % 2 ? y : x));
16051
+ var absValues = values.map(function (n, j) { return n + (j % 2 ? y : x); });
15954
16052
  // for n, l, c, s, q, t
15955
- absoluteSegment = [absCommand, ...absValues];
16053
+ absoluteSegment = __spreadArray([absCommand], absValues, true);
15956
16054
  }
15957
16055
  }
15958
16056
  }
15959
16057
  else {
15960
- absoluteSegment = [absCommand, ...values];
16058
+ absoluteSegment = __spreadArray([absCommand], values, true);
15961
16059
  }
15962
- const segLength = absoluteSegment.length;
16060
+ var segLength = absoluteSegment.length;
15963
16061
  switch (absCommand) {
15964
16062
  case 'Z':
15965
16063
  x = mx;
15966
16064
  y = my;
15967
16065
  break;
15968
16066
  case 'H':
15969
- [, x] = absoluteSegment;
16067
+ x = absoluteSegment[1];
15970
16068
  break;
15971
16069
  case 'V':
15972
- [, y] = absoluteSegment;
16070
+ y = absoluteSegment[1];
15973
16071
  break;
15974
16072
  default:
15975
16073
  x = absoluteSegment[segLength - 2];
@@ -15988,10 +16086,10 @@
15988
16086
  * eg. H/V -> L, T -> Q
15989
16087
  */
15990
16088
  function normalizeSegment(segment, params) {
15991
- const [pathCommand] = segment;
15992
- const { x1: px1, y1: py1, x2: px2, y2: py2 } = params;
15993
- const values = segment.slice(1).map(Number);
15994
- let result = segment;
16089
+ var pathCommand = segment[0];
16090
+ var px1 = params.x1, py1 = params.y1, px2 = params.x2, py2 = params.y2;
16091
+ var values = segment.slice(1).map(Number);
16092
+ var result = segment;
15995
16093
  if (!'TQ'.includes(pathCommand)) {
15996
16094
  // optional but good to be cautious
15997
16095
  params.qx = null;
@@ -16004,21 +16102,21 @@
16004
16102
  result = ['L', px1, segment[1]];
16005
16103
  }
16006
16104
  else if (pathCommand === 'S') {
16007
- const x1 = px1 * 2 - px2;
16008
- const y1 = py1 * 2 - py2;
16105
+ var x1 = px1 * 2 - px2;
16106
+ var y1 = py1 * 2 - py2;
16009
16107
  params.x1 = x1;
16010
16108
  params.y1 = y1;
16011
- result = ['C', x1, y1, ...values];
16109
+ result = __spreadArray(['C', x1, y1], values, true);
16012
16110
  }
16013
16111
  else if (pathCommand === 'T') {
16014
- const qx = px1 * 2 - params.qx;
16015
- const qy = py1 * 2 - params.qy;
16112
+ var qx = px1 * 2 - params.qx;
16113
+ var qy = py1 * 2 - params.qy;
16016
16114
  params.qx = qx;
16017
16115
  params.qy = qy;
16018
- result = ['Q', qx, qy, ...values];
16116
+ result = __spreadArray(['Q', qx, qy], values, true);
16019
16117
  }
16020
16118
  else if (pathCommand === 'Q') {
16021
- const [nqx, nqy] = values;
16119
+ var nqx = values[0], nqy = values[1];
16022
16120
  params.qx = nqx;
16023
16121
  params.qy = nqy;
16024
16122
  }
@@ -16035,18 +16133,18 @@
16035
16133
  if (isNormalizedArray(pathInput)) {
16036
16134
  return clonePath(pathInput);
16037
16135
  }
16038
- const path = path2Absolute(pathInput);
16039
- const params = Object.assign({}, paramsParser);
16040
- const allPathCommands = [];
16041
- const ii = path.length;
16042
- let pathCommand = '';
16043
- for (let i = 0; i < ii; i += 1) {
16044
- [pathCommand] = path[i];
16136
+ var path = path2Absolute(pathInput);
16137
+ var params = __assign({}, paramsParser);
16138
+ var allPathCommands = [];
16139
+ var ii = path.length;
16140
+ var pathCommand = '';
16141
+ for (var i = 0; i < ii; i += 1) {
16142
+ pathCommand = path[i][0];
16045
16143
  // Save current path command
16046
16144
  allPathCommands[i] = pathCommand;
16047
16145
  path[i] = normalizeSegment(path[i], params);
16048
- const segment = path[i];
16049
- const seglen = segment.length;
16146
+ var segment = path[i];
16147
+ var seglen = segment.length;
16050
16148
  params.x1 = +segment[seglen - 2];
16051
16149
  params.y1 = +segment[seglen - 1];
16052
16150
  params.x2 = +segment[seglen - 4] || params.x1;
@@ -16063,12 +16161,15 @@
16063
16161
  * @returns {boolean} iteration result
16064
16162
  */
16065
16163
  function isCurveArray(path) {
16066
- return isNormalizedArray(path) && path.every(([pc]) => 'MC'.includes(pc));
16164
+ return isNormalizedArray(path) && path.every(function (_a) {
16165
+ var pc = _a[0];
16166
+ return 'MC'.includes(pc);
16167
+ });
16067
16168
  }
16068
16169
 
16069
16170
  function rotateVector(x, y, rad) {
16070
- const X = x * Math.cos(rad) - y * Math.sin(rad);
16071
- const Y = x * Math.sin(rad) + y * Math.cos(rad);
16171
+ var X = x * Math.cos(rad) - y * Math.sin(rad);
16172
+ var Y = x * Math.sin(rad) + y * Math.cos(rad);
16072
16173
  return { x: X, y: Y };
16073
16174
  }
16074
16175
 
@@ -16079,23 +16180,23 @@
16079
16180
  * http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
16080
16181
  */
16081
16182
  function arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, recursive) {
16082
- let x1 = X1;
16083
- let y1 = Y1;
16084
- let rx = RX;
16085
- let ry = RY;
16086
- let x2 = X2;
16087
- let y2 = Y2;
16183
+ var x1 = X1;
16184
+ var y1 = Y1;
16185
+ var rx = RX;
16186
+ var ry = RY;
16187
+ var x2 = X2;
16188
+ var y2 = Y2;
16088
16189
  // for more information of where this Math came from visit:
16089
16190
  // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
16090
- const d120 = (Math.PI * 120) / 180;
16091
- const rad = (Math.PI / 180) * (+angle || 0);
16191
+ var d120 = (Math.PI * 120) / 180;
16192
+ var rad = (Math.PI / 180) * (+angle || 0);
16092
16193
  /** @type {number[]} */
16093
- let res = [];
16094
- let xy;
16095
- let f1;
16096
- let f2;
16097
- let cx;
16098
- let cy;
16194
+ var res = [];
16195
+ var xy;
16196
+ var f1;
16197
+ var f2;
16198
+ var cx;
16199
+ var cy;
16099
16200
  if (!recursive) {
16100
16201
  xy = rotateVector(x1, y1, -rad);
16101
16202
  x1 = xy.x;
@@ -16103,17 +16204,17 @@
16103
16204
  xy = rotateVector(x2, y2, -rad);
16104
16205
  x2 = xy.x;
16105
16206
  y2 = xy.y;
16106
- const x = (x1 - x2) / 2;
16107
- const y = (y1 - y2) / 2;
16108
- let h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
16207
+ var x = (x1 - x2) / 2;
16208
+ var y = (y1 - y2) / 2;
16209
+ var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
16109
16210
  if (h > 1) {
16110
16211
  h = Math.sqrt(h);
16111
16212
  rx *= h;
16112
16213
  ry *= h;
16113
16214
  }
16114
- const rx2 = rx * rx;
16115
- const ry2 = ry * ry;
16116
- const k = (LAF === SF ? -1 : 1) *
16215
+ var rx2 = rx * rx;
16216
+ var ry2 = ry * ry;
16217
+ var k = (LAF === SF ? -1 : 1) *
16117
16218
  Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
16118
16219
  cx = (k * rx * y) / ry + (x1 + x2) / 2;
16119
16220
  cy = (k * -ry * x) / rx + (y1 + y2) / 2;
@@ -16135,38 +16236,38 @@
16135
16236
  }
16136
16237
  }
16137
16238
  else {
16138
- [f1, f2, cx, cy] = recursive;
16239
+ f1 = recursive[0], f2 = recursive[1], cx = recursive[2], cy = recursive[3];
16139
16240
  }
16140
- let df = f2 - f1;
16241
+ var df = f2 - f1;
16141
16242
  if (Math.abs(df) > d120) {
16142
- const f2old = f2;
16143
- const x2old = x2;
16144
- const y2old = y2;
16243
+ var f2old = f2;
16244
+ var x2old = x2;
16245
+ var y2old = y2;
16145
16246
  f2 = f1 + d120 * (SF && f2 > f1 ? 1 : -1);
16146
16247
  x2 = cx + rx * Math.cos(f2);
16147
16248
  y2 = cy + ry * Math.sin(f2);
16148
16249
  res = arcToCubic(x2, y2, rx, ry, angle, 0, SF, x2old, y2old, [f2, f2old, cx, cy]);
16149
16250
  }
16150
16251
  df = f2 - f1;
16151
- const c1 = Math.cos(f1);
16152
- const s1 = Math.sin(f1);
16153
- const c2 = Math.cos(f2);
16154
- const s2 = Math.sin(f2);
16155
- const t = Math.tan(df / 4);
16156
- const hx = (4 / 3) * rx * t;
16157
- const hy = (4 / 3) * ry * t;
16158
- const m1 = [x1, y1];
16159
- const m2 = [x1 + hx * s1, y1 - hy * c1];
16160
- const m3 = [x2 + hx * s2, y2 - hy * c2];
16161
- const m4 = [x2, y2];
16252
+ var c1 = Math.cos(f1);
16253
+ var s1 = Math.sin(f1);
16254
+ var c2 = Math.cos(f2);
16255
+ var s2 = Math.sin(f2);
16256
+ var t = Math.tan(df / 4);
16257
+ var hx = (4 / 3) * rx * t;
16258
+ var hy = (4 / 3) * ry * t;
16259
+ var m1 = [x1, y1];
16260
+ var m2 = [x1 + hx * s1, y1 - hy * c1];
16261
+ var m3 = [x2 + hx * s2, y2 - hy * c2];
16262
+ var m4 = [x2, y2];
16162
16263
  m2[0] = 2 * m1[0] - m2[0];
16163
16264
  m2[1] = 2 * m1[1] - m2[1];
16164
16265
  if (recursive) {
16165
- return [...m2, ...m3, ...m4, ...res];
16266
+ return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], m2, true), m3, true), m4, true), res, true);
16166
16267
  }
16167
- res = [...m2, ...m3, ...m4, ...res];
16168
- const newres = [];
16169
- for (let i = 0, ii = res.length; i < ii; i += 1) {
16268
+ res = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], m2, true), m3, true), m4, true), res, true);
16269
+ var newres = [];
16270
+ for (var i = 0, ii = res.length; i < ii; i += 1) {
16170
16271
  newres[i] = i % 2 ? rotateVector(res[i - 1], res[i], rad).y : rotateVector(res[i], res[i + 1], rad).x;
16171
16272
  }
16172
16273
  return newres;
@@ -16355,8 +16456,8 @@
16355
16456
  // }
16356
16457
 
16357
16458
  function quadToCubic(x1, y1, qx, qy, x2, y2) {
16358
- const r13 = 1 / 3;
16359
- const r23 = 2 / 3;
16459
+ var r13 = 1 / 3;
16460
+ var r23 = 2 / 3;
16360
16461
  return [
16361
16462
  r13 * x1 + r23 * qx,
16362
16463
  r13 * y1 + r23 * qy,
@@ -16368,10 +16469,10 @@
16368
16469
  }
16369
16470
 
16370
16471
  function midPoint(a, b, t) {
16371
- const ax = a[0];
16372
- const ay = a[1];
16373
- const bx = b[0];
16374
- const by = b[1];
16472
+ var ax = a[0];
16473
+ var ay = a[1];
16474
+ var bx = b[0];
16475
+ var by = b[1];
16375
16476
  return [ax + (bx - ax) * t, ay + (by - ay) * t];
16376
16477
  }
16377
16478
 
@@ -16384,8 +16485,8 @@
16384
16485
  * the minimum and maximum {x,y} coordinates of a line (L,V,H,Z) segment.
16385
16486
  */
16386
16487
  function segmentLineFactory(x1, y1, x2, y2, distance) {
16387
- const length = distanceSquareRoot([x1, y1], [x2, y2]);
16388
- let point = { x: 0, y: 0 };
16488
+ var length = distanceSquareRoot([x1, y1], [x2, y2]);
16489
+ var point = { x: 0, y: 0 };
16389
16490
  if (typeof distance === 'number') {
16390
16491
  if (distance <= 0) {
16391
16492
  point = { x: x1, y: y1 };
@@ -16394,13 +16495,13 @@
16394
16495
  point = { x: x2, y: y2 };
16395
16496
  }
16396
16497
  else {
16397
- const [x, y] = midPoint([x1, y1], [x2, y2], distance / length);
16398
- point = { x, y };
16498
+ var _a = midPoint([x1, y1], [x2, y2], distance / length), x = _a[0], y = _a[1];
16499
+ point = { x: x, y: y };
16399
16500
  }
16400
16501
  }
16401
16502
  return {
16402
- length,
16403
- point,
16503
+ length: length,
16504
+ point: point,
16404
16505
  min: {
16405
16506
  x: Math.min(x1, x2),
16406
16507
  y: Math.min(y1, y2),
@@ -16413,29 +16514,29 @@
16413
16514
  }
16414
16515
 
16415
16516
  function lineToCubic(x1, y1, x2, y2) {
16416
- const t = 0.5;
16417
- const p0 = [x1, y1];
16418
- const p1 = [x2, y2];
16419
- const p2 = midPoint(p0, p1, t);
16420
- const p3 = midPoint(p1, p2, t);
16421
- const p4 = midPoint(p2, p3, t);
16422
- const p5 = midPoint(p3, p4, t);
16423
- const p6 = midPoint(p4, p5, t);
16424
- const seg1 = [...p0, ...p2, ...p4, ...p6, t];
16517
+ var t = 0.5;
16518
+ var p0 = [x1, y1];
16519
+ var p1 = [x2, y2];
16520
+ var p2 = midPoint(p0, p1, t);
16521
+ var p3 = midPoint(p1, p2, t);
16522
+ var p4 = midPoint(p2, p3, t);
16523
+ var p5 = midPoint(p3, p4, t);
16524
+ var p6 = midPoint(p4, p5, t);
16525
+ var seg1 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], p0, true), p2, true), p4, true), p6, true), [t], false);
16425
16526
  // @ts-ignore
16426
- const cp1 = segmentLineFactory(...seg1).point;
16427
- const seg2 = [...p6, ...p5, ...p3, ...p1, 0];
16527
+ var cp1 = segmentLineFactory.apply(void 0, seg1).point;
16528
+ var seg2 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], p6, true), p5, true), p3, true), p1, true), [0], false);
16428
16529
  // @ts-ignore
16429
- const cp2 = segmentLineFactory(...seg2).point;
16530
+ var cp2 = segmentLineFactory.apply(void 0, seg2).point;
16430
16531
  return [cp1.x, cp1.y, cp2.x, cp2.y, x2, y2];
16431
16532
  }
16432
16533
 
16433
16534
  function segmentToCubic(segment, params) {
16434
- const [pathCommand] = segment;
16435
- const values = segment.slice(1).map(Number);
16436
- const [x, y] = values;
16437
- let args;
16438
- const { x1: px1, y1: py1, x: px, y: py } = params;
16535
+ var pathCommand = segment[0];
16536
+ var values = segment.slice(1).map(Number);
16537
+ var x = values[0], y = values[1];
16538
+ var args;
16539
+ var px1 = params.x1, py1 = params.y1, px = params.x, py = params.y;
16439
16540
  if (!'TQ'.includes(pathCommand)) {
16440
16541
  params.qx = null;
16441
16542
  params.qy = null;
@@ -16446,31 +16547,32 @@
16446
16547
  params.y = y;
16447
16548
  return segment;
16448
16549
  case 'A':
16449
- args = [px1, py1, ...values];
16550
+ args = __spreadArray([px1, py1], values, true);
16450
16551
  // @ts-ignore
16451
- return ['C', ...arcToCubic(...args)];
16552
+ return __spreadArray(['C'], arcToCubic.apply(void 0, args), true);
16452
16553
  case 'Q':
16453
16554
  params.qx = x;
16454
16555
  params.qy = y;
16455
- args = [px1, py1, ...values];
16556
+ args = __spreadArray([px1, py1], values, true);
16456
16557
  // @ts-ignore
16457
- return ['C', ...quadToCubic(...args)];
16558
+ return __spreadArray(['C'], quadToCubic.apply(void 0, args), true);
16458
16559
  case 'L':
16459
- return ['C', ...lineToCubic(px1, py1, x, y)];
16560
+ return __spreadArray(['C'], lineToCubic(px1, py1, x, y), true);
16460
16561
  case 'Z':
16461
16562
  // prevent NaN from divide 0
16462
16563
  if (px1 === px && py1 === py) {
16463
16564
  return ['C', px1, py1, px, py, px, py];
16464
16565
  }
16465
- return ['C', ...lineToCubic(px1, py1, px, py)];
16566
+ return __spreadArray(['C'], lineToCubic(px1, py1, px, py), true);
16466
16567
  }
16467
16568
  return segment;
16468
16569
  }
16469
16570
 
16470
16571
  // import { fixPath } from '../process/fix-path';
16471
- function path2Curve(pathInput, needZCommandIndexes = false) {
16572
+ function path2Curve(pathInput, needZCommandIndexes) {
16573
+ if (needZCommandIndexes === void 0) { needZCommandIndexes = false; }
16472
16574
  if (isCurveArray(pathInput)) {
16473
- const cloned = clonePath(pathInput);
16575
+ var cloned = clonePath(pathInput);
16474
16576
  if (needZCommandIndexes) {
16475
16577
  return [cloned, []];
16476
16578
  }
@@ -16480,19 +16582,19 @@
16480
16582
  }
16481
16583
  // fixPath will remove 'Z' command
16482
16584
  // const path = fixPath(normalizePath(pathInput));
16483
- const path = normalizePath(pathInput);
16484
- const params = Object.assign({}, paramsParser);
16485
- const allPathCommands = [];
16486
- let pathCommand = '';
16487
- let ii = path.length;
16488
- let segment;
16489
- let seglen;
16490
- const zCommandIndexes = [];
16491
- for (let i = 0; i < ii; i += 1) {
16585
+ var path = normalizePath(pathInput);
16586
+ var params = __assign({}, paramsParser);
16587
+ var allPathCommands = [];
16588
+ var pathCommand = '';
16589
+ var ii = path.length;
16590
+ var segment;
16591
+ var seglen;
16592
+ var zCommandIndexes = [];
16593
+ for (var i = 0; i < ii; i += 1) {
16492
16594
  if (path[i])
16493
- [pathCommand] = path[i];
16595
+ pathCommand = path[i][0];
16494
16596
  allPathCommands[i] = pathCommand;
16495
- const curveSegment = segmentToCubic(path[i], params);
16597
+ var curveSegment = segmentToCubic(path[i], params);
16496
16598
  path[i] = curveSegment;
16497
16599
  fixArc(path, allPathCommands, i);
16498
16600
  ii = path.length; // solves curveArrays ending in Z
@@ -16519,24 +16621,25 @@
16519
16621
 
16520
16622
  // reverse CURVE based pathArray segments only
16521
16623
  function reverseCurve(pathArray) {
16522
- const rotatedCurve = pathArray
16624
+ var rotatedCurve = pathArray
16523
16625
  .slice(1)
16524
- .map((x, i, curveOnly) =>
16525
- // @ts-ignore
16526
- !i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1)))
16626
+ .map(function (x, i, curveOnly) {
16527
16627
  // @ts-ignore
16528
- .map((x) => x.map((y, i) => x[x.length - i - 2 * (1 - (i % 2))]))
16628
+ return !i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1));
16629
+ })
16630
+ // @ts-ignore
16631
+ .map(function (x) { return x.map(function (y, i) { return x[x.length - i - 2 * (1 - (i % 2))]; }); })
16529
16632
  .reverse();
16530
- return [['M'].concat(rotatedCurve[0].slice(0, 2))].concat(rotatedCurve.map((x) => ['C'].concat(x.slice(2))));
16633
+ return [['M'].concat(rotatedCurve[0].slice(0, 2))].concat(rotatedCurve.map(function (x) { return ['C'].concat(x.slice(2)); }));
16531
16634
  }
16532
16635
 
16533
16636
  function angleBetween(v0, v1) {
16534
- const { x: v0x, y: v0y } = v0;
16535
- const { x: v1x, y: v1y } = v1;
16536
- const p = v0x * v1x + v0y * v1y;
16537
- const n = Math.sqrt((Math.pow(v0x, 2) + Math.pow(v0y, 2)) * (Math.pow(v1x, 2) + Math.pow(v1y, 2)));
16538
- const sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;
16539
- const angle = sign * Math.acos(p / n);
16637
+ var v0x = v0.x, v0y = v0.y;
16638
+ var v1x = v1.x, v1y = v1.y;
16639
+ var p = v0x * v1x + v0y * v1y;
16640
+ var n = Math.sqrt((Math.pow(v0x, 2) + Math.pow(v0y, 2)) * (Math.pow(v1x, 2) + Math.pow(v1y, 2)));
16641
+ var sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;
16642
+ var angle = sign * Math.acos(p / n);
16540
16643
  return angle;
16541
16644
  }
16542
16645
  /**
@@ -16545,51 +16648,51 @@
16545
16648
  * @see https://github.com/MadLittleMods/svg-curve-lib/blob/master/src/js/svg-curve-lib.js
16546
16649
  */
16547
16650
  function getPointAtArcSegmentLength(x1, y1, RX, RY, angle, LAF, SF, x, y, t) {
16548
- const { abs, sin, cos, sqrt, PI } = Math;
16549
- let rx = abs(RX);
16550
- let ry = abs(RY);
16551
- const xRot = ((angle % 360) + 360) % 360;
16552
- const xRotRad = xRot * (PI / 180);
16651
+ var abs = Math.abs, sin = Math.sin, cos = Math.cos, sqrt = Math.sqrt, PI = Math.PI;
16652
+ var rx = abs(RX);
16653
+ var ry = abs(RY);
16654
+ var xRot = ((angle % 360) + 360) % 360;
16655
+ var xRotRad = xRot * (PI / 180);
16553
16656
  if (x1 === x && y1 === y) {
16554
16657
  return { x: x1, y: y1 };
16555
16658
  }
16556
16659
  if (rx === 0 || ry === 0) {
16557
16660
  return segmentLineFactory(x1, y1, x, y, t).point;
16558
16661
  }
16559
- const dx = (x1 - x) / 2;
16560
- const dy = (y1 - y) / 2;
16561
- const transformedPoint = {
16662
+ var dx = (x1 - x) / 2;
16663
+ var dy = (y1 - y) / 2;
16664
+ var transformedPoint = {
16562
16665
  x: cos(xRotRad) * dx + sin(xRotRad) * dy,
16563
16666
  y: -sin(xRotRad) * dx + cos(xRotRad) * dy,
16564
16667
  };
16565
- const radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
16668
+ var radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
16566
16669
  if (radiiCheck > 1) {
16567
16670
  rx *= sqrt(radiiCheck);
16568
16671
  ry *= sqrt(radiiCheck);
16569
16672
  }
16570
- const 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);
16571
- const cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
16572
- let cRadicand = cSquareNumerator / cSquareRootDenom;
16673
+ 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);
16674
+ var cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
16675
+ var cRadicand = cSquareNumerator / cSquareRootDenom;
16573
16676
  cRadicand = cRadicand < 0 ? 0 : cRadicand;
16574
- const cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);
16575
- const transformedCenter = {
16677
+ var cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);
16678
+ var transformedCenter = {
16576
16679
  x: cCoef * ((rx * transformedPoint.y) / ry),
16577
16680
  y: cCoef * (-(ry * transformedPoint.x) / rx),
16578
16681
  };
16579
- const center = {
16682
+ var center = {
16580
16683
  x: cos(xRotRad) * transformedCenter.x - sin(xRotRad) * transformedCenter.y + (x1 + x) / 2,
16581
16684
  y: sin(xRotRad) * transformedCenter.x + cos(xRotRad) * transformedCenter.y + (y1 + y) / 2,
16582
16685
  };
16583
- const startVector = {
16686
+ var startVector = {
16584
16687
  x: (transformedPoint.x - transformedCenter.x) / rx,
16585
16688
  y: (transformedPoint.y - transformedCenter.y) / ry,
16586
16689
  };
16587
- const startAngle = angleBetween({ x: 1, y: 0 }, startVector);
16588
- const endVector = {
16690
+ var startAngle = angleBetween({ x: 1, y: 0 }, startVector);
16691
+ var endVector = {
16589
16692
  x: (-transformedPoint.x - transformedCenter.x) / rx,
16590
16693
  y: (-transformedPoint.y - transformedCenter.y) / ry,
16591
16694
  };
16592
- let sweepAngle = angleBetween(startVector, endVector);
16695
+ var sweepAngle = angleBetween(startVector, endVector);
16593
16696
  if (!SF && sweepAngle > 0) {
16594
16697
  sweepAngle -= 2 * PI;
16595
16698
  }
@@ -16597,10 +16700,10 @@
16597
16700
  sweepAngle += 2 * PI;
16598
16701
  }
16599
16702
  sweepAngle %= 2 * PI;
16600
- const alpha = startAngle + sweepAngle * t;
16601
- const ellipseComponentX = rx * cos(alpha);
16602
- const ellipseComponentY = ry * sin(alpha);
16603
- const point = {
16703
+ var alpha = startAngle + sweepAngle * t;
16704
+ var ellipseComponentX = rx * cos(alpha);
16705
+ var ellipseComponentY = ry * sin(alpha);
16706
+ var point = {
16604
16707
  x: cos(xRotRad) * ellipseComponentX - sin(xRotRad) * ellipseComponentY + center.x,
16605
16708
  y: sin(xRotRad) * ellipseComponentX + cos(xRotRad) * ellipseComponentY + center.y,
16606
16709
  };
@@ -16618,27 +16721,28 @@
16618
16721
  * the shape minimum and maximum {x,y} coordinates of an A (arc-to) segment.
16619
16722
  */
16620
16723
  function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
16621
- const distanceIsNumber = typeof distance === 'number';
16622
- let x = X1;
16623
- let y = Y1;
16624
- let LENGTH = 0;
16625
- let prev = [x, y, LENGTH];
16626
- let cur = [x, y];
16627
- let t = 0;
16628
- let POINT = { x: 0, y: 0 };
16629
- let POINTS = [{ x, y }];
16724
+ var _a;
16725
+ var distanceIsNumber = typeof distance === 'number';
16726
+ var x = X1;
16727
+ var y = Y1;
16728
+ var LENGTH = 0;
16729
+ var prev = [x, y, LENGTH];
16730
+ var cur = [x, y];
16731
+ var t = 0;
16732
+ var POINT = { x: 0, y: 0 };
16733
+ var POINTS = [{ x: x, y: y }];
16630
16734
  if (distanceIsNumber && distance <= 0) {
16631
- POINT = { x, y };
16735
+ POINT = { x: x, y: y };
16632
16736
  }
16633
- const sampleSize = 300;
16634
- for (let j = 0; j <= sampleSize; j += 1) {
16737
+ var sampleSize = 300;
16738
+ for (var j = 0; j <= sampleSize; j += 1) {
16635
16739
  t = j / sampleSize;
16636
- ({ x, y } = getPointAtArcSegmentLength(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, t));
16637
- POINTS = [...POINTS, { x, y }];
16740
+ (_a = getPointAtArcSegmentLength(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, t), x = _a.x, y = _a.y);
16741
+ POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
16638
16742
  LENGTH += distanceSquareRoot(cur, [x, y]);
16639
16743
  cur = [x, y];
16640
16744
  if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
16641
- const dv = (LENGTH - distance) / (LENGTH - prev[2]);
16745
+ var dv = (LENGTH - distance) / (LENGTH - prev[2]);
16642
16746
  POINT = {
16643
16747
  x: cur[0] * (1 - dv) + prev[0] * dv,
16644
16748
  y: cur[1] * (1 - dv) + prev[1] * dv,
@@ -16653,12 +16757,12 @@
16653
16757
  length: LENGTH,
16654
16758
  point: POINT,
16655
16759
  min: {
16656
- x: Math.min(...POINTS.map((n) => n.x)),
16657
- y: Math.min(...POINTS.map((n) => n.y)),
16760
+ x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
16761
+ y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
16658
16762
  },
16659
16763
  max: {
16660
- x: Math.max(...POINTS.map((n) => n.x)),
16661
- y: Math.max(...POINTS.map((n) => n.y)),
16764
+ x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
16765
+ y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
16662
16766
  },
16663
16767
  };
16664
16768
  }
@@ -16668,7 +16772,7 @@
16668
16772
  * the minimum and maximum {x,y} coordinates of a C (cubic-bezier) segment.
16669
16773
  */
16670
16774
  function getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t) {
16671
- const t1 = 1 - t;
16775
+ var t1 = 1 - t;
16672
16776
  return {
16673
16777
  x: Math.pow(t1, 3) * x1 + 3 * Math.pow(t1, 2) * t * c1x + 3 * t1 * Math.pow(t, 2) * c2x + Math.pow(t, 3) * x2,
16674
16778
  y: Math.pow(t1, 3) * y1 + 3 * Math.pow(t1, 2) * t * c1y + 3 * t1 * Math.pow(t, 2) * c2y + Math.pow(t, 3) * y2,
@@ -16679,28 +16783,29 @@
16679
16783
  * or an {x,y} point at a given length.
16680
16784
  */
16681
16785
  function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
16682
- const distanceIsNumber = typeof distance === 'number';
16683
- let x = x1;
16684
- let y = y1;
16685
- let LENGTH = 0;
16686
- let prev = [x, y, LENGTH];
16687
- let cur = [x, y];
16688
- let t = 0;
16689
- let POINT = { x: 0, y: 0 };
16690
- let POINTS = [{ x, y }];
16786
+ var _a;
16787
+ var distanceIsNumber = typeof distance === 'number';
16788
+ var x = x1;
16789
+ var y = y1;
16790
+ var LENGTH = 0;
16791
+ var prev = [x, y, LENGTH];
16792
+ var cur = [x, y];
16793
+ var t = 0;
16794
+ var POINT = { x: 0, y: 0 };
16795
+ var POINTS = [{ x: x, y: y }];
16691
16796
  if (distanceIsNumber && distance <= 0) {
16692
- POINT = { x, y };
16797
+ POINT = { x: x, y: y };
16693
16798
  }
16694
16799
  // bad perf when size = 300
16695
- const sampleSize = 20;
16696
- for (let j = 0; j <= sampleSize; j += 1) {
16800
+ var sampleSize = 20;
16801
+ for (var j = 0; j <= sampleSize; j += 1) {
16697
16802
  t = j / sampleSize;
16698
- ({ x, y } = getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t));
16699
- POINTS = [...POINTS, { x, y }];
16803
+ (_a = getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t), x = _a.x, y = _a.y);
16804
+ POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
16700
16805
  LENGTH += distanceSquareRoot(cur, [x, y]);
16701
16806
  cur = [x, y];
16702
16807
  if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
16703
- const dv = (LENGTH - distance) / (LENGTH - prev[2]);
16808
+ var dv = (LENGTH - distance) / (LENGTH - prev[2]);
16704
16809
  POINT = {
16705
16810
  x: cur[0] * (1 - dv) + prev[0] * dv,
16706
16811
  y: cur[1] * (1 - dv) + prev[1] * dv,
@@ -16715,12 +16820,12 @@
16715
16820
  length: LENGTH,
16716
16821
  point: POINT,
16717
16822
  min: {
16718
- x: Math.min(...POINTS.map((n) => n.x)),
16719
- y: Math.min(...POINTS.map((n) => n.y)),
16823
+ x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
16824
+ y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
16720
16825
  },
16721
16826
  max: {
16722
- x: Math.max(...POINTS.map((n) => n.x)),
16723
- y: Math.max(...POINTS.map((n) => n.y)),
16827
+ x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
16828
+ y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
16724
16829
  },
16725
16830
  };
16726
16831
  }
@@ -16732,7 +16837,7 @@
16732
16837
  * @see https://github.com/substack/point-at-length
16733
16838
  */
16734
16839
  function getPointAtQuadSegmentLength(x1, y1, cx, cy, x2, y2, t) {
16735
- const t1 = 1 - t;
16840
+ var t1 = 1 - t;
16736
16841
  return {
16737
16842
  x: Math.pow(t1, 2) * x1 + 2 * t1 * t * cx + Math.pow(t, 2) * x2,
16738
16843
  y: Math.pow(t1, 2) * y1 + 2 * t1 * t * cy + Math.pow(t, 2) * y2,
@@ -16743,27 +16848,28 @@
16743
16848
  * the minimum and maximum {x,y} coordinates of a Q (quadratic-bezier) segment.
16744
16849
  */
16745
16850
  function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
16746
- const distanceIsNumber = typeof distance === 'number';
16747
- let x = x1;
16748
- let y = y1;
16749
- let LENGTH = 0;
16750
- let prev = [x, y, LENGTH];
16751
- let cur = [x, y];
16752
- let t = 0;
16753
- let POINT = { x: 0, y: 0 };
16754
- let POINTS = [{ x, y }];
16851
+ var _a;
16852
+ var distanceIsNumber = typeof distance === 'number';
16853
+ var x = x1;
16854
+ var y = y1;
16855
+ var LENGTH = 0;
16856
+ var prev = [x, y, LENGTH];
16857
+ var cur = [x, y];
16858
+ var t = 0;
16859
+ var POINT = { x: 0, y: 0 };
16860
+ var POINTS = [{ x: x, y: y }];
16755
16861
  if (distanceIsNumber && distance <= 0) {
16756
- POINT = { x, y };
16862
+ POINT = { x: x, y: y };
16757
16863
  }
16758
- const sampleSize = 300;
16759
- for (let j = 0; j <= sampleSize; j += 1) {
16864
+ var sampleSize = 300;
16865
+ for (var j = 0; j <= sampleSize; j += 1) {
16760
16866
  t = j / sampleSize;
16761
- ({ x, y } = getPointAtQuadSegmentLength(x1, y1, qx, qy, x2, y2, t));
16762
- POINTS = [...POINTS, { x, y }];
16867
+ (_a = getPointAtQuadSegmentLength(x1, y1, qx, qy, x2, y2, t), x = _a.x, y = _a.y);
16868
+ POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
16763
16869
  LENGTH += distanceSquareRoot(cur, [x, y]);
16764
16870
  cur = [x, y];
16765
16871
  if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
16766
- const dv = (LENGTH - distance) / (LENGTH - prev[2]);
16872
+ var dv = (LENGTH - distance) / (LENGTH - prev[2]);
16767
16873
  POINT = {
16768
16874
  x: cur[0] * (1 - dv) + prev[0] * dv,
16769
16875
  y: cur[1] * (1 - dv) + prev[1] * dv,
@@ -16779,12 +16885,12 @@
16779
16885
  length: LENGTH,
16780
16886
  point: POINT,
16781
16887
  min: {
16782
- x: Math.min(...POINTS.map((n) => n.x)),
16783
- y: Math.min(...POINTS.map((n) => n.y)),
16888
+ x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
16889
+ y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
16784
16890
  },
16785
16891
  max: {
16786
- x: Math.max(...POINTS.map((n) => n.x)),
16787
- y: Math.max(...POINTS.map((n) => n.y)),
16892
+ x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
16893
+ y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
16788
16894
  },
16789
16895
  };
16790
16896
  }
@@ -16795,34 +16901,35 @@
16795
16901
  * the shape minimum and maximum {x,y} coordinates.
16796
16902
  */
16797
16903
  function pathLengthFactory(pathInput, distance) {
16798
- const path = normalizePath(pathInput);
16799
- const distanceIsNumber = typeof distance === 'number';
16800
- let isM;
16801
- let data = [];
16802
- let pathCommand;
16803
- let x = 0;
16804
- let y = 0;
16805
- let mx = 0;
16806
- let my = 0;
16807
- let seg;
16808
- let MIN = [];
16809
- let MAX = [];
16810
- let length = 0;
16811
- let min = { x: 0, y: 0 };
16812
- let max = min;
16813
- let point = min;
16814
- let POINT = min;
16815
- let LENGTH = 0;
16816
- for (let i = 0, ll = path.length; i < ll; i += 1) {
16904
+ var _a, _b, _c, _d, _e, _f;
16905
+ var path = normalizePath(pathInput);
16906
+ var distanceIsNumber = typeof distance === 'number';
16907
+ var isM;
16908
+ var data = [];
16909
+ var pathCommand;
16910
+ var x = 0;
16911
+ var y = 0;
16912
+ var mx = 0;
16913
+ var my = 0;
16914
+ var seg;
16915
+ var MIN = [];
16916
+ var MAX = [];
16917
+ var length = 0;
16918
+ var min = { x: 0, y: 0 };
16919
+ var max = min;
16920
+ var point = min;
16921
+ var POINT = min;
16922
+ var LENGTH = 0;
16923
+ for (var i = 0, ll = path.length; i < ll; i += 1) {
16817
16924
  seg = path[i];
16818
- [pathCommand] = seg;
16925
+ pathCommand = seg[0];
16819
16926
  isM = pathCommand === 'M';
16820
- data = !isM ? [x, y, ...seg.slice(1)] : data;
16927
+ data = !isM ? __spreadArray([x, y], seg.slice(1), true) : data;
16821
16928
  // this segment is always ZERO
16822
16929
  /* istanbul ignore else */
16823
16930
  if (isM) {
16824
16931
  // remember mx, my for Z
16825
- [, mx, my] = seg;
16932
+ mx = seg[1], my = seg[2];
16826
16933
  min = { x: mx, y: my };
16827
16934
  max = min;
16828
16935
  length = 0;
@@ -16832,48 +16939,48 @@
16832
16939
  }
16833
16940
  else if (pathCommand === 'L') {
16834
16941
  // @ts-ignore
16835
- ({ length, min, max, point } = segmentLineFactory(...data, (distance || 0) - LENGTH));
16942
+ (_a = segmentLineFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _a.length, min = _a.min, max = _a.max, point = _a.point);
16836
16943
  }
16837
16944
  else if (pathCommand === 'A') {
16838
16945
  // @ts-ignore
16839
- ({ length, min, max, point } = segmentArcFactory(...data, (distance || 0) - LENGTH));
16946
+ (_b = segmentArcFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _b.length, min = _b.min, max = _b.max, point = _b.point);
16840
16947
  }
16841
16948
  else if (pathCommand === 'C') {
16842
16949
  // @ts-ignore
16843
- ({ length, min, max, point } = segmentCubicFactory(...data, (distance || 0) - LENGTH));
16950
+ (_c = segmentCubicFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _c.length, min = _c.min, max = _c.max, point = _c.point);
16844
16951
  }
16845
16952
  else if (pathCommand === 'Q') {
16846
16953
  // @ts-ignore
16847
- ({ length, min, max, point } = segmentQuadFactory(...data, (distance || 0) - LENGTH));
16954
+ (_d = segmentQuadFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _d.length, min = _d.min, max = _d.max, point = _d.point);
16848
16955
  }
16849
16956
  else if (pathCommand === 'Z') {
16850
16957
  data = [x, y, mx, my];
16851
16958
  // @ts-ignore
16852
- ({ length, min, max, point } = segmentLineFactory(...data, (distance || 0) - LENGTH));
16959
+ (_e = segmentLineFactory.apply(void 0, __spreadArray(__spreadArray([], data, false), [(distance || 0) - LENGTH], false)), length = _e.length, min = _e.min, max = _e.max, point = _e.point);
16853
16960
  }
16854
16961
  if (distanceIsNumber && LENGTH < distance && LENGTH + length >= distance) {
16855
16962
  POINT = point;
16856
16963
  }
16857
- MAX = [...MAX, max];
16858
- MIN = [...MIN, min];
16964
+ MAX = __spreadArray(__spreadArray([], MAX, true), [max], false);
16965
+ MIN = __spreadArray(__spreadArray([], MIN, true), [min], false);
16859
16966
  LENGTH += length;
16860
- [x, y] = pathCommand !== 'Z' ? seg.slice(-2) : [mx, my];
16967
+ _f = pathCommand !== 'Z' ? seg.slice(-2) : [mx, my], x = _f[0], y = _f[1];
16861
16968
  }
16862
16969
  // native `getPointAtLength` behavior when the given distance
16863
16970
  // is higher than total length
16864
16971
  if (distanceIsNumber && distance >= LENGTH) {
16865
- POINT = { x, y };
16972
+ POINT = { x: x, y: y };
16866
16973
  }
16867
16974
  return {
16868
16975
  length: LENGTH,
16869
16976
  point: POINT,
16870
16977
  min: {
16871
- x: Math.min(...MIN.map((n) => n.x)),
16872
- y: Math.min(...MIN.map((n) => n.y)),
16978
+ x: Math.min.apply(Math, MIN.map(function (n) { return n.x; })),
16979
+ y: Math.min.apply(Math, MIN.map(function (n) { return n.y; })),
16873
16980
  },
16874
16981
  max: {
16875
- x: Math.max(...MAX.map((n) => n.x)),
16876
- y: Math.max(...MAX.map((n) => n.y)),
16982
+ x: Math.max.apply(Math, MAX.map(function (n) { return n.x; })),
16983
+ y: Math.max.apply(Math, MAX.map(function (n) { return n.y; })),
16877
16984
  },
16878
16985
  };
16879
16986
  }
@@ -16896,13 +17003,13 @@
16896
17003
  cz: 0,
16897
17004
  };
16898
17005
  }
16899
- const { length, min: { x: xMin, y: yMin }, max: { x: xMax, y: yMax }, } = pathLengthFactory(path);
16900
- const width = xMax - xMin;
16901
- const height = yMax - yMin;
17006
+ var _a = pathLengthFactory(path), length = _a.length, _b = _a.min, xMin = _b.x, yMin = _b.y, _c = _a.max, xMax = _c.x, yMax = _c.y;
17007
+ var width = xMax - xMin;
17008
+ var height = yMax - yMin;
16902
17009
  return {
16903
- length,
16904
- width,
16905
- height,
17010
+ length: length,
17011
+ width: width,
17012
+ height: height,
16906
17013
  x: xMin,
16907
17014
  y: yMin,
16908
17015
  x2: xMax,
@@ -16915,28 +17022,30 @@
16915
17022
  }
16916
17023
 
16917
17024
  function getRotations(a) {
16918
- const segCount = a.length;
16919
- const pointCount = segCount - 1;
16920
- return a.map((f, idx) => a.map((p, i) => {
16921
- let oldSegIdx = idx + i;
16922
- let seg;
16923
- if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === 'M')) {
16924
- seg = a[oldSegIdx];
16925
- return ['M'].concat(seg.slice(-2));
16926
- }
16927
- if (oldSegIdx >= segCount)
16928
- oldSegIdx -= pointCount;
16929
- return a[oldSegIdx];
16930
- }));
17025
+ var segCount = a.length;
17026
+ var pointCount = segCount - 1;
17027
+ return a.map(function (f, idx) {
17028
+ return a.map(function (p, i) {
17029
+ var oldSegIdx = idx + i;
17030
+ var seg;
17031
+ if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === 'M')) {
17032
+ seg = a[oldSegIdx];
17033
+ return ['M'].concat(seg.slice(-2));
17034
+ }
17035
+ if (oldSegIdx >= segCount)
17036
+ oldSegIdx -= pointCount;
17037
+ return a[oldSegIdx];
17038
+ });
17039
+ });
16931
17040
  }
16932
17041
  function getRotatedCurve(a, b) {
16933
- const segCount = a.length - 1;
16934
- const lineLengths = [];
16935
- let computedIndex = 0;
16936
- let sumLensSqrd = 0;
16937
- const rotations = getRotations(a);
16938
- rotations.forEach((r, i) => {
16939
- a.slice(1).forEach((s, j) => {
17042
+ var segCount = a.length - 1;
17043
+ var lineLengths = [];
17044
+ var computedIndex = 0;
17045
+ var sumLensSqrd = 0;
17046
+ var rotations = getRotations(a);
17047
+ rotations.forEach(function (r, i) {
17048
+ a.slice(1).forEach(function (s, j) {
16940
17049
  // @ts-ignore
16941
17050
  sumLensSqrd += distanceSquareRoot(a[(i + j) % segCount].slice(-2), b[j % segCount].slice(-2));
16942
17051
  });
@@ -16970,23 +17079,24 @@
16970
17079
  * @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
16971
17080
  */
16972
17081
  function getPathArea(path) {
16973
- let x = 0;
16974
- let y = 0;
16975
- let len = 0;
17082
+ var x = 0;
17083
+ var y = 0;
17084
+ var len = 0;
16976
17085
  return path2Curve(path)
16977
- .map((seg) => {
17086
+ .map(function (seg) {
17087
+ var _a;
16978
17088
  switch (seg[0]) {
16979
17089
  case 'M':
16980
- [, x, y] = seg;
17090
+ x = seg[1], y = seg[2];
16981
17091
  return 0;
16982
17092
  default:
16983
17093
  // @ts-ignore
16984
- len = getCubicSegArea(x, y, ...seg.slice(1));
16985
- [x, y] = seg.slice(-2);
17094
+ len = getCubicSegArea.apply(void 0, __spreadArray([x, y], seg.slice(1), false));
17095
+ _a = seg.slice(-2), x = _a[0], y = _a[1];
16986
17096
  return len;
16987
17097
  }
16988
17098
  })
16989
- .reduce((a, b) => a + b, 0);
17099
+ .reduce(function (a, b) { return a + b; }, 0);
16990
17100
  }
16991
17101
  // export function getPathArea(pathArray: AbsoluteArray) {
16992
17102
  // let x = 0;
@@ -17025,17 +17135,18 @@
17025
17135
  return pathLengthFactory(pathInput, distance).point;
17026
17136
  }
17027
17137
 
17028
- function splitCubic(pts, t = 0.5) {
17029
- const p0 = pts.slice(0, 2);
17030
- const p1 = pts.slice(2, 4);
17031
- const p2 = pts.slice(4, 6);
17032
- const p3 = pts.slice(6, 8);
17033
- const p4 = midPoint(p0, p1, t);
17034
- const p5 = midPoint(p1, p2, t);
17035
- const p6 = midPoint(p2, p3, t);
17036
- const p7 = midPoint(p4, p5, t);
17037
- const p8 = midPoint(p5, p6, t);
17038
- const p9 = midPoint(p7, p8, t);
17138
+ function splitCubic(pts, t) {
17139
+ if (t === void 0) { t = 0.5; }
17140
+ var p0 = pts.slice(0, 2);
17141
+ var p1 = pts.slice(2, 4);
17142
+ var p2 = pts.slice(4, 6);
17143
+ var p3 = pts.slice(6, 8);
17144
+ var p4 = midPoint(p0, p1, t);
17145
+ var p5 = midPoint(p1, p2, t);
17146
+ var p6 = midPoint(p2, p3, t);
17147
+ var p7 = midPoint(p4, p5, t);
17148
+ var p8 = midPoint(p5, p6, t);
17149
+ var p9 = midPoint(p7, p8, t);
17039
17150
  return [
17040
17151
  // @ts-ignore
17041
17152
  ['C'].concat(p4, p7, p9),
@@ -17044,12 +17155,12 @@
17044
17155
  ];
17045
17156
  }
17046
17157
  function getCurveArray(segments) {
17047
- return segments.map((segment, i, pathArray) => {
17158
+ return segments.map(function (segment, i, pathArray) {
17048
17159
  // @ts-ignore
17049
- const segmentData = i && pathArray[i - 1].slice(-2).concat(segment.slice(1));
17160
+ var segmentData = i && pathArray[i - 1].slice(-2).concat(segment.slice(1));
17050
17161
  // @ts-ignore
17051
- const curveLength = i ? segmentCubicFactory(...segmentData).length : 0;
17052
- let subsegs;
17162
+ var curveLength = i ? segmentCubicFactory.apply(void 0, segmentData).length : 0;
17163
+ var subsegs;
17053
17164
  if (i) {
17054
17165
  // must be [segment,segment]
17055
17166
  subsegs = curveLength ? splitCubic(segmentData) : [segment, segment];
@@ -17065,33 +17176,40 @@
17065
17176
  });
17066
17177
  }
17067
17178
  function equalizeSegments(path1, path2, TL) {
17068
- const c1 = getCurveArray(path1);
17069
- const c2 = getCurveArray(path2);
17070
- const L1 = c1.length;
17071
- const L2 = c2.length;
17072
- const l1 = c1.filter((x) => x.l).length;
17073
- const l2 = c2.filter((x) => x.l).length;
17074
- const m1 = c1.filter((x) => x.l).reduce((a, { l }) => a + l, 0) / l1 || 0;
17075
- const m2 = c2.filter((x) => x.l).reduce((a, { l }) => a + l, 0) / l2 || 0;
17076
- const tl = TL || Math.max(L1, L2);
17077
- const mm = [m1, m2];
17078
- const dif = [tl - L1, tl - L2];
17079
- let canSplit = 0;
17080
- const result = [c1, c2].map((x, i) =>
17081
- // @ts-ignore
17082
- x.l === tl
17083
- ? x.map((y) => y.s)
17084
- : x
17085
- .map((y, j) => {
17086
- canSplit = j && dif[i] && y.l >= mm[i];
17087
- dif[i] -= canSplit ? 1 : 0;
17088
- return canSplit ? y.ss : [y.s];
17089
- })
17090
- .flat());
17179
+ var c1 = getCurveArray(path1);
17180
+ var c2 = getCurveArray(path2);
17181
+ var L1 = c1.length;
17182
+ var L2 = c2.length;
17183
+ var l1 = c1.filter(function (x) { return x.l; }).length;
17184
+ var l2 = c2.filter(function (x) { return x.l; }).length;
17185
+ var m1 = c1.filter(function (x) { return x.l; }).reduce(function (a, _a) {
17186
+ var l = _a.l;
17187
+ return a + l;
17188
+ }, 0) / l1 || 0;
17189
+ var m2 = c2.filter(function (x) { return x.l; }).reduce(function (a, _a) {
17190
+ var l = _a.l;
17191
+ return a + l;
17192
+ }, 0) / l2 || 0;
17193
+ var tl = TL || Math.max(L1, L2);
17194
+ var mm = [m1, m2];
17195
+ var dif = [tl - L1, tl - L2];
17196
+ var canSplit = 0;
17197
+ var result = [c1, c2].map(function (x, i) {
17198
+ // @ts-ignore
17199
+ return x.l === tl
17200
+ ? x.map(function (y) { return y.s; })
17201
+ : x
17202
+ .map(function (y, j) {
17203
+ canSplit = j && dif[i] && y.l >= mm[i];
17204
+ dif[i] -= canSplit ? 1 : 0;
17205
+ return canSplit ? y.ss : [y.s];
17206
+ })
17207
+ .flat();
17208
+ });
17091
17209
  return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
17092
17210
  }
17093
17211
 
17094
- function parsePath(path, object) {
17212
+ var memoizedParsePath = memoize(function (path) {
17095
17213
  var absolutePath;
17096
17214
 
17097
17215
  try {
@@ -17123,11 +17241,6 @@
17123
17241
  height = _getPathBBoxTotalLeng.height,
17124
17242
  length = _getPathBBoxTotalLeng.length;
17125
17243
 
17126
- if (object) {
17127
- object.parsedStyle.defX = x;
17128
- object.parsedStyle.defY = y;
17129
- }
17130
-
17131
17244
  return {
17132
17245
  absolutePath: absolutePath,
17133
17246
  hasArc: hasArc,
@@ -17139,6 +17252,18 @@
17139
17252
  zCommandIndexes: zCommandIndexes,
17140
17253
  rect: new Rectangle(x, y, width, height)
17141
17254
  };
17255
+ }, function (path) {
17256
+ return isString(path) ? path : path2String(path);
17257
+ });
17258
+ function parsePath(path, object) {
17259
+ var result = memoizedParsePath(path);
17260
+
17261
+ if (object) {
17262
+ object.parsedStyle.defX = result.rect.x;
17263
+ object.parsedStyle.defY = result.rect.y;
17264
+ }
17265
+
17266
+ return result;
17142
17267
  }
17143
17268
  function mergePaths(left, right, object) {
17144
17269
  var curve1 = left.curve;
@@ -17589,6 +17714,463 @@
17589
17714
  return [];
17590
17715
  }
17591
17716
 
17717
+ var normalize$4 = function normalize(out, mat) {
17718
+ var m44 = mat[15];
17719
+ // Cannot normalize.
17720
+ if (m44 === 0)
17721
+ return false
17722
+ var scale = 1 / m44;
17723
+ for (var i=0; i<16; i++)
17724
+ out[i] = mat[i] * scale;
17725
+ return true
17726
+ };
17727
+
17728
+ var create_1 = create$6;
17729
+
17730
+ /**
17731
+ * Creates a new identity mat4
17732
+ *
17733
+ * @returns {mat4} a new 4x4 matrix
17734
+ */
17735
+ function create$6() {
17736
+ var out = new Float32Array(16);
17737
+ out[0] = 1;
17738
+ out[1] = 0;
17739
+ out[2] = 0;
17740
+ out[3] = 0;
17741
+ out[4] = 0;
17742
+ out[5] = 1;
17743
+ out[6] = 0;
17744
+ out[7] = 0;
17745
+ out[8] = 0;
17746
+ out[9] = 0;
17747
+ out[10] = 1;
17748
+ out[11] = 0;
17749
+ out[12] = 0;
17750
+ out[13] = 0;
17751
+ out[14] = 0;
17752
+ out[15] = 1;
17753
+ return out;
17754
+ }
17755
+
17756
+ var clone_1 = clone$2;
17757
+
17758
+ /**
17759
+ * Creates a new mat4 initialized with values from an existing matrix
17760
+ *
17761
+ * @param {mat4} a matrix to clone
17762
+ * @returns {mat4} a new 4x4 matrix
17763
+ */
17764
+ function clone$2(a) {
17765
+ var out = new Float32Array(16);
17766
+ out[0] = a[0];
17767
+ out[1] = a[1];
17768
+ out[2] = a[2];
17769
+ out[3] = a[3];
17770
+ out[4] = a[4];
17771
+ out[5] = a[5];
17772
+ out[6] = a[6];
17773
+ out[7] = a[7];
17774
+ out[8] = a[8];
17775
+ out[9] = a[9];
17776
+ out[10] = a[10];
17777
+ out[11] = a[11];
17778
+ out[12] = a[12];
17779
+ out[13] = a[13];
17780
+ out[14] = a[14];
17781
+ out[15] = a[15];
17782
+ return out;
17783
+ }
17784
+
17785
+ var determinant_1 = determinant;
17786
+
17787
+ /**
17788
+ * Calculates the determinant of a mat4
17789
+ *
17790
+ * @param {mat4} a the source matrix
17791
+ * @returns {Number} determinant of a
17792
+ */
17793
+ function determinant(a) {
17794
+ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
17795
+ a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
17796
+ a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
17797
+ a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
17798
+
17799
+ b00 = a00 * a11 - a01 * a10,
17800
+ b01 = a00 * a12 - a02 * a10,
17801
+ b02 = a00 * a13 - a03 * a10,
17802
+ b03 = a01 * a12 - a02 * a11,
17803
+ b04 = a01 * a13 - a03 * a11,
17804
+ b05 = a02 * a13 - a03 * a12,
17805
+ b06 = a20 * a31 - a21 * a30,
17806
+ b07 = a20 * a32 - a22 * a30,
17807
+ b08 = a20 * a33 - a23 * a30,
17808
+ b09 = a21 * a32 - a22 * a31,
17809
+ b10 = a21 * a33 - a23 * a31,
17810
+ b11 = a22 * a33 - a23 * a32;
17811
+
17812
+ // Calculate the determinant
17813
+ return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
17814
+ }
17815
+
17816
+ var invert_1 = invert$2;
17817
+
17818
+ /**
17819
+ * Inverts a mat4
17820
+ *
17821
+ * @param {mat4} out the receiving matrix
17822
+ * @param {mat4} a the source matrix
17823
+ * @returns {mat4} out
17824
+ */
17825
+ function invert$2(out, a) {
17826
+ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
17827
+ a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
17828
+ a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
17829
+ a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
17830
+
17831
+ b00 = a00 * a11 - a01 * a10,
17832
+ b01 = a00 * a12 - a02 * a10,
17833
+ b02 = a00 * a13 - a03 * a10,
17834
+ b03 = a01 * a12 - a02 * a11,
17835
+ b04 = a01 * a13 - a03 * a11,
17836
+ b05 = a02 * a13 - a03 * a12,
17837
+ b06 = a20 * a31 - a21 * a30,
17838
+ b07 = a20 * a32 - a22 * a30,
17839
+ b08 = a20 * a33 - a23 * a30,
17840
+ b09 = a21 * a32 - a22 * a31,
17841
+ b10 = a21 * a33 - a23 * a31,
17842
+ b11 = a22 * a33 - a23 * a32,
17843
+
17844
+ // Calculate the determinant
17845
+ det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
17846
+
17847
+ if (!det) {
17848
+ return null;
17849
+ }
17850
+ det = 1.0 / det;
17851
+
17852
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
17853
+ out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
17854
+ out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
17855
+ out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
17856
+ out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
17857
+ out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
17858
+ out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
17859
+ out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
17860
+ out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
17861
+ out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
17862
+ out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
17863
+ out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
17864
+ out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
17865
+ out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
17866
+ out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
17867
+ out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
17868
+
17869
+ return out;
17870
+ }
17871
+
17872
+ var transpose_1 = transpose;
17873
+
17874
+ /**
17875
+ * Transpose the values of a mat4
17876
+ *
17877
+ * @param {mat4} out the receiving matrix
17878
+ * @param {mat4} a the source matrix
17879
+ * @returns {mat4} out
17880
+ */
17881
+ function transpose(out, a) {
17882
+ // If we are transposing ourselves we can skip a few steps but have to cache some values
17883
+ if (out === a) {
17884
+ var a01 = a[1], a02 = a[2], a03 = a[3],
17885
+ a12 = a[6], a13 = a[7],
17886
+ a23 = a[11];
17887
+
17888
+ out[1] = a[4];
17889
+ out[2] = a[8];
17890
+ out[3] = a[12];
17891
+ out[4] = a01;
17892
+ out[6] = a[9];
17893
+ out[7] = a[13];
17894
+ out[8] = a02;
17895
+ out[9] = a12;
17896
+ out[11] = a[14];
17897
+ out[12] = a03;
17898
+ out[13] = a13;
17899
+ out[14] = a23;
17900
+ } else {
17901
+ out[0] = a[0];
17902
+ out[1] = a[4];
17903
+ out[2] = a[8];
17904
+ out[3] = a[12];
17905
+ out[4] = a[1];
17906
+ out[5] = a[5];
17907
+ out[6] = a[9];
17908
+ out[7] = a[13];
17909
+ out[8] = a[2];
17910
+ out[9] = a[6];
17911
+ out[10] = a[10];
17912
+ out[11] = a[14];
17913
+ out[12] = a[3];
17914
+ out[13] = a[7];
17915
+ out[14] = a[11];
17916
+ out[15] = a[15];
17917
+ }
17918
+
17919
+ return out;
17920
+ }
17921
+
17922
+ var length_1 = length$1;
17923
+
17924
+ /**
17925
+ * Calculates the length of a vec3
17926
+ *
17927
+ * @param {vec3} a vector to calculate length of
17928
+ * @returns {Number} length of a
17929
+ */
17930
+ function length$1(a) {
17931
+ var x = a[0],
17932
+ y = a[1],
17933
+ z = a[2];
17934
+ return Math.sqrt(x*x + y*y + z*z)
17935
+ }
17936
+
17937
+ var normalize_1 = normalize$5;
17938
+
17939
+ /**
17940
+ * Normalize a vec3
17941
+ *
17942
+ * @param {vec3} out the receiving vector
17943
+ * @param {vec3} a vector to normalize
17944
+ * @returns {vec3} out
17945
+ */
17946
+ function normalize$5(out, a) {
17947
+ var x = a[0],
17948
+ y = a[1],
17949
+ z = a[2];
17950
+ var len = x*x + y*y + z*z;
17951
+ if (len > 0) {
17952
+ //TODO: evaluate use of glm_invsqrt here?
17953
+ len = 1 / Math.sqrt(len);
17954
+ out[0] = a[0] * len;
17955
+ out[1] = a[1] * len;
17956
+ out[2] = a[2] * len;
17957
+ }
17958
+ return out
17959
+ }
17960
+
17961
+ var dot_1 = dot$2;
17962
+
17963
+ /**
17964
+ * Calculates the dot product of two vec3's
17965
+ *
17966
+ * @param {vec3} a the first operand
17967
+ * @param {vec3} b the second operand
17968
+ * @returns {Number} dot product of a and b
17969
+ */
17970
+ function dot$2(a, b) {
17971
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
17972
+ }
17973
+
17974
+ var cross_1 = cross$1;
17975
+
17976
+ /**
17977
+ * Computes the cross product of two vec3's
17978
+ *
17979
+ * @param {vec3} out the receiving vector
17980
+ * @param {vec3} a the first operand
17981
+ * @param {vec3} b the second operand
17982
+ * @returns {vec3} out
17983
+ */
17984
+ function cross$1(out, a, b) {
17985
+ var ax = a[0], ay = a[1], az = a[2],
17986
+ bx = b[0], by = b[1], bz = b[2];
17987
+
17988
+ out[0] = ay * bz - az * by;
17989
+ out[1] = az * bx - ax * bz;
17990
+ out[2] = ax * by - ay * bx;
17991
+ return out
17992
+ }
17993
+
17994
+ /*jshint unused:true*/
17995
+ /*
17996
+ Input: matrix ; a 4x4 matrix
17997
+ Output: translation ; a 3 component vector
17998
+ scale ; a 3 component vector
17999
+ skew ; skew factors XY,XZ,YZ represented as a 3 component vector
18000
+ perspective ; a 4 component vector
18001
+ quaternion ; a 4 component vector
18002
+ Returns false if the matrix cannot be decomposed, true if it can
18003
+
18004
+
18005
+ References:
18006
+ https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
18007
+ https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
18008
+ http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
18009
+ */
18010
+
18011
+
18012
+
18013
+
18014
+
18015
+
18016
+
18017
+
18018
+ var vec3 = {
18019
+ length: length_1,
18020
+ normalize: normalize_1,
18021
+ dot: dot_1,
18022
+ cross: cross_1
18023
+ };
18024
+
18025
+ var tmp = create_1();
18026
+ var perspectiveMatrix = create_1();
18027
+ var tmpVec4 = [0, 0, 0, 0];
18028
+ var row = [ [0,0,0], [0,0,0], [0,0,0] ];
18029
+ var pdum3 = [0,0,0];
18030
+
18031
+ var mat4Decompose = function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
18032
+ if (!translation) translation = [0,0,0];
18033
+ if (!scale) scale = [0,0,0];
18034
+ if (!skew) skew = [0,0,0];
18035
+ if (!perspective) perspective = [0,0,0,1];
18036
+ if (!quaternion) quaternion = [0,0,0,1];
18037
+
18038
+ //normalize, if not possible then bail out early
18039
+ if (!normalize$4(tmp, matrix))
18040
+ return false
18041
+
18042
+ // perspectiveMatrix is used to solve for perspective, but it also provides
18043
+ // an easy way to test for singularity of the upper 3x3 component.
18044
+ clone_1(perspectiveMatrix);
18045
+
18046
+ perspectiveMatrix[3] = 0;
18047
+ perspectiveMatrix[7] = 0;
18048
+ perspectiveMatrix[11] = 0;
18049
+ perspectiveMatrix[15] = 1;
18050
+
18051
+ // If the perspectiveMatrix is not invertible, we are also unable to
18052
+ // decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
18053
+ if (Math.abs(determinant_1(perspectiveMatrix) < 1e-8))
18054
+ return false
18055
+
18056
+ var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11],
18057
+ a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
18058
+
18059
+ // First, isolate perspective.
18060
+ if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
18061
+ tmpVec4[0] = a03;
18062
+ tmpVec4[1] = a13;
18063
+ tmpVec4[2] = a23;
18064
+ tmpVec4[3] = a33;
18065
+
18066
+ // Solve the equation by inverting perspectiveMatrix and multiplying
18067
+ // rightHandSide by the inverse.
18068
+ // resuing the perspectiveMatrix here since it's no longer needed
18069
+ var ret = invert_1(perspectiveMatrix, perspectiveMatrix);
18070
+ if (!ret) return false
18071
+ transpose_1(perspectiveMatrix, perspectiveMatrix);
18072
+
18073
+ //multiply by transposed inverse perspective matrix, into perspective vec4
18074
+ vec4multMat4(perspective, tmpVec4, perspectiveMatrix);
18075
+ } else {
18076
+ //no perspective
18077
+ perspective[0] = perspective[1] = perspective[2] = 0;
18078
+ perspective[3] = 1;
18079
+ }
18080
+
18081
+ // Next take care of translation
18082
+ translation[0] = a30;
18083
+ translation[1] = a31;
18084
+ translation[2] = a32;
18085
+
18086
+ // Now get scale and shear. 'row' is a 3 element array of 3 component vectors
18087
+ mat3from4(row, tmp);
18088
+
18089
+ // Compute X scale factor and normalize first row.
18090
+ scale[0] = vec3.length(row[0]);
18091
+ vec3.normalize(row[0], row[0]);
18092
+
18093
+ // Compute XY shear factor and make 2nd row orthogonal to 1st.
18094
+ skew[0] = vec3.dot(row[0], row[1]);
18095
+ combine(row[1], row[1], row[0], 1.0, -skew[0]);
18096
+
18097
+ // Now, compute Y scale and normalize 2nd row.
18098
+ scale[1] = vec3.length(row[1]);
18099
+ vec3.normalize(row[1], row[1]);
18100
+ skew[0] /= scale[1];
18101
+
18102
+ // Compute XZ and YZ shears, orthogonalize 3rd row
18103
+ skew[1] = vec3.dot(row[0], row[2]);
18104
+ combine(row[2], row[2], row[0], 1.0, -skew[1]);
18105
+ skew[2] = vec3.dot(row[1], row[2]);
18106
+ combine(row[2], row[2], row[1], 1.0, -skew[2]);
18107
+
18108
+ // Next, get Z scale and normalize 3rd row.
18109
+ scale[2] = vec3.length(row[2]);
18110
+ vec3.normalize(row[2], row[2]);
18111
+ skew[1] /= scale[2];
18112
+ skew[2] /= scale[2];
18113
+
18114
+
18115
+ // At this point, the matrix (in rows) is orthonormal.
18116
+ // Check for a coordinate system flip. If the determinant
18117
+ // is -1, then negate the matrix and the scaling factors.
18118
+ vec3.cross(pdum3, row[1], row[2]);
18119
+ if (vec3.dot(row[0], pdum3) < 0) {
18120
+ for (var i = 0; i < 3; i++) {
18121
+ scale[i] *= -1;
18122
+ row[i][0] *= -1;
18123
+ row[i][1] *= -1;
18124
+ row[i][2] *= -1;
18125
+ }
18126
+ }
18127
+
18128
+ // Now, get the rotations out
18129
+ quaternion[0] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
18130
+ quaternion[1] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
18131
+ quaternion[2] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
18132
+ quaternion[3] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
18133
+
18134
+ if (row[2][1] > row[1][2])
18135
+ quaternion[0] = -quaternion[0];
18136
+ if (row[0][2] > row[2][0])
18137
+ quaternion[1] = -quaternion[1];
18138
+ if (row[1][0] > row[0][1])
18139
+ quaternion[2] = -quaternion[2];
18140
+ return true
18141
+ };
18142
+
18143
+ //will be replaced by gl-vec4 eventually
18144
+ function vec4multMat4(out, a, m) {
18145
+ var x = a[0], y = a[1], z = a[2], w = a[3];
18146
+ out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
18147
+ out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
18148
+ out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
18149
+ out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
18150
+ return out;
18151
+ }
18152
+
18153
+ //gets upper-left of a 4x4 matrix into a 3x3 of vectors
18154
+ function mat3from4(out, mat4x4) {
18155
+ out[0][0] = mat4x4[0];
18156
+ out[0][1] = mat4x4[1];
18157
+ out[0][2] = mat4x4[2];
18158
+
18159
+ out[1][0] = mat4x4[4];
18160
+ out[1][1] = mat4x4[5];
18161
+ out[1][2] = mat4x4[6];
18162
+
18163
+ out[2][0] = mat4x4[8];
18164
+ out[2][1] = mat4x4[9];
18165
+ out[2][2] = mat4x4[10];
18166
+ }
18167
+
18168
+ function combine(out, a, b, scale1, scale2) {
18169
+ out[0] = a[0] * scale1 + b[0] * scale2;
18170
+ out[1] = a[1] * scale1 + b[1] * scale2;
18171
+ out[2] = a[2] * scale1 + b[2] * scale2;
18172
+ }
18173
+
17592
18174
  /**
17593
18175
  * holds useful CSS-related methods.
17594
18176
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
@@ -17728,22 +18310,23 @@
17728
18310
 
17729
18311
 
17730
18312
  var transformFunctions = {
17731
- // matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
17732
- // matrix3d: ['NNNNNNNNNNNNNNNN', id],
18313
+ // @ts-ignore
18314
+ matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id$1],
18315
+ matrix3d: ['NNNNNNNNNNNNNNNN', id$1],
17733
18316
  rotate: ['A'],
17734
18317
  rotatex: ['A'],
17735
18318
  rotatey: ['A'],
17736
18319
  rotatez: ['A'],
17737
18320
  rotate3d: ['NNNA'],
17738
- // perspective: ['L'],
18321
+ perspective: ['L'],
17739
18322
  scale: ['Nn', cast([_, _, CSS.number(1)]), id$1],
17740
18323
  scalex: ['N', cast([_, CSS.number(1), CSS.number(1)]), cast([_, CSS.number(1)])],
17741
18324
  scaley: ['N', cast([CSS.number(1), _, CSS.number(1)]), cast([CSS.number(1), _])],
17742
18325
  scalez: ['N', cast([CSS.number(1), CSS.number(1), _])],
17743
18326
  scale3d: ['NNN', id$1],
17744
- // skew: ['Aa', null, id],
17745
- // skewx: ['A', null, cast([_, Odeg])],
17746
- // skewy: ['A', null, cast([Odeg, _])],
18327
+ skew: ['Aa', null, id$1],
18328
+ skewx: ['A', null, cast([_, Odeg])],
18329
+ skewy: ['A', null, cast([Odeg, _])],
17747
18330
  translate: ['Tt', cast([_, _, Opx]), id$1],
17748
18331
  translatex: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
17749
18332
  translatey: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
@@ -17836,33 +18419,289 @@
17836
18419
  }
17837
18420
 
17838
18421
  return [];
17839
- } // function mergeMatrices(left: number[][], right: number[][]): [
17840
- // number[][], number[][], () => string,
17841
- // ] {
17842
- // if (left.decompositionPair !== right) {
17843
- // left.decompositionPair = right;
17844
- // var leftArgs = makeMatrixDecomposition(left);
17845
- // }
17846
- // if (right.decompositionPair !== left) {
17847
- // right.decompositionPair = left;
17848
- // var rightArgs = makeMatrixDecomposition(right);
17849
- // }
17850
- // if (leftArgs[0] === null || rightArgs[0] === null)
17851
- // return [[false], [true], (x) => { return x ? right[0].d : left[0].d; }];
17852
- // leftArgs[0].push(0);
17853
- // rightArgs[0].push(1);
17854
- // return [
17855
- // leftArgs,
17856
- // rightArgs,
17857
- // (list) => {
17858
- // const q = quat(leftArgs[0][3], rightArgs[0][3], list[5]);
17859
- // const mat = composeMatrix(list[0], list[1], list[2], q, list[4]);
17860
- // const stringifiedArgs = mat.map(numberToLongString).join(',');
17861
- // return stringifiedArgs;
17862
- // }
17863
- // ];
17864
- // }
17865
- // scalex/y/z -> scale
18422
+ }
18423
+ function convertItemToMatrix(item) {
18424
+ var x;
18425
+ var y;
18426
+ var z;
18427
+ var angle;
18428
+
18429
+ switch (item.t) {
18430
+ case 'rotatex':
18431
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18432
+ return [1, 0, 0, 0, 0, Math.cos(angle), Math.sin(angle), 0, 0, -Math.sin(angle), Math.cos(angle), 0, 0, 0, 0, 1];
18433
+
18434
+ case 'rotatey':
18435
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18436
+ return [Math.cos(angle), 0, -Math.sin(angle), 0, 0, 1, 0, 0, Math.sin(angle), 0, Math.cos(angle), 0, 0, 0, 0, 1];
18437
+
18438
+ case 'rotate':
18439
+ case 'rotatez':
18440
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18441
+ return [Math.cos(angle), Math.sin(angle), 0, 0, -Math.sin(angle), Math.cos(angle), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18442
+
18443
+ case 'rotate3d':
18444
+ x = item.d[0].value;
18445
+ y = item.d[1].value;
18446
+ z = item.d[2].value;
18447
+ angle = deg2rad(convertAngleUnit(item.d[3]));
18448
+ var sqrLength = x * x + y * y + z * z;
18449
+
18450
+ if (sqrLength === 0) {
18451
+ x = 1;
18452
+ y = 0;
18453
+ z = 0;
18454
+ } else if (sqrLength !== 1) {
18455
+ var length = Math.sqrt(sqrLength);
18456
+ x /= length;
18457
+ y /= length;
18458
+ z /= length;
18459
+ }
18460
+
18461
+ var s = Math.sin(angle / 2);
18462
+ var sc = s * Math.cos(angle / 2);
18463
+ var sq = s * s;
18464
+ return [1 - 2 * (y * y + z * z) * sq, 2 * (x * y * sq + z * sc), 2 * (x * z * sq - y * sc), 0, 2 * (x * y * sq - z * sc), 1 - 2 * (x * x + z * z) * sq, 2 * (y * z * sq + x * sc), 0, 2 * (x * z * sq + y * sc), 2 * (y * z * sq - x * sc), 1 - 2 * (x * x + y * y) * sq, 0, 0, 0, 0, 1];
18465
+
18466
+ case 'scale':
18467
+ return [item.d[0].value, 0, 0, 0, 0, item.d[1].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18468
+
18469
+ case 'scalex':
18470
+ return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18471
+
18472
+ case 'scaley':
18473
+ return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18474
+
18475
+ case 'scalez':
18476
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
18477
+
18478
+ case 'scale3d':
18479
+ return [item.d[0].value, 0, 0, 0, 0, item.d[1].value, 0, 0, 0, 0, item.d[2].value, 0, 0, 0, 0, 1];
18480
+
18481
+ case 'skew':
18482
+ var xAngle = deg2rad(convertAngleUnit(item.d[0]));
18483
+ var yAngle = deg2rad(convertAngleUnit(item.d[1]));
18484
+ return [1, Math.tan(yAngle), 0, 0, Math.tan(xAngle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18485
+
18486
+ case 'skewx':
18487
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18488
+ return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18489
+
18490
+ case 'skewy':
18491
+ angle = deg2rad(convertAngleUnit(item.d[0]));
18492
+ return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18493
+
18494
+ case 'translate':
18495
+ // TODO: pass target
18496
+ x = convertPercentUnit(item.d[0], 0, null) || 0;
18497
+ y = convertPercentUnit(item.d[1], 0, null) || 0;
18498
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
18499
+
18500
+ case 'translatex':
18501
+ x = convertPercentUnit(item.d[0], 0, null) || 0;
18502
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
18503
+
18504
+ case 'translatey':
18505
+ y = convertPercentUnit(item.d[0], 0, null) || 0;
18506
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
18507
+
18508
+ case 'translatez':
18509
+ z = convertPercentUnit(item.d[0], 0, null) || 0;
18510
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
18511
+
18512
+ case 'translate3d':
18513
+ x = convertPercentUnit(item.d[0], 0, null) || 0;
18514
+ y = convertPercentUnit(item.d[1], 0, null) || 0;
18515
+ z = convertPercentUnit(item.d[2], 0, null) || 0;
18516
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1];
18517
+
18518
+ case 'perspective':
18519
+ var t = convertPercentUnit(item.d[0], 0, null) || 0;
18520
+ var p = t ? -1 / t : 0;
18521
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, p, 0, 0, 0, 1];
18522
+
18523
+ case 'matrix':
18524
+ return [item.d[0].value, item.d[1].value, 0, 0, item.d[2].value, item.d[3].value, 0, 0, 0, 0, 1, 0, item.d[4].value, item.d[5].value, 0, 1];
18525
+
18526
+ case 'matrix3d':
18527
+ return item.d.map(function (d) {
18528
+ return d.value;
18529
+ });
18530
+ }
18531
+ }
18532
+
18533
+ function multiplyMatrices(a, b) {
18534
+ return [a[0] * b[0] + a[4] * b[1] + a[8] * b[2] + a[12] * b[3], a[1] * b[0] + a[5] * b[1] + a[9] * b[2] + a[13] * b[3], a[2] * b[0] + a[6] * b[1] + a[10] * b[2] + a[14] * b[3], a[3] * b[0] + a[7] * b[1] + a[11] * b[2] + a[15] * b[3], a[0] * b[4] + a[4] * b[5] + a[8] * b[6] + a[12] * b[7], a[1] * b[4] + a[5] * b[5] + a[9] * b[6] + a[13] * b[7], a[2] * b[4] + a[6] * b[5] + a[10] * b[6] + a[14] * b[7], a[3] * b[4] + a[7] * b[5] + a[11] * b[6] + a[15] * b[7], a[0] * b[8] + a[4] * b[9] + a[8] * b[10] + a[12] * b[11], a[1] * b[8] + a[5] * b[9] + a[9] * b[10] + a[13] * b[11], a[2] * b[8] + a[6] * b[9] + a[10] * b[10] + a[14] * b[11], a[3] * b[8] + a[7] * b[9] + a[11] * b[10] + a[15] * b[11], a[0] * b[12] + a[4] * b[13] + a[8] * b[14] + a[12] * b[15], a[1] * b[12] + a[5] * b[13] + a[9] * b[14] + a[13] * b[15], a[2] * b[12] + a[6] * b[13] + a[10] * b[14] + a[14] * b[15], a[3] * b[12] + a[7] * b[13] + a[11] * b[14] + a[15] * b[15]];
18535
+ }
18536
+
18537
+ function convertToMatrix(transformList) {
18538
+ if (transformList.length === 0) {
18539
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
18540
+ }
18541
+
18542
+ return transformList.map(convertItemToMatrix).reduce(multiplyMatrices);
18543
+ }
18544
+
18545
+ function makeMatrixDecomposition(transformList) {
18546
+ var translate = [0, 0, 0];
18547
+ var scale = [0, 0, 0];
18548
+ var skew = [0, 0, 0];
18549
+ var perspective = [0, 0, 0, 1];
18550
+ var quaternion = [0, 0, 0, 1];
18551
+ mat4Decompose(convertToMatrix(transformList), translate, scale, skew, perspective, quaternion);
18552
+ return [translate, scale, skew, quaternion, perspective];
18553
+ }
18554
+
18555
+ var composeMatrix = function () {
18556
+ function multiply(a, b) {
18557
+ var result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
18558
+
18559
+ for (var i = 0; i < 4; i++) {
18560
+ for (var j = 0; j < 4; j++) {
18561
+ for (var k = 0; k < 4; k++) {
18562
+ result[i][j] += b[i][k] * a[k][j];
18563
+ }
18564
+ }
18565
+ }
18566
+
18567
+ return result;
18568
+ }
18569
+
18570
+ function is2D(m) {
18571
+ return m[0][2] == 0 && m[0][3] == 0 && m[1][2] == 0 && m[1][3] == 0 && m[2][0] == 0 && m[2][1] == 0 && m[2][2] == 1 && m[2][3] == 0 && m[3][2] == 0 && m[3][3] == 1;
18572
+ }
18573
+
18574
+ function composeMatrix(translate, scale, skew, quat, perspective) {
18575
+ var matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
18576
+
18577
+ for (var i = 0; i < 4; i++) {
18578
+ matrix[i][3] = perspective[i];
18579
+ }
18580
+
18581
+ for (var _i = 0; _i < 3; _i++) {
18582
+ for (var j = 0; j < 3; j++) {
18583
+ matrix[3][_i] += translate[j] * matrix[j][_i];
18584
+ }
18585
+ }
18586
+
18587
+ var x = quat[0],
18588
+ y = quat[1],
18589
+ z = quat[2],
18590
+ w = quat[3];
18591
+ var rotMatrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
18592
+ rotMatrix[0][0] = 1 - 2 * (y * y + z * z);
18593
+ rotMatrix[0][1] = 2 * (x * y - z * w);
18594
+ rotMatrix[0][2] = 2 * (x * z + y * w);
18595
+ rotMatrix[1][0] = 2 * (x * y + z * w);
18596
+ rotMatrix[1][1] = 1 - 2 * (x * x + z * z);
18597
+ rotMatrix[1][2] = 2 * (y * z - x * w);
18598
+ rotMatrix[2][0] = 2 * (x * z - y * w);
18599
+ rotMatrix[2][1] = 2 * (y * z + x * w);
18600
+ rotMatrix[2][2] = 1 - 2 * (x * x + y * y);
18601
+ matrix = multiply(matrix, rotMatrix);
18602
+ var temp = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
18603
+
18604
+ if (skew[2]) {
18605
+ temp[2][1] = skew[2];
18606
+ matrix = multiply(matrix, temp);
18607
+ }
18608
+
18609
+ if (skew[1]) {
18610
+ temp[2][1] = 0;
18611
+ temp[2][0] = skew[0];
18612
+ matrix = multiply(matrix, temp);
18613
+ }
18614
+
18615
+ if (skew[0]) {
18616
+ temp[2][0] = 0;
18617
+ temp[1][0] = skew[0];
18618
+ matrix = multiply(matrix, temp);
18619
+ }
18620
+
18621
+ for (var _i2 = 0; _i2 < 3; _i2++) {
18622
+ for (var _j = 0; _j < 3; _j++) {
18623
+ matrix[_i2][_j] *= scale[_i2];
18624
+ }
18625
+ }
18626
+
18627
+ if (is2D(matrix)) {
18628
+ return [matrix[0][0], matrix[0][1], matrix[1][0], matrix[1][1], matrix[3][0], matrix[3][1]];
18629
+ }
18630
+
18631
+ return matrix[0].concat(matrix[1], matrix[2], matrix[3]);
18632
+ }
18633
+
18634
+ return composeMatrix;
18635
+ }();
18636
+
18637
+ function numberToLongString(x) {
18638
+ return x.toFixed(6).replace('.000000', '');
18639
+ }
18640
+
18641
+ function mergeMatrices(left, right) {
18642
+ var leftArgs;
18643
+ var rightArgs; // @ts-ignore
18644
+
18645
+ if (left.decompositionPair !== right) {
18646
+ // @ts-ignore
18647
+ left.decompositionPair = right;
18648
+ leftArgs = makeMatrixDecomposition(left);
18649
+ } // @ts-ignore
18650
+
18651
+
18652
+ if (right.decompositionPair !== left) {
18653
+ // @ts-ignore
18654
+ right.decompositionPair = left;
18655
+ rightArgs = makeMatrixDecomposition(right);
18656
+ }
18657
+
18658
+ if (leftArgs[0] === null || rightArgs[0] === null) return [// @ts-ignore
18659
+ [false], // @ts-ignore
18660
+ [true], // @ts-ignore
18661
+ function (x) {
18662
+ return x ? right[0].d : left[0].d;
18663
+ }];
18664
+ leftArgs[0].push(0);
18665
+ rightArgs[0].push(1);
18666
+ return [leftArgs, rightArgs, // @ts-ignore
18667
+ function (list) {
18668
+ // @ts-ignore
18669
+ var q = quat(leftArgs[0][3], rightArgs[0][3], list[5]);
18670
+ var mat = composeMatrix(list[0], list[1], list[2], q, list[4]);
18671
+ var stringifiedArgs = mat.map(numberToLongString).join(',');
18672
+ return stringifiedArgs;
18673
+ }];
18674
+ }
18675
+
18676
+ function dot$3(v1, v2) {
18677
+ var result = 0;
18678
+
18679
+ for (var i = 0; i < v1.length; i++) {
18680
+ result += v1[i] * v2[i];
18681
+ }
18682
+
18683
+ return result;
18684
+ }
18685
+
18686
+ function quat(fromQ, toQ, f) {
18687
+ var product = dot$3(fromQ, toQ);
18688
+ product = clamp(product, -1.0, 1.0);
18689
+ var quat = [];
18690
+
18691
+ if (product === 1.0) {
18692
+ quat = fromQ;
18693
+ } else {
18694
+ var theta = Math.acos(product);
18695
+ var w = Math.sin(f * theta) * 1 / Math.sqrt(1 - product * product);
18696
+
18697
+ for (var i = 0; i < 4; i++) {
18698
+ quat.push(fromQ[i] * (Math.cos(f * theta) - product * w) + toQ[i] * w);
18699
+ }
18700
+ }
18701
+
18702
+ return quat;
18703
+ } // scalex/y/z -> scale
18704
+
17866
18705
 
17867
18706
  function typeTo2D(type) {
17868
18707
  return type.replace(/[xy]/, '');
@@ -17892,7 +18731,7 @@
17892
18731
  type = _left$i.t,
17893
18732
  args = _left$i.d; // none -> scale(1)/translateX(0)
17894
18733
 
17895
- var defaultValue = type.substr(0, 5) === 'scale' ? 1 : 0;
18734
+ var defaultValue = type.substring(0, 5) === 'scale' ? 1 : 0;
17896
18735
  right.push({
17897
18736
  t: type,
17898
18737
  d: args.map(function (arg) {
@@ -17917,21 +18756,31 @@
17917
18756
  var rightResult = [];
17918
18757
  var types = []; // merge matrix() with matrix3d()
17919
18758
 
17920
- if (left.length !== right.length) ; else {
17921
- for (var _i = 0; _i < left.length; _i++) {
17922
- var leftType = left[_i].t;
17923
- var rightType = right[_i].t;
17924
- var leftArgs = left[_i].d;
17925
- var rightArgs = right[_i].d;
18759
+ if (left.length !== right.length) {
18760
+ var merged = mergeMatrices(left, right); // @ts-ignore
18761
+
18762
+ leftResult = [merged[0]]; // @ts-ignore
18763
+
18764
+ rightResult = [merged[1]];
18765
+ types = [['matrix', [merged[2]]]];
18766
+ } else {
18767
+ for (var _i3 = 0; _i3 < left.length; _i3++) {
18768
+ var leftType = left[_i3].t;
18769
+ var rightType = right[_i3].t;
18770
+ var leftArgs = left[_i3].d;
18771
+ var rightArgs = right[_i3].d;
17926
18772
  var leftFunctionData = transformFunctions[leftType];
17927
18773
  var rightFunctionData = transformFunctions[rightType];
17928
18774
  var type = void 0;
17929
18775
 
17930
18776
  if (isMatrixOrPerspective(leftType, rightType)) {
17931
- // const merged = mergeMatrices([left[i]], [right[i]]);
17932
- // leftResult.push(merged[0]);
17933
- // rightResult.push(merged[1]);
17934
- // types.push(['matrix', [merged[2]]]);
18777
+ var _merged = mergeMatrices([left[_i3]], [right[_i3]]); // @ts-ignore
18778
+
18779
+
18780
+ leftResult.push(_merged[0]); // @ts-ignore
18781
+
18782
+ rightResult.push(_merged[1]);
18783
+ types.push(['matrix', [_merged[2]]]);
17935
18784
  continue;
17936
18785
  } else if (leftType === rightType) {
17937
18786
  type = leftType;
@@ -17948,10 +18797,13 @@
17948
18797
 
17949
18798
  rightArgs = rightFunctionData[1](rightArgs);
17950
18799
  } else {
17951
- // const merged = mergeMatrices(left, right);
17952
- // leftResult = [merged[0]];
17953
- // rightResult = [merged[1]];
17954
- // types = [['matrix', [merged[2]]]];
18800
+ var _merged2 = mergeMatrices(left, right); // @ts-ignore
18801
+
18802
+
18803
+ leftResult = [_merged2[0]]; // @ts-ignore
18804
+
18805
+ rightResult = [_merged2[1]];
18806
+ types = [['matrix', [_merged2[2]]]];
17955
18807
  break;
17956
18808
  }
17957
18809
 
@@ -17962,10 +18814,11 @@
17962
18814
  for (var j = 0; j < leftArgs.length; j++) {
17963
18815
  var merge = leftArgs[j].unit === exports.UnitType.kNumber ? mergeNumbers : mergeDimensions; // @ts-ignore
17964
18816
 
17965
- var merged = merge(leftArgs[j], rightArgs[j], target, false, j);
17966
- leftArgsCopy[j] = merged[0];
17967
- rightArgsCopy[j] = merged[1];
17968
- stringConversions.push(merged[2]);
18817
+ var _merged3 = merge(leftArgs[j], rightArgs[j], target, false, j);
18818
+
18819
+ leftArgsCopy[j] = _merged3[0];
18820
+ rightArgsCopy[j] = _merged3[1];
18821
+ stringConversions.push(_merged3[2]);
17969
18822
  }
17970
18823
 
17971
18824
  leftResult.push(leftArgsCopy);
@@ -18106,8 +18959,8 @@
18106
18959
  */
18107
18960
 
18108
18961
  ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
18109
- ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
18110
- ElementEvent["GEOMETRY_BOUNDS_CHANGED"] = "geometry-bounds-changed";
18962
+ ElementEvent["BOUNDS_CHANGED"] = "bounds-changed"; // GEOMETRY_BOUNDS_CHANGED = 'geometry-bounds-changed',
18963
+
18111
18964
  /**
18112
18965
  * trigger when z-index changed
18113
18966
  */
@@ -18869,6 +19722,7 @@
18869
19722
  this.localRotation = fromValues$3(0, 0, 0, 1);
18870
19723
  this.localScale = fromValues$1(1, 1, 1);
18871
19724
  this.localTransform = create$1();
19725
+ this.localSkew = fromValues$4(0, 0);
18872
19726
  this.position = fromValues$1(0, 0, 0);
18873
19727
  this.rotation = fromValues$3(0, 0, 0, 1);
18874
19728
  this.scaling = fromValues$1(1, 1, 1);
@@ -20321,7 +21175,8 @@
20321
21175
  fontVariant: '',
20322
21176
  textAlign: '',
20323
21177
  textBaseline: '',
20324
- textTransform: ''
21178
+ textTransform: '',
21179
+ zIndex: ''
20325
21180
  };
20326
21181
  /**
20327
21182
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
@@ -20353,7 +21208,7 @@
20353
21208
  * push to active animations after calling `animate()`
20354
21209
  */
20355
21210
  function DisplayObject(config) {
20356
- var _this$config$capture, _this$config$zIndex, _this$config$interact;
21211
+ var _this$config$capture;
20357
21212
 
20358
21213
  var _this;
20359
21214
 
@@ -20377,10 +21232,7 @@
20377
21232
 
20378
21233
  _this.nodeName = _this.config.type || exports.Shape.GROUP; // compatible with G 3.0
20379
21234
 
20380
- _this.config.style = _extends({}, DEFAULT_STYLE_PROPS, {
20381
- zIndex: (_this$config$zIndex = _this.config.zIndex) !== null && _this$config$zIndex !== void 0 ? _this$config$zIndex : 0,
20382
- interactive: (_this$config$interact = _this.config.interactive) !== null && _this$config$interact !== void 0 ? _this$config$interact : true
20383
- }, _this.config.style, _this.config.attrs);
21235
+ _this.config.style = _extends({}, DEFAULT_STYLE_PROPS, _this.config.style, _this.config.attrs);
20384
21236
 
20385
21237
  if (_this.config.visible != null) {
20386
21238
  _this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
@@ -20511,8 +21363,8 @@
20511
21363
  var oldParsedValue = this.parsedStyle[name];
20512
21364
  this.styleValueRegistry.processProperties(this, (_this$styleValueRegis = {}, _this$styleValueRegis[name] = value, _this$styleValueRegis), parseOptions); // inform clip path targets
20513
21365
 
20514
- if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
20515
- this.attributes.clipPathTargets.forEach(function (target) {
21366
+ if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
21367
+ this.parsedStyle.clipPathTargets.forEach(function (target) {
20516
21368
  dirtifyToRoot(target);
20517
21369
  target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, target, _this2, _this2, 'clipPath', MutationEvent.MODIFICATION, _this2, _this2));
20518
21370
 
@@ -20782,6 +21634,11 @@
20782
21634
  return this;
20783
21635
  };
20784
21636
 
21637
+ _proto.setLocalSkew = function setLocalSkew(skew, y) {
21638
+ this.sceneGraphService.setLocalSkew(this, skew, y);
21639
+ return this;
21640
+ };
21641
+
20785
21642
  _proto.getRotation = function getRotation() {
20786
21643
  return this.sceneGraphService.getRotation(this);
20787
21644
  };
@@ -20790,6 +21647,10 @@
20790
21647
  return this.sceneGraphService.getLocalRotation(this);
20791
21648
  };
20792
21649
 
21650
+ _proto.getLocalSkew = function getLocalSkew() {
21651
+ return this.sceneGraphService.getLocalSkew(this);
21652
+ };
21653
+
20793
21654
  _proto.getLocalTransform = function getLocalTransform() {
20794
21655
  return this.sceneGraphService.getLocalTransform(this);
20795
21656
  };
@@ -20828,10 +21689,10 @@
20828
21689
 
20829
21690
  var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline; // account for clip path, use target's timeline
20830
21691
 
20831
- if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
21692
+ if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
20832
21693
  var _target$ownerDocument;
20833
21694
 
20834
- var target = this.attributes.clipPathTargets[0];
21695
+ var target = this.parsedStyle.clipPathTargets[0];
20835
21696
  timeline = (_target$ownerDocument = target.ownerDocument) === null || _target$ownerDocument === void 0 ? void 0 : _target$ownerDocument.timeline;
20836
21697
  } // clear old parsed transform
20837
21698
 
@@ -21237,9 +22098,7 @@
21237
22098
  style: _extends({
21238
22099
  cx: '',
21239
22100
  cy: '',
21240
- r: '',
21241
- anchor: '0.5 0.5',
21242
- transformOrigin: 'center'
22101
+ r: ''
21243
22102
  }, style)
21244
22103
  }, rest)) || this;
21245
22104
  }
@@ -21262,9 +22121,7 @@
21262
22121
  cx: '',
21263
22122
  cy: '',
21264
22123
  rx: '',
21265
- ry: '',
21266
- anchor: '0.5 0.5',
21267
- transformOrigin: 'center'
22124
+ ry: ''
21268
22125
  }, style)
21269
22126
  }, rest)) || this;
21270
22127
  }
@@ -23779,6 +24636,16 @@
23779
24636
  this.dirtifyLocal(element, transform);
23780
24637
  };
23781
24638
 
24639
+ _proto.setLocalSkew = function setLocalSkew(element, skew, y) {
24640
+ if (typeof skew === 'number') {
24641
+ skew = fromValues$4(skew, y);
24642
+ }
24643
+
24644
+ var transform = element.transformable;
24645
+ copy$4(transform.localSkew, skew);
24646
+ this.dirtifyLocal(element, transform);
24647
+ };
24648
+
23782
24649
  _proto.dirtifyLocal = function dirtifyLocal(element, transform) {
23783
24650
  if (!transform.localDirtyFlag) {
23784
24651
  transform.localDirtyFlag = true;
@@ -23842,11 +24709,37 @@
23842
24709
  return element.transformable.localScale;
23843
24710
  };
23844
24711
 
24712
+ _proto.getLocalSkew = function getLocalSkew(element) {
24713
+ return element.transformable.localSkew;
24714
+ };
24715
+
24716
+ _proto.calcLocalTransform = function calcLocalTransform(transform) {
24717
+ // @see https://github.com/mattdesl/css-mat4/blob/master/index.js
24718
+ // mat4.fromRotationTranslationScaleOrigin(
24719
+ // transform.localTransform,
24720
+ // transform.localRotation,
24721
+ // transform.localPosition,
24722
+ // transform.localScale,
24723
+ // transform.origin,
24724
+ // );
24725
+ fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, fromValues$1(1, 1, 1), transform.origin); // apply skew2D
24726
+
24727
+ if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
24728
+ var tmpMat4 = identity(create$1());
24729
+ tmpMat4[4] = Math.tan(transform.localSkew[0]);
24730
+ tmpMat4[1] = Math.tan(transform.localSkew[1]);
24731
+ multiply(transform.localTransform, transform.localTransform, tmpMat4);
24732
+ }
24733
+
24734
+ var scaling = fromRotationTranslationScaleOrigin(create$1(), fromValues$3(0, 0, 0, 1), create$2(), transform.localScale, transform.origin);
24735
+ multiply(transform.localTransform, transform.localTransform, scaling);
24736
+ };
24737
+
23845
24738
  _proto.getLocalTransform = function getLocalTransform(element) {
23846
24739
  var transform = element.transformable;
23847
24740
 
23848
24741
  if (transform.localDirtyFlag) {
23849
- fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
24742
+ this.calcLocalTransform(transform);
23850
24743
  transform.localDirtyFlag = false;
23851
24744
  }
23852
24745
 
@@ -23866,6 +24759,7 @@
23866
24759
  this.setLocalScale(element, [1, 1, 1]);
23867
24760
  this.setLocalPosition(element, [0, 0, 0]);
23868
24761
  this.setLocalEulerAngles(element, [0, 0, 0]);
24762
+ this.setLocalSkew(element, [0, 0]);
23869
24763
  };
23870
24764
 
23871
24765
  _proto.getTransformedGeometryBounds = function getTransformedGeometryBounds(element, render) {
@@ -23894,8 +24788,9 @@
23894
24788
  }
23895
24789
 
23896
24790
  var geometry = element.geometry;
23897
- var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
23898
- return bounds && new AABB(bounds.center, bounds.halfExtents) || new AABB();
24791
+ var bounds = render ? geometry.renderBounds : geometry.contentBounds || null; // return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
24792
+
24793
+ return bounds || new AABB();
23899
24794
  }
23900
24795
  /**
23901
24796
  * account for children in world space
@@ -24073,7 +24968,7 @@
24073
24968
 
24074
24969
  _proto.sync = function sync(element, transform) {
24075
24970
  if (transform.localDirtyFlag) {
24076
- fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
24971
+ this.calcLocalTransform(transform);
24077
24972
  transform.localDirtyFlag = false;
24078
24973
  }
24079
24974
 
@@ -27498,17 +28393,17 @@
27498
28393
  } // clear ref to old clip path
27499
28394
 
27500
28395
 
27501
- if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
27502
- var index = oldClipPath.style.clipPathTargets.indexOf(object);
27503
- oldClipPath.style.clipPathTargets.splice(index, 1);
28396
+ if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.parsedStyle.clipPathTargets) {
28397
+ var index = oldClipPath.parsedStyle.clipPathTargets.indexOf(object);
28398
+ oldClipPath.parsedStyle.clipPathTargets.splice(index, 1);
27504
28399
  }
27505
28400
 
27506
28401
  if (newClipPath) {
27507
- if (!newClipPath.style.clipPathTargets) {
27508
- newClipPath.style.clipPathTargets = [];
28402
+ if (!newClipPath.parsedStyle.clipPathTargets) {
28403
+ newClipPath.parsedStyle.clipPathTargets = [];
27509
28404
  }
27510
28405
 
27511
- newClipPath.style.clipPathTargets.push(object);
28406
+ newClipPath.parsedStyle.clipPathTargets.push(object);
27512
28407
  }
27513
28408
 
27514
28409
  dirtifyToRoot(object);
@@ -28125,9 +29020,9 @@
28125
29020
  // reset transform
28126
29021
  object.resetLocalTransform();
28127
29022
  object.setLocalPosition(defX, defY);
28128
- transform.forEach(function (_ref) {
28129
- var t = _ref.t,
28130
- d = _ref.d;
29023
+ transform.forEach(function (parsed) {
29024
+ var t = parsed.t,
29025
+ d = parsed.d;
28131
29026
 
28132
29027
  if (t === 'scale') {
28133
29028
  // scale(1) scale(1, 1)
@@ -28193,7 +29088,24 @@
28193
29088
  var _newAngles3 = d || [Odeg];
28194
29089
 
28195
29090
  object.rotateLocal(0, 0, _newAngles3[0].value);
28196
- } else ;
29091
+ } else if (t === 'rotate3d') ; else if (t === 'skew') {
29092
+ var newSkew = d.map(function (s) {
29093
+ return s.value;
29094
+ }) || [0, 0];
29095
+ object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
29096
+ } else if (t === 'skewx') {
29097
+ var _newSkew = d.map(function (s) {
29098
+ return s.value;
29099
+ }) || [0];
29100
+
29101
+ object.setLocalSkew(deg2rad(_newSkew[0]), object.getLocalSkew()[1]);
29102
+ } else if (t === 'skewy') {
29103
+ var _newSkew2 = d.map(function (s) {
29104
+ return s.value;
29105
+ }) || [0];
29106
+
29107
+ object.setLocalSkew(object.getLocalSkew()[0], deg2rad(_newSkew2[0]));
29108
+ }
28197
29109
  });
28198
29110
  }
28199
29111
  };
@@ -28448,13 +29360,25 @@
28448
29360
  name: 'transformOrigin',
28449
29361
  parsePriority: 100,
28450
29362
  // interpolable: true,
28451
- defaultValue: 'left top',
29363
+ defaultValue: function defaultValue(nodeName) {
29364
+ if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
29365
+ return 'center';
29366
+ }
29367
+
29368
+ return 'left top';
29369
+ },
28452
29370
  layoutDependent: true,
28453
29371
  syntax: exports.PropertySyntax.TRANSFORM_ORIGIN
28454
29372
  }, {
28455
29373
  name: 'anchor',
28456
29374
  parsePriority: 99,
28457
- defaultValue: '0 0',
29375
+ defaultValue: function defaultValue(nodeName) {
29376
+ if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
29377
+ return '0.5 0.5';
29378
+ }
29379
+
29380
+ return '0 0';
29381
+ },
28458
29382
  layoutDependent: true,
28459
29383
  syntax: exports.PropertySyntax.LENGTH_PERCENTAGE_12
28460
29384
  }, // <circle> & <ellipse>
@@ -28879,7 +29803,7 @@
28879
29803
  if (value === 'initial') {
28880
29804
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
28881
29805
  if (!isNil(defaultValue)) {
28882
- computed = this.parseProperty(name, defaultValue, object);
29806
+ computed = this.parseProperty(name, isFunction(defaultValue) ? defaultValue(object.nodeName) : defaultValue, object);
28883
29807
  }
28884
29808
  } else if (value === 'inherit') {
28885
29809
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
@@ -29119,8 +30043,8 @@
29119
30043
  var usedOriginYValue = (flipX ? -1 : 1) * convertPercentUnit(transformOrigin[1], 1, object);
29120
30044
  usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0].value || 0) * geometry.contentBounds.halfExtents[0] * 2;
29121
30045
  usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1].value || 0) * geometry.contentBounds.halfExtents[1] * 2;
29122
- object.setOrigin(usedOriginXValue, usedOriginYValue);
29123
- object.dispatchEvent(new CustomEvent(exports.ElementEvent.GEOMETRY_BOUNDS_CHANGED));
30046
+ object.setOrigin(usedOriginXValue, usedOriginYValue); // object.dispatchEvent(new CustomEvent(ElementEvent.GEOMETRY_BOUNDS_CHANGED));
30047
+
29124
30048
  dirtifyToRoot(object);
29125
30049
  }
29126
30050
  };
@@ -29320,7 +30244,7 @@
29320
30244
  * only dirty object will cause re-render
29321
30245
  */
29322
30246
  enableDirtyCheck: true,
29323
- enableCulling: true,
30247
+ enableCulling: false,
29324
30248
 
29325
30249
  /**
29326
30250
  * enable auto rendering by default
@@ -29394,26 +30318,29 @@
29394
30318
  _proto.apply = function apply(renderingService) {
29395
30319
  var _this = this;
29396
30320
 
29397
- // const strategies = this.strategyProvider.getContributions();
30321
+ var strategies = this.strategyProvider.getContributions();
29398
30322
  renderingService.hooks.cull.tap(CullingPlugin_1.tag, function (object) {
29399
30323
  if (object) {
29400
- var cullable = object.cullable;
29401
- cullable.visible = true; // // const renderBounds = object.getRenderBounds();
29402
- // // if (AABB.isEmpty(renderBounds)) {
29403
- // // cullable.visible = false;
29404
- // // } else {
29405
- // // const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
29406
- // // const [p0, p1, p2, p3] = camera.getFrustum().planes;
29407
- // // tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
29408
- // // cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
29409
- // // }
29410
- // if (strategies.length === 0) {
29411
- // cullable.visible = this.renderingContext.unculledEntities.indexOf(object.entity) > -1;
30324
+ var cullable = object.cullable; // cullable.visible = true;
30325
+ // const renderBounds = object.getRenderBounds();
30326
+ // if (AABB.isEmpty(renderBounds)) {
30327
+ // cullable.visible = false;
29412
30328
  // } else {
29413
- // // eg. implemented by g-webgl(frustum culling)
29414
- // cullable.visible = strategies.every((strategy) => strategy.isVisible(object));
30329
+ // const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
30330
+ // const [p0, p1, p2, p3] = camera.getFrustum().planes;
30331
+ // tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
30332
+ // cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
29415
30333
  // }
29416
30334
 
30335
+ if (strategies.length === 0) {
30336
+ cullable.visible = _this.renderingContext.unculledEntities.indexOf(object.entity) > -1;
30337
+ } else {
30338
+ // eg. implemented by g-webgl(frustum culling)
30339
+ cullable.visible = strategies.every(function (strategy) {
30340
+ return strategy.isVisible(object);
30341
+ });
30342
+ }
30343
+
29417
30344
  if (!cullable.isCulled() && object.isVisible()) {
29418
30345
  return object;
29419
30346
  } else {
@@ -30880,6 +31807,7 @@
30880
31807
  exports.contrib = contrib;
30881
31808
  exports.convertAngleUnit = convertAngleUnit;
30882
31809
  exports.convertEffectInput = convertEffectInput;
31810
+ exports.convertItemToMatrix = convertItemToMatrix;
30883
31811
  exports.convertPercentUnit = convertPercentUnit;
30884
31812
  exports.convertToDash = convertToDash;
30885
31813
  exports.convertToPath = convertToPath;