@antv/g 5.3.1 → 5.5.1
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/components/Transform.d.ts +5 -1
- package/dist/components/Transform.d.ts.map +1 -1
- package/dist/css/StyleValueRegistry.d.ts +1 -0
- package/dist/css/StyleValueRegistry.d.ts.map +1 -1
- package/dist/css/cssom/CSSNumericValue.d.ts +1 -1
- package/dist/css/cssom/CSSStyleValue.d.ts +2 -2
- package/dist/css/cssom/CSSStyleValue.d.ts.map +1 -1
- package/dist/css/interfaces.d.ts +1 -1
- package/dist/css/interfaces.d.ts.map +1 -1
- package/dist/css/layout/LayoutObject.d.ts +2 -2
- package/dist/css/layout/LayoutObject.d.ts.map +1 -1
- package/dist/css/parser/color.d.ts +4 -1
- package/dist/css/parser/color.d.ts.map +1 -1
- package/dist/css/parser/dimension.d.ts +1 -0
- package/dist/css/parser/dimension.d.ts.map +1 -1
- package/dist/css/parser/gradient.d.ts +4 -3
- package/dist/css/parser/gradient.d.ts.map +1 -1
- package/dist/css/parser/path.d.ts +2 -2
- package/dist/css/parser/path.d.ts.map +1 -1
- package/dist/css/parser/transform.d.ts +1 -0
- package/dist/css/parser/transform.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyClipPath.d.ts +1 -0
- package/dist/css/properties/CSSPropertyClipPath.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyColor.d.ts +4 -1
- package/dist/css/properties/CSSPropertyColor.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyNumber.d.ts +8 -0
- package/dist/css/properties/CSSPropertyNumber.d.ts.map +1 -0
- package/dist/css/properties/CSSPropertyTransform.d.ts.map +1 -1
- package/dist/css/properties/index.d.ts +1 -0
- package/dist/css/properties/index.d.ts.map +1 -1
- package/dist/display-objects/Circle.d.ts.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts +3 -0
- package/dist/display-objects/DisplayObject.d.ts.map +1 -1
- package/dist/display-objects/Ellipse.d.ts.map +1 -1
- package/dist/display-objects/Line.d.ts.map +1 -1
- package/dist/display-objects/Path.d.ts +1 -1
- package/dist/display-objects/Path.d.ts.map +1 -1
- package/dist/display-objects/Polyline.d.ts.map +1 -1
- package/dist/dom/interfaces.d.ts +0 -1
- package/dist/dom/interfaces.d.ts.map +1 -1
- package/dist/global-module.d.ts.map +1 -1
- package/dist/index.esm.js +746 -262
- package/dist/index.js +711 -225
- package/dist/index.umd.js +1783 -1510
- package/dist/index.umd.min.js +2 -2
- package/dist/plugins/DirtyCheckPlugin.d.ts +0 -1
- package/dist/plugins/DirtyCheckPlugin.d.ts.map +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/dist/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/dist/services/RenderingService.d.ts +9 -1
- package/dist/services/RenderingService.d.ts.map +1 -1
- package/dist/services/SceneGraphService.d.ts +12 -3
- package/dist/services/SceneGraphService.d.ts.map +1 -1
- package/dist/types.d.ts +2 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/interpolation.d.ts.map +1 -1
- package/dist/utils/memoize.d.ts +11 -0
- package/dist/utils/memoize.d.ts.map +1 -0
- package/dist/utils/string.d.ts +4 -1
- package/dist/utils/string.d.ts.map +1 -1
- package/package.json +6 -7
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.
|
|
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
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
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
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
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
|
+
}
|
|
9053
|
+
|
|
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
|
+
};
|
|
9004
9065
|
|
|
9005
|
-
|
|
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,15 +9282,33 @@
|
|
|
9209
9282
|
alias: 'img'
|
|
9210
9283
|
}
|
|
9211
9284
|
};
|
|
9212
|
-
function
|
|
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
|
-
|
|
9289
|
+
return [attributeName, map];
|
|
9290
|
+
});
|
|
9291
|
+
function formatAttribute(name, value) {
|
|
9292
|
+
var _map$values;
|
|
9293
|
+
|
|
9294
|
+
var _formatAttributeName = formatAttributeName(name),
|
|
9295
|
+
attributeName = _formatAttributeName[0],
|
|
9296
|
+
map = _formatAttributeName[1];
|
|
9297
|
+
|
|
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;
|
|
9219
9299
|
return [attributeName, attributeValue];
|
|
9220
|
-
}
|
|
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
|
+
// );
|
|
9221
9312
|
|
|
9222
9313
|
(function (Shape) {
|
|
9223
9314
|
Shape["GROUP"] = "g";
|
|
@@ -12124,8 +12215,8 @@
|
|
|
12124
12215
|
return exports.UnitType.kPixels;
|
|
12125
12216
|
|
|
12126
12217
|
case exports.UnitCategory.kUPercent:
|
|
12127
|
-
return exports.UnitType.
|
|
12128
|
-
// Cannot convert between numbers and percent.
|
|
12218
|
+
return exports.UnitType.kPercentage;
|
|
12219
|
+
// return UnitType.kUnknown; // Cannot convert between numbers and percent.
|
|
12129
12220
|
|
|
12130
12221
|
case exports.UnitCategory.kUTime:
|
|
12131
12222
|
return exports.UnitType.kSeconds;
|
|
@@ -14382,947 +14473,173 @@
|
|
|
14382
14473
|
: m1) * 255;
|
|
14383
14474
|
}
|
|
14384
14475
|
|
|
14385
|
-
|
|
14386
|
-
var
|
|
14476
|
+
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
14477
|
+
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
14478
|
+
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
|
|
14479
|
+
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
14387
14480
|
|
|
14388
|
-
|
|
14389
|
-
|
|
14481
|
+
function spaceColorStops(colorStops) {
|
|
14482
|
+
var _colorStops$length;
|
|
14390
14483
|
|
|
14391
|
-
|
|
14392
|
-
|
|
14484
|
+
var length = colorStops.length;
|
|
14485
|
+
colorStops[length - 1].length = (_colorStops$length = colorStops[length - 1].length) !== null && _colorStops$length !== void 0 ? _colorStops$length : {
|
|
14486
|
+
type: '%',
|
|
14487
|
+
value: '100'
|
|
14488
|
+
};
|
|
14393
14489
|
|
|
14394
|
-
|
|
14395
|
-
|
|
14490
|
+
if (length > 1) {
|
|
14491
|
+
var _colorStops$0$length;
|
|
14396
14492
|
|
|
14397
|
-
|
|
14398
|
-
|
|
14493
|
+
colorStops[0].length = (_colorStops$0$length = colorStops[0].length) !== null && _colorStops$0$length !== void 0 ? _colorStops$0$length : {
|
|
14494
|
+
type: '%',
|
|
14495
|
+
value: '0'
|
|
14496
|
+
};
|
|
14497
|
+
}
|
|
14399
14498
|
|
|
14400
|
-
|
|
14401
|
-
|
|
14499
|
+
var previousIndex = 0;
|
|
14500
|
+
var previousOffset = Number(colorStops[0].length.value);
|
|
14402
14501
|
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
14406
|
-
* of values.
|
|
14407
|
-
*/
|
|
14408
|
-
var nativeObjectToString = objectProto.toString;
|
|
14502
|
+
for (var i = 1; i < length; i++) {
|
|
14503
|
+
var _colorStops$i$length;
|
|
14409
14504
|
|
|
14410
|
-
|
|
14411
|
-
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
14505
|
+
var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
|
|
14412
14506
|
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
function getRawTag(value) {
|
|
14421
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
14422
|
-
tag = value[symToStringTag];
|
|
14507
|
+
if (!isNil(offset) && !isNil(previousOffset)) {
|
|
14508
|
+
for (var j = 1; j < i - previousIndex; j++) {
|
|
14509
|
+
colorStops[previousIndex + j].length = {
|
|
14510
|
+
type: '%',
|
|
14511
|
+
value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
|
|
14512
|
+
};
|
|
14513
|
+
}
|
|
14423
14514
|
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
var unmasked = true;
|
|
14427
|
-
} catch (e) {}
|
|
14428
|
-
|
|
14429
|
-
var result = nativeObjectToString.call(value);
|
|
14430
|
-
if (unmasked) {
|
|
14431
|
-
if (isOwn) {
|
|
14432
|
-
value[symToStringTag] = tag;
|
|
14433
|
-
} else {
|
|
14434
|
-
delete value[symToStringTag];
|
|
14515
|
+
previousIndex = i;
|
|
14516
|
+
previousOffset = Number(offset);
|
|
14435
14517
|
}
|
|
14436
14518
|
}
|
|
14437
|
-
|
|
14438
|
-
|
|
14519
|
+
} // The position of the gradient line's starting point.
|
|
14520
|
+
// different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
|
|
14439
14521
|
|
|
14440
|
-
/** Used for built-in method references. */
|
|
14441
|
-
var objectProto$1 = Object.prototype;
|
|
14442
14522
|
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14523
|
+
var SideOrCornerToDegMap = {
|
|
14524
|
+
left: 270 - 90,
|
|
14525
|
+
top: 0 - 90,
|
|
14526
|
+
bottom: 180 - 90,
|
|
14527
|
+
right: 90 - 90,
|
|
14528
|
+
'left top': 315 - 90,
|
|
14529
|
+
'top left': 315 - 90,
|
|
14530
|
+
'left bottom': 225 - 90,
|
|
14531
|
+
'bottom left': 225 - 90,
|
|
14532
|
+
'right top': 45 - 90,
|
|
14533
|
+
'top right': 45 - 90,
|
|
14534
|
+
'right bottom': 135 - 90,
|
|
14535
|
+
'bottom right': 135 - 90
|
|
14536
|
+
};
|
|
14537
|
+
var angleToDeg = memoize(function (orientation) {
|
|
14538
|
+
var angle;
|
|
14449
14539
|
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
* @returns {string} Returns the converted string.
|
|
14456
|
-
*/
|
|
14457
|
-
function objectToString(value) {
|
|
14458
|
-
return nativeObjectToString$1.call(value);
|
|
14459
|
-
}
|
|
14540
|
+
if (orientation.type === 'angular') {
|
|
14541
|
+
angle = Number(orientation.value);
|
|
14542
|
+
} else {
|
|
14543
|
+
angle = SideOrCornerToDegMap[orientation.value] || 0;
|
|
14544
|
+
}
|
|
14460
14545
|
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14546
|
+
return angle;
|
|
14547
|
+
});
|
|
14548
|
+
var positonToPercentage = memoize(function (position) {
|
|
14549
|
+
var cx = 0.5;
|
|
14550
|
+
var cy = 0.5;
|
|
14464
14551
|
|
|
14465
|
-
|
|
14466
|
-
|
|
14552
|
+
if ((position === null || position === void 0 ? void 0 : position.type) === 'position') {
|
|
14553
|
+
var _position$value = position.value,
|
|
14554
|
+
x = _position$value.x,
|
|
14555
|
+
y = _position$value.y;
|
|
14467
14556
|
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
: objectToString(value);
|
|
14482
|
-
}
|
|
14557
|
+
if ((x === null || x === void 0 ? void 0 : x.type) === 'position-keyword') {
|
|
14558
|
+
if (x.value === 'left') {
|
|
14559
|
+
cx = 0;
|
|
14560
|
+
} else if (x.value === 'center') {
|
|
14561
|
+
cx = 0.5;
|
|
14562
|
+
} else if (x.value === 'right') {
|
|
14563
|
+
cx = 1;
|
|
14564
|
+
} else if (x.value === 'top') {
|
|
14565
|
+
cy = 0;
|
|
14566
|
+
} else if (x.value === 'bottom') {
|
|
14567
|
+
cy = 1;
|
|
14568
|
+
}
|
|
14569
|
+
}
|
|
14483
14570
|
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
* _.isObject({});
|
|
14498
|
-
* // => true
|
|
14499
|
-
*
|
|
14500
|
-
* _.isObject([1, 2, 3]);
|
|
14501
|
-
* // => true
|
|
14502
|
-
*
|
|
14503
|
-
* _.isObject(_.noop);
|
|
14504
|
-
* // => true
|
|
14505
|
-
*
|
|
14506
|
-
* _.isObject(null);
|
|
14507
|
-
* // => false
|
|
14508
|
-
*/
|
|
14509
|
-
function isObject$1(value) {
|
|
14510
|
-
var type = typeof value;
|
|
14511
|
-
return value != null && (type == 'object' || type == 'function');
|
|
14512
|
-
}
|
|
14571
|
+
if ((y === null || y === void 0 ? void 0 : y.type) === 'position-keyword') {
|
|
14572
|
+
if (y.value === 'left') {
|
|
14573
|
+
cx = 0;
|
|
14574
|
+
} else if (y.value === 'center') {
|
|
14575
|
+
cy = 0.5;
|
|
14576
|
+
} else if (y.value === 'right') {
|
|
14577
|
+
cx = 1;
|
|
14578
|
+
} else if (y.value === 'top') {
|
|
14579
|
+
cy = 0;
|
|
14580
|
+
} else if (y.value === 'bottom') {
|
|
14581
|
+
cy = 1;
|
|
14582
|
+
}
|
|
14583
|
+
}
|
|
14513
14584
|
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
genTag = '[object GeneratorFunction]',
|
|
14518
|
-
proxyTag = '[object Proxy]';
|
|
14585
|
+
if ((x === null || x === void 0 ? void 0 : x.type) === '%') {
|
|
14586
|
+
cx = Number(x.value) / 100;
|
|
14587
|
+
}
|
|
14519
14588
|
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
* @static
|
|
14524
|
-
* @memberOf _
|
|
14525
|
-
* @since 0.1.0
|
|
14526
|
-
* @category Lang
|
|
14527
|
-
* @param {*} value The value to check.
|
|
14528
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
14529
|
-
* @example
|
|
14530
|
-
*
|
|
14531
|
-
* _.isFunction(_);
|
|
14532
|
-
* // => true
|
|
14533
|
-
*
|
|
14534
|
-
* _.isFunction(/abc/);
|
|
14535
|
-
* // => false
|
|
14536
|
-
*/
|
|
14537
|
-
function isFunction$1(value) {
|
|
14538
|
-
if (!isObject$1(value)) {
|
|
14539
|
-
return false;
|
|
14589
|
+
if ((y === null || y === void 0 ? void 0 : y.type) === '%') {
|
|
14590
|
+
cy = Number(x.value) / 100;
|
|
14591
|
+
}
|
|
14540
14592
|
}
|
|
14541
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
14542
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
14543
|
-
var tag = baseGetTag(value);
|
|
14544
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
14545
|
-
}
|
|
14546
14593
|
|
|
14547
|
-
|
|
14548
|
-
|
|
14594
|
+
return {
|
|
14595
|
+
cx: cx,
|
|
14596
|
+
cy: cy
|
|
14597
|
+
};
|
|
14598
|
+
});
|
|
14599
|
+
var parseGradient$1 = memoize(function (colorStr) {
|
|
14600
|
+
if (colorStr.indexOf('linear') > -1 || colorStr.indexOf('radial') > -1) {
|
|
14601
|
+
var ast = parseGradient(colorStr);
|
|
14602
|
+
return ast.map(function (_ref) {
|
|
14603
|
+
var type = _ref.type,
|
|
14604
|
+
orientation = _ref.orientation,
|
|
14605
|
+
colorStops = _ref.colorStops;
|
|
14606
|
+
spaceColorStops(colorStops);
|
|
14607
|
+
var steps = colorStops.map(function (colorStop) {
|
|
14608
|
+
// TODO: only support % for now, should calc percentage of axis length when using px/em
|
|
14609
|
+
return [Number(colorStop.length.value) / 100, colorStopToString(colorStop)];
|
|
14610
|
+
});
|
|
14549
14611
|
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14612
|
+
if (type === 'linear-gradient') {
|
|
14613
|
+
return new CSSGradientValue(exports.GradientType.LinearGradient, {
|
|
14614
|
+
angle: orientation ? angleToDeg(orientation) : 0,
|
|
14615
|
+
steps: steps,
|
|
14616
|
+
hash: colorStr
|
|
14617
|
+
});
|
|
14618
|
+
} else if (type === 'radial-gradient') {
|
|
14619
|
+
if (!orientation) {
|
|
14620
|
+
orientation = [{
|
|
14621
|
+
type: 'shape',
|
|
14622
|
+
value: 'circle'
|
|
14623
|
+
}];
|
|
14624
|
+
}
|
|
14555
14625
|
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
* @param {Function} func The function to check.
|
|
14561
|
-
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
14562
|
-
*/
|
|
14563
|
-
function isMasked(func) {
|
|
14564
|
-
return !!maskSrcKey && (maskSrcKey in func);
|
|
14565
|
-
}
|
|
14626
|
+
if (orientation[0].type === 'shape' && orientation[0].value === 'circle') {
|
|
14627
|
+
var _positonToPercentage = positonToPercentage(orientation[0].at),
|
|
14628
|
+
cx = _positonToPercentage.cx,
|
|
14629
|
+
cy = _positonToPercentage.cy;
|
|
14566
14630
|
|
|
14567
|
-
|
|
14568
|
-
|
|
14631
|
+
return new CSSGradientValue(exports.GradientType.RadialGradient, {
|
|
14632
|
+
cx: cx,
|
|
14633
|
+
cy: cy,
|
|
14634
|
+
steps: steps,
|
|
14635
|
+
hash: colorStr
|
|
14636
|
+
});
|
|
14637
|
+
} // } else if (type === 'repeating-linear-gradient') {
|
|
14638
|
+
// } else if (type === 'repeating-radial-gradient') {
|
|
14569
14639
|
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
/**
|
|
14574
|
-
* Converts `func` to its source code.
|
|
14575
|
-
*
|
|
14576
|
-
* @private
|
|
14577
|
-
* @param {Function} func The function to convert.
|
|
14578
|
-
* @returns {string} Returns the source code.
|
|
14579
|
-
*/
|
|
14580
|
-
function toSource(func) {
|
|
14581
|
-
if (func != null) {
|
|
14582
|
-
try {
|
|
14583
|
-
return funcToString.call(func);
|
|
14584
|
-
} catch (e) {}
|
|
14585
|
-
try {
|
|
14586
|
-
return (func + '');
|
|
14587
|
-
} catch (e) {}
|
|
14588
|
-
}
|
|
14589
|
-
return '';
|
|
14590
|
-
}
|
|
14591
|
-
|
|
14592
|
-
/**
|
|
14593
|
-
* Used to match `RegExp`
|
|
14594
|
-
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
14595
|
-
*/
|
|
14596
|
-
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
14597
|
-
|
|
14598
|
-
/** Used to detect host constructors (Safari). */
|
|
14599
|
-
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
14600
|
-
|
|
14601
|
-
/** Used for built-in method references. */
|
|
14602
|
-
var funcProto$1 = Function.prototype,
|
|
14603
|
-
objectProto$2 = Object.prototype;
|
|
14604
|
-
|
|
14605
|
-
/** Used to resolve the decompiled source of functions. */
|
|
14606
|
-
var funcToString$1 = funcProto$1.toString;
|
|
14607
|
-
|
|
14608
|
-
/** Used to check objects for own properties. */
|
|
14609
|
-
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
|
14610
|
-
|
|
14611
|
-
/** Used to detect if a method is native. */
|
|
14612
|
-
var reIsNative = RegExp('^' +
|
|
14613
|
-
funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
|
|
14614
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
14615
|
-
);
|
|
14616
|
-
|
|
14617
|
-
/**
|
|
14618
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
14619
|
-
*
|
|
14620
|
-
* @private
|
|
14621
|
-
* @param {*} value The value to check.
|
|
14622
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
14623
|
-
* else `false`.
|
|
14624
|
-
*/
|
|
14625
|
-
function baseIsNative(value) {
|
|
14626
|
-
if (!isObject$1(value) || isMasked(value)) {
|
|
14627
|
-
return false;
|
|
14628
|
-
}
|
|
14629
|
-
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
14630
|
-
return pattern.test(toSource(value));
|
|
14631
|
-
}
|
|
14632
|
-
|
|
14633
|
-
/**
|
|
14634
|
-
* Gets the value at `key` of `object`.
|
|
14635
|
-
*
|
|
14636
|
-
* @private
|
|
14637
|
-
* @param {Object} [object] The object to query.
|
|
14638
|
-
* @param {string} key The key of the property to get.
|
|
14639
|
-
* @returns {*} Returns the property value.
|
|
14640
|
-
*/
|
|
14641
|
-
function getValue(object, key) {
|
|
14642
|
-
return object == null ? undefined : object[key];
|
|
14643
|
-
}
|
|
14644
|
-
|
|
14645
|
-
/**
|
|
14646
|
-
* Gets the native function at `key` of `object`.
|
|
14647
|
-
*
|
|
14648
|
-
* @private
|
|
14649
|
-
* @param {Object} object The object to query.
|
|
14650
|
-
* @param {string} key The key of the method to get.
|
|
14651
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
14652
|
-
*/
|
|
14653
|
-
function getNative(object, key) {
|
|
14654
|
-
var value = getValue(object, key);
|
|
14655
|
-
return baseIsNative(value) ? value : undefined;
|
|
14656
|
-
}
|
|
14657
|
-
|
|
14658
|
-
/**
|
|
14659
|
-
* Performs a
|
|
14660
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
14661
|
-
* comparison between two values to determine if they are equivalent.
|
|
14662
|
-
*
|
|
14663
|
-
* @static
|
|
14664
|
-
* @memberOf _
|
|
14665
|
-
* @since 4.0.0
|
|
14666
|
-
* @category Lang
|
|
14667
|
-
* @param {*} value The value to compare.
|
|
14668
|
-
* @param {*} other The other value to compare.
|
|
14669
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
14670
|
-
* @example
|
|
14671
|
-
*
|
|
14672
|
-
* var object = { 'a': 1 };
|
|
14673
|
-
* var other = { 'a': 1 };
|
|
14674
|
-
*
|
|
14675
|
-
* _.eq(object, object);
|
|
14676
|
-
* // => true
|
|
14677
|
-
*
|
|
14678
|
-
* _.eq(object, other);
|
|
14679
|
-
* // => false
|
|
14680
|
-
*
|
|
14681
|
-
* _.eq('a', 'a');
|
|
14682
|
-
* // => true
|
|
14683
|
-
*
|
|
14684
|
-
* _.eq('a', Object('a'));
|
|
14685
|
-
* // => false
|
|
14686
|
-
*
|
|
14687
|
-
* _.eq(NaN, NaN);
|
|
14688
|
-
* // => true
|
|
14689
|
-
*/
|
|
14690
|
-
function eq(value, other) {
|
|
14691
|
-
return value === other || (value !== value && other !== other);
|
|
14692
|
-
}
|
|
14693
|
-
|
|
14694
|
-
/* Built-in method references that are verified to be native. */
|
|
14695
|
-
var nativeCreate = getNative(Object, 'create');
|
|
14696
|
-
|
|
14697
|
-
/**
|
|
14698
|
-
* Removes all key-value entries from the hash.
|
|
14699
|
-
*
|
|
14700
|
-
* @private
|
|
14701
|
-
* @name clear
|
|
14702
|
-
* @memberOf Hash
|
|
14703
|
-
*/
|
|
14704
|
-
function hashClear() {
|
|
14705
|
-
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
14706
|
-
this.size = 0;
|
|
14707
|
-
}
|
|
14708
|
-
|
|
14709
|
-
/**
|
|
14710
|
-
* Removes `key` and its value from the hash.
|
|
14711
|
-
*
|
|
14712
|
-
* @private
|
|
14713
|
-
* @name delete
|
|
14714
|
-
* @memberOf Hash
|
|
14715
|
-
* @param {Object} hash The hash to modify.
|
|
14716
|
-
* @param {string} key The key of the value to remove.
|
|
14717
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
14718
|
-
*/
|
|
14719
|
-
function hashDelete(key) {
|
|
14720
|
-
var result = this.has(key) && delete this.__data__[key];
|
|
14721
|
-
this.size -= result ? 1 : 0;
|
|
14722
|
-
return result;
|
|
14723
|
-
}
|
|
14724
|
-
|
|
14725
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
14726
|
-
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
14727
|
-
|
|
14728
|
-
/** Used for built-in method references. */
|
|
14729
|
-
var objectProto$3 = Object.prototype;
|
|
14730
|
-
|
|
14731
|
-
/** Used to check objects for own properties. */
|
|
14732
|
-
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
14733
|
-
|
|
14734
|
-
/**
|
|
14735
|
-
* Gets the hash value for `key`.
|
|
14736
|
-
*
|
|
14737
|
-
* @private
|
|
14738
|
-
* @name get
|
|
14739
|
-
* @memberOf Hash
|
|
14740
|
-
* @param {string} key The key of the value to get.
|
|
14741
|
-
* @returns {*} Returns the entry value.
|
|
14742
|
-
*/
|
|
14743
|
-
function hashGet(key) {
|
|
14744
|
-
var data = this.__data__;
|
|
14745
|
-
if (nativeCreate) {
|
|
14746
|
-
var result = data[key];
|
|
14747
|
-
return result === HASH_UNDEFINED ? undefined : result;
|
|
14748
|
-
}
|
|
14749
|
-
return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
|
|
14750
|
-
}
|
|
14751
|
-
|
|
14752
|
-
/** Used for built-in method references. */
|
|
14753
|
-
var objectProto$4 = Object.prototype;
|
|
14754
|
-
|
|
14755
|
-
/** Used to check objects for own properties. */
|
|
14756
|
-
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
14757
|
-
|
|
14758
|
-
/**
|
|
14759
|
-
* Checks if a hash value for `key` exists.
|
|
14760
|
-
*
|
|
14761
|
-
* @private
|
|
14762
|
-
* @name has
|
|
14763
|
-
* @memberOf Hash
|
|
14764
|
-
* @param {string} key The key of the entry to check.
|
|
14765
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
14766
|
-
*/
|
|
14767
|
-
function hashHas(key) {
|
|
14768
|
-
var data = this.__data__;
|
|
14769
|
-
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
|
|
14770
|
-
}
|
|
14771
|
-
|
|
14772
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
14773
|
-
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
14774
|
-
|
|
14775
|
-
/**
|
|
14776
|
-
* Sets the hash `key` to `value`.
|
|
14777
|
-
*
|
|
14778
|
-
* @private
|
|
14779
|
-
* @name set
|
|
14780
|
-
* @memberOf Hash
|
|
14781
|
-
* @param {string} key The key of the value to set.
|
|
14782
|
-
* @param {*} value The value to set.
|
|
14783
|
-
* @returns {Object} Returns the hash instance.
|
|
14784
|
-
*/
|
|
14785
|
-
function hashSet(key, value) {
|
|
14786
|
-
var data = this.__data__;
|
|
14787
|
-
this.size += this.has(key) ? 0 : 1;
|
|
14788
|
-
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
|
|
14789
|
-
return this;
|
|
14790
|
-
}
|
|
14791
|
-
|
|
14792
|
-
/**
|
|
14793
|
-
* Creates a hash object.
|
|
14794
|
-
*
|
|
14795
|
-
* @private
|
|
14796
|
-
* @constructor
|
|
14797
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
14798
|
-
*/
|
|
14799
|
-
function Hash(entries) {
|
|
14800
|
-
var index = -1,
|
|
14801
|
-
length = entries == null ? 0 : entries.length;
|
|
14802
|
-
|
|
14803
|
-
this.clear();
|
|
14804
|
-
while (++index < length) {
|
|
14805
|
-
var entry = entries[index];
|
|
14806
|
-
this.set(entry[0], entry[1]);
|
|
14807
|
-
}
|
|
14808
|
-
}
|
|
14809
|
-
|
|
14810
|
-
// Add methods to `Hash`.
|
|
14811
|
-
Hash.prototype.clear = hashClear;
|
|
14812
|
-
Hash.prototype['delete'] = hashDelete;
|
|
14813
|
-
Hash.prototype.get = hashGet;
|
|
14814
|
-
Hash.prototype.has = hashHas;
|
|
14815
|
-
Hash.prototype.set = hashSet;
|
|
14816
|
-
|
|
14817
|
-
/**
|
|
14818
|
-
* Removes all key-value entries from the list cache.
|
|
14819
|
-
*
|
|
14820
|
-
* @private
|
|
14821
|
-
* @name clear
|
|
14822
|
-
* @memberOf ListCache
|
|
14823
|
-
*/
|
|
14824
|
-
function listCacheClear() {
|
|
14825
|
-
this.__data__ = [];
|
|
14826
|
-
this.size = 0;
|
|
14827
|
-
}
|
|
14828
|
-
|
|
14829
|
-
/**
|
|
14830
|
-
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
14831
|
-
*
|
|
14832
|
-
* @private
|
|
14833
|
-
* @param {Array} array The array to inspect.
|
|
14834
|
-
* @param {*} key The key to search for.
|
|
14835
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
14836
|
-
*/
|
|
14837
|
-
function assocIndexOf(array, key) {
|
|
14838
|
-
var length = array.length;
|
|
14839
|
-
while (length--) {
|
|
14840
|
-
if (eq(array[length][0], key)) {
|
|
14841
|
-
return length;
|
|
14842
|
-
}
|
|
14843
|
-
}
|
|
14844
|
-
return -1;
|
|
14845
|
-
}
|
|
14846
|
-
|
|
14847
|
-
/** Used for built-in method references. */
|
|
14848
|
-
var arrayProto = Array.prototype;
|
|
14849
|
-
|
|
14850
|
-
/** Built-in value references. */
|
|
14851
|
-
var splice = arrayProto.splice;
|
|
14852
|
-
|
|
14853
|
-
/**
|
|
14854
|
-
* Removes `key` and its value from the list cache.
|
|
14855
|
-
*
|
|
14856
|
-
* @private
|
|
14857
|
-
* @name delete
|
|
14858
|
-
* @memberOf ListCache
|
|
14859
|
-
* @param {string} key The key of the value to remove.
|
|
14860
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
14861
|
-
*/
|
|
14862
|
-
function listCacheDelete(key) {
|
|
14863
|
-
var data = this.__data__,
|
|
14864
|
-
index = assocIndexOf(data, key);
|
|
14865
|
-
|
|
14866
|
-
if (index < 0) {
|
|
14867
|
-
return false;
|
|
14868
|
-
}
|
|
14869
|
-
var lastIndex = data.length - 1;
|
|
14870
|
-
if (index == lastIndex) {
|
|
14871
|
-
data.pop();
|
|
14872
|
-
} else {
|
|
14873
|
-
splice.call(data, index, 1);
|
|
14874
|
-
}
|
|
14875
|
-
--this.size;
|
|
14876
|
-
return true;
|
|
14877
|
-
}
|
|
14878
|
-
|
|
14879
|
-
/**
|
|
14880
|
-
* Gets the list cache value for `key`.
|
|
14881
|
-
*
|
|
14882
|
-
* @private
|
|
14883
|
-
* @name get
|
|
14884
|
-
* @memberOf ListCache
|
|
14885
|
-
* @param {string} key The key of the value to get.
|
|
14886
|
-
* @returns {*} Returns the entry value.
|
|
14887
|
-
*/
|
|
14888
|
-
function listCacheGet(key) {
|
|
14889
|
-
var data = this.__data__,
|
|
14890
|
-
index = assocIndexOf(data, key);
|
|
14891
|
-
|
|
14892
|
-
return index < 0 ? undefined : data[index][1];
|
|
14893
|
-
}
|
|
14894
|
-
|
|
14895
|
-
/**
|
|
14896
|
-
* Checks if a list cache value for `key` exists.
|
|
14897
|
-
*
|
|
14898
|
-
* @private
|
|
14899
|
-
* @name has
|
|
14900
|
-
* @memberOf ListCache
|
|
14901
|
-
* @param {string} key The key of the entry to check.
|
|
14902
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
14903
|
-
*/
|
|
14904
|
-
function listCacheHas(key) {
|
|
14905
|
-
return assocIndexOf(this.__data__, key) > -1;
|
|
14906
|
-
}
|
|
14907
|
-
|
|
14908
|
-
/**
|
|
14909
|
-
* Sets the list cache `key` to `value`.
|
|
14910
|
-
*
|
|
14911
|
-
* @private
|
|
14912
|
-
* @name set
|
|
14913
|
-
* @memberOf ListCache
|
|
14914
|
-
* @param {string} key The key of the value to set.
|
|
14915
|
-
* @param {*} value The value to set.
|
|
14916
|
-
* @returns {Object} Returns the list cache instance.
|
|
14917
|
-
*/
|
|
14918
|
-
function listCacheSet(key, value) {
|
|
14919
|
-
var data = this.__data__,
|
|
14920
|
-
index = assocIndexOf(data, key);
|
|
14921
|
-
|
|
14922
|
-
if (index < 0) {
|
|
14923
|
-
++this.size;
|
|
14924
|
-
data.push([key, value]);
|
|
14925
|
-
} else {
|
|
14926
|
-
data[index][1] = value;
|
|
14927
|
-
}
|
|
14928
|
-
return this;
|
|
14929
|
-
}
|
|
14930
|
-
|
|
14931
|
-
/**
|
|
14932
|
-
* Creates an list cache object.
|
|
14933
|
-
*
|
|
14934
|
-
* @private
|
|
14935
|
-
* @constructor
|
|
14936
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
14937
|
-
*/
|
|
14938
|
-
function ListCache(entries) {
|
|
14939
|
-
var index = -1,
|
|
14940
|
-
length = entries == null ? 0 : entries.length;
|
|
14941
|
-
|
|
14942
|
-
this.clear();
|
|
14943
|
-
while (++index < length) {
|
|
14944
|
-
var entry = entries[index];
|
|
14945
|
-
this.set(entry[0], entry[1]);
|
|
14946
|
-
}
|
|
14947
|
-
}
|
|
14948
|
-
|
|
14949
|
-
// Add methods to `ListCache`.
|
|
14950
|
-
ListCache.prototype.clear = listCacheClear;
|
|
14951
|
-
ListCache.prototype['delete'] = listCacheDelete;
|
|
14952
|
-
ListCache.prototype.get = listCacheGet;
|
|
14953
|
-
ListCache.prototype.has = listCacheHas;
|
|
14954
|
-
ListCache.prototype.set = listCacheSet;
|
|
14955
|
-
|
|
14956
|
-
/* Built-in method references that are verified to be native. */
|
|
14957
|
-
var Map$1 = getNative(root, 'Map');
|
|
14958
|
-
|
|
14959
|
-
/**
|
|
14960
|
-
* Removes all key-value entries from the map.
|
|
14961
|
-
*
|
|
14962
|
-
* @private
|
|
14963
|
-
* @name clear
|
|
14964
|
-
* @memberOf MapCache
|
|
14965
|
-
*/
|
|
14966
|
-
function mapCacheClear() {
|
|
14967
|
-
this.size = 0;
|
|
14968
|
-
this.__data__ = {
|
|
14969
|
-
'hash': new Hash,
|
|
14970
|
-
'map': new (Map$1 || ListCache),
|
|
14971
|
-
'string': new Hash
|
|
14972
|
-
};
|
|
14973
|
-
}
|
|
14974
|
-
|
|
14975
|
-
/**
|
|
14976
|
-
* Checks if `value` is suitable for use as unique object key.
|
|
14977
|
-
*
|
|
14978
|
-
* @private
|
|
14979
|
-
* @param {*} value The value to check.
|
|
14980
|
-
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
14981
|
-
*/
|
|
14982
|
-
function isKeyable(value) {
|
|
14983
|
-
var type = typeof value;
|
|
14984
|
-
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
14985
|
-
? (value !== '__proto__')
|
|
14986
|
-
: (value === null);
|
|
14987
|
-
}
|
|
14988
|
-
|
|
14989
|
-
/**
|
|
14990
|
-
* Gets the data for `map`.
|
|
14991
|
-
*
|
|
14992
|
-
* @private
|
|
14993
|
-
* @param {Object} map The map to query.
|
|
14994
|
-
* @param {string} key The reference key.
|
|
14995
|
-
* @returns {*} Returns the map data.
|
|
14996
|
-
*/
|
|
14997
|
-
function getMapData(map, key) {
|
|
14998
|
-
var data = map.__data__;
|
|
14999
|
-
return isKeyable(key)
|
|
15000
|
-
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
15001
|
-
: data.map;
|
|
15002
|
-
}
|
|
15003
|
-
|
|
15004
|
-
/**
|
|
15005
|
-
* Removes `key` and its value from the map.
|
|
15006
|
-
*
|
|
15007
|
-
* @private
|
|
15008
|
-
* @name delete
|
|
15009
|
-
* @memberOf MapCache
|
|
15010
|
-
* @param {string} key The key of the value to remove.
|
|
15011
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
15012
|
-
*/
|
|
15013
|
-
function mapCacheDelete(key) {
|
|
15014
|
-
var result = getMapData(this, key)['delete'](key);
|
|
15015
|
-
this.size -= result ? 1 : 0;
|
|
15016
|
-
return result;
|
|
15017
|
-
}
|
|
15018
|
-
|
|
15019
|
-
/**
|
|
15020
|
-
* Gets the map value for `key`.
|
|
15021
|
-
*
|
|
15022
|
-
* @private
|
|
15023
|
-
* @name get
|
|
15024
|
-
* @memberOf MapCache
|
|
15025
|
-
* @param {string} key The key of the value to get.
|
|
15026
|
-
* @returns {*} Returns the entry value.
|
|
15027
|
-
*/
|
|
15028
|
-
function mapCacheGet(key) {
|
|
15029
|
-
return getMapData(this, key).get(key);
|
|
15030
|
-
}
|
|
15031
|
-
|
|
15032
|
-
/**
|
|
15033
|
-
* Checks if a map value for `key` exists.
|
|
15034
|
-
*
|
|
15035
|
-
* @private
|
|
15036
|
-
* @name has
|
|
15037
|
-
* @memberOf MapCache
|
|
15038
|
-
* @param {string} key The key of the entry to check.
|
|
15039
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
15040
|
-
*/
|
|
15041
|
-
function mapCacheHas(key) {
|
|
15042
|
-
return getMapData(this, key).has(key);
|
|
15043
|
-
}
|
|
15044
|
-
|
|
15045
|
-
/**
|
|
15046
|
-
* Sets the map `key` to `value`.
|
|
15047
|
-
*
|
|
15048
|
-
* @private
|
|
15049
|
-
* @name set
|
|
15050
|
-
* @memberOf MapCache
|
|
15051
|
-
* @param {string} key The key of the value to set.
|
|
15052
|
-
* @param {*} value The value to set.
|
|
15053
|
-
* @returns {Object} Returns the map cache instance.
|
|
15054
|
-
*/
|
|
15055
|
-
function mapCacheSet(key, value) {
|
|
15056
|
-
var data = getMapData(this, key),
|
|
15057
|
-
size = data.size;
|
|
15058
|
-
|
|
15059
|
-
data.set(key, value);
|
|
15060
|
-
this.size += data.size == size ? 0 : 1;
|
|
15061
|
-
return this;
|
|
15062
|
-
}
|
|
15063
|
-
|
|
15064
|
-
/**
|
|
15065
|
-
* Creates a map cache object to store key-value pairs.
|
|
15066
|
-
*
|
|
15067
|
-
* @private
|
|
15068
|
-
* @constructor
|
|
15069
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
15070
|
-
*/
|
|
15071
|
-
function MapCache(entries) {
|
|
15072
|
-
var index = -1,
|
|
15073
|
-
length = entries == null ? 0 : entries.length;
|
|
15074
|
-
|
|
15075
|
-
this.clear();
|
|
15076
|
-
while (++index < length) {
|
|
15077
|
-
var entry = entries[index];
|
|
15078
|
-
this.set(entry[0], entry[1]);
|
|
15079
|
-
}
|
|
15080
|
-
}
|
|
15081
|
-
|
|
15082
|
-
// Add methods to `MapCache`.
|
|
15083
|
-
MapCache.prototype.clear = mapCacheClear;
|
|
15084
|
-
MapCache.prototype['delete'] = mapCacheDelete;
|
|
15085
|
-
MapCache.prototype.get = mapCacheGet;
|
|
15086
|
-
MapCache.prototype.has = mapCacheHas;
|
|
15087
|
-
MapCache.prototype.set = mapCacheSet;
|
|
15088
|
-
|
|
15089
|
-
/** Error message constants. */
|
|
15090
|
-
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
15091
|
-
|
|
15092
|
-
/**
|
|
15093
|
-
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
15094
|
-
* provided, it determines the cache key for storing the result based on the
|
|
15095
|
-
* arguments provided to the memoized function. By default, the first argument
|
|
15096
|
-
* provided to the memoized function is used as the map cache key. The `func`
|
|
15097
|
-
* is invoked with the `this` binding of the memoized function.
|
|
15098
|
-
*
|
|
15099
|
-
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
15100
|
-
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
15101
|
-
* constructor with one whose instances implement the
|
|
15102
|
-
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
15103
|
-
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
15104
|
-
*
|
|
15105
|
-
* @static
|
|
15106
|
-
* @memberOf _
|
|
15107
|
-
* @since 0.1.0
|
|
15108
|
-
* @category Function
|
|
15109
|
-
* @param {Function} func The function to have its output memoized.
|
|
15110
|
-
* @param {Function} [resolver] The function to resolve the cache key.
|
|
15111
|
-
* @returns {Function} Returns the new memoized function.
|
|
15112
|
-
* @example
|
|
15113
|
-
*
|
|
15114
|
-
* var object = { 'a': 1, 'b': 2 };
|
|
15115
|
-
* var other = { 'c': 3, 'd': 4 };
|
|
15116
|
-
*
|
|
15117
|
-
* var values = _.memoize(_.values);
|
|
15118
|
-
* values(object);
|
|
15119
|
-
* // => [1, 2]
|
|
15120
|
-
*
|
|
15121
|
-
* values(other);
|
|
15122
|
-
* // => [3, 4]
|
|
15123
|
-
*
|
|
15124
|
-
* object.a = 2;
|
|
15125
|
-
* values(object);
|
|
15126
|
-
* // => [1, 2]
|
|
15127
|
-
*
|
|
15128
|
-
* // Modify the result cache.
|
|
15129
|
-
* values.cache.set(object, ['a', 'b']);
|
|
15130
|
-
* values(object);
|
|
15131
|
-
* // => ['a', 'b']
|
|
15132
|
-
*
|
|
15133
|
-
* // Replace `_.memoize.Cache`.
|
|
15134
|
-
* _.memoize.Cache = WeakMap;
|
|
15135
|
-
*/
|
|
15136
|
-
function memoize(func, resolver) {
|
|
15137
|
-
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
15138
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
15139
|
-
}
|
|
15140
|
-
var memoized = function() {
|
|
15141
|
-
var args = arguments,
|
|
15142
|
-
key = resolver ? resolver.apply(this, args) : args[0],
|
|
15143
|
-
cache = memoized.cache;
|
|
15144
|
-
|
|
15145
|
-
if (cache.has(key)) {
|
|
15146
|
-
return cache.get(key);
|
|
15147
|
-
}
|
|
15148
|
-
var result = func.apply(this, args);
|
|
15149
|
-
memoized.cache = cache.set(key, result) || cache;
|
|
15150
|
-
return result;
|
|
15151
|
-
};
|
|
15152
|
-
memoized.cache = new (memoize.Cache || MapCache);
|
|
15153
|
-
return memoized;
|
|
15154
|
-
}
|
|
15155
|
-
|
|
15156
|
-
// Expose `MapCache`.
|
|
15157
|
-
memoize.Cache = MapCache;
|
|
15158
|
-
|
|
15159
|
-
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
15160
|
-
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
15161
|
-
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
|
|
15162
|
-
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
15163
|
-
|
|
15164
|
-
function spaceColorStops(colorStops) {
|
|
15165
|
-
var _colorStops$length;
|
|
15166
|
-
|
|
15167
|
-
var length = colorStops.length;
|
|
15168
|
-
colorStops[length - 1].length = (_colorStops$length = colorStops[length - 1].length) !== null && _colorStops$length !== void 0 ? _colorStops$length : {
|
|
15169
|
-
type: '%',
|
|
15170
|
-
value: '100'
|
|
15171
|
-
};
|
|
15172
|
-
|
|
15173
|
-
if (length > 1) {
|
|
15174
|
-
var _colorStops$0$length;
|
|
15175
|
-
|
|
15176
|
-
colorStops[0].length = (_colorStops$0$length = colorStops[0].length) !== null && _colorStops$0$length !== void 0 ? _colorStops$0$length : {
|
|
15177
|
-
type: '%',
|
|
15178
|
-
value: '0'
|
|
15179
|
-
};
|
|
15180
|
-
}
|
|
15181
|
-
|
|
15182
|
-
var previousIndex = 0;
|
|
15183
|
-
var previousOffset = Number(colorStops[0].length.value);
|
|
15184
|
-
|
|
15185
|
-
for (var i = 1; i < length; i++) {
|
|
15186
|
-
var _colorStops$i$length;
|
|
15187
|
-
|
|
15188
|
-
var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
|
|
15189
|
-
|
|
15190
|
-
if (!isNil(offset) && !isNil(previousOffset)) {
|
|
15191
|
-
for (var j = 1; j < i - previousIndex; j++) {
|
|
15192
|
-
colorStops[previousIndex + j].length = {
|
|
15193
|
-
type: '%',
|
|
15194
|
-
value: "" + (previousOffset + (Number(offset) - previousOffset) * j / (i - previousIndex))
|
|
15195
|
-
};
|
|
15196
|
-
}
|
|
15197
|
-
|
|
15198
|
-
previousIndex = i;
|
|
15199
|
-
previousOffset = Number(offset);
|
|
15200
|
-
}
|
|
15201
|
-
}
|
|
15202
|
-
} // The position of the gradient line's starting point.
|
|
15203
|
-
// different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
var SideOrCornerToDegMap = {
|
|
15207
|
-
left: 270 - 90,
|
|
15208
|
-
top: 0 - 90,
|
|
15209
|
-
bottom: 180 - 90,
|
|
15210
|
-
right: 90 - 90,
|
|
15211
|
-
'left top': 315 - 90,
|
|
15212
|
-
'top left': 315 - 90,
|
|
15213
|
-
'left bottom': 225 - 90,
|
|
15214
|
-
'bottom left': 225 - 90,
|
|
15215
|
-
'right top': 45 - 90,
|
|
15216
|
-
'top right': 45 - 90,
|
|
15217
|
-
'right bottom': 135 - 90,
|
|
15218
|
-
'bottom right': 135 - 90
|
|
15219
|
-
};
|
|
15220
|
-
var angleToDeg = memoize(function (orientation) {
|
|
15221
|
-
var angle;
|
|
15222
|
-
|
|
15223
|
-
if (orientation.type === 'angular') {
|
|
15224
|
-
angle = Number(orientation.value);
|
|
15225
|
-
} else {
|
|
15226
|
-
angle = SideOrCornerToDegMap[orientation.value] || 0;
|
|
15227
|
-
}
|
|
15228
|
-
|
|
15229
|
-
return angle;
|
|
15230
|
-
});
|
|
15231
|
-
var positonToPercentage = memoize(function (position) {
|
|
15232
|
-
var cx = 0.5;
|
|
15233
|
-
var cy = 0.5;
|
|
15234
|
-
|
|
15235
|
-
if ((position === null || position === void 0 ? void 0 : position.type) === 'position') {
|
|
15236
|
-
var _position$value = position.value,
|
|
15237
|
-
x = _position$value.x,
|
|
15238
|
-
y = _position$value.y;
|
|
15239
|
-
|
|
15240
|
-
if ((x === null || x === void 0 ? void 0 : x.type) === 'position-keyword') {
|
|
15241
|
-
if (x.value === 'left') {
|
|
15242
|
-
cx = 0;
|
|
15243
|
-
} else if (x.value === 'center') {
|
|
15244
|
-
cx = 0.5;
|
|
15245
|
-
} else if (x.value === 'right') {
|
|
15246
|
-
cx = 1;
|
|
15247
|
-
} else if (x.value === 'top') {
|
|
15248
|
-
cy = 0;
|
|
15249
|
-
} else if (x.value === 'bottom') {
|
|
15250
|
-
cy = 1;
|
|
15251
|
-
}
|
|
15252
|
-
}
|
|
15253
|
-
|
|
15254
|
-
if ((y === null || y === void 0 ? void 0 : y.type) === 'position-keyword') {
|
|
15255
|
-
if (y.value === 'left') {
|
|
15256
|
-
cx = 0;
|
|
15257
|
-
} else if (y.value === 'center') {
|
|
15258
|
-
cy = 0.5;
|
|
15259
|
-
} else if (y.value === 'right') {
|
|
15260
|
-
cx = 1;
|
|
15261
|
-
} else if (y.value === 'top') {
|
|
15262
|
-
cy = 0;
|
|
15263
|
-
} else if (y.value === 'bottom') {
|
|
15264
|
-
cy = 1;
|
|
15265
|
-
}
|
|
15266
|
-
}
|
|
15267
|
-
|
|
15268
|
-
if ((x === null || x === void 0 ? void 0 : x.type) === '%') {
|
|
15269
|
-
cx = Number(x.value) / 100;
|
|
15270
|
-
}
|
|
15271
|
-
|
|
15272
|
-
if ((y === null || y === void 0 ? void 0 : y.type) === '%') {
|
|
15273
|
-
cy = Number(x.value) / 100;
|
|
15274
|
-
}
|
|
15275
|
-
}
|
|
15276
|
-
|
|
15277
|
-
return {
|
|
15278
|
-
cx: cx,
|
|
15279
|
-
cy: cy
|
|
15280
|
-
};
|
|
15281
|
-
});
|
|
15282
|
-
var parseGradient$1 = memoize(function (colorStr) {
|
|
15283
|
-
if (colorStr.indexOf('linear') > -1 || colorStr.indexOf('radial') > -1) {
|
|
15284
|
-
var ast = parseGradient(colorStr);
|
|
15285
|
-
return ast.map(function (_ref) {
|
|
15286
|
-
var type = _ref.type,
|
|
15287
|
-
orientation = _ref.orientation,
|
|
15288
|
-
colorStops = _ref.colorStops;
|
|
15289
|
-
spaceColorStops(colorStops);
|
|
15290
|
-
var steps = colorStops.map(function (colorStop) {
|
|
15291
|
-
// TODO: only support % for now, should calc percentage of axis length when using px/em
|
|
15292
|
-
return [Number(colorStop.length.value) / 100, colorStopToString(colorStop)];
|
|
15293
|
-
});
|
|
15294
|
-
|
|
15295
|
-
if (type === 'linear-gradient') {
|
|
15296
|
-
return new CSSGradientValue(exports.GradientType.LinearGradient, {
|
|
15297
|
-
angle: orientation ? angleToDeg(orientation) : 0,
|
|
15298
|
-
steps: steps,
|
|
15299
|
-
hash: colorStr
|
|
15300
|
-
});
|
|
15301
|
-
} else if (type === 'radial-gradient') {
|
|
15302
|
-
if (!orientation) {
|
|
15303
|
-
orientation = [{
|
|
15304
|
-
type: 'shape',
|
|
15305
|
-
value: 'circle'
|
|
15306
|
-
}];
|
|
15307
|
-
}
|
|
15308
|
-
|
|
15309
|
-
if (orientation[0].type === 'shape' && orientation[0].value === 'circle') {
|
|
15310
|
-
var _positonToPercentage = positonToPercentage(orientation[0].at),
|
|
15311
|
-
cx = _positonToPercentage.cx,
|
|
15312
|
-
cy = _positonToPercentage.cy;
|
|
15313
|
-
|
|
15314
|
-
return new CSSGradientValue(exports.GradientType.RadialGradient, {
|
|
15315
|
-
cx: cx,
|
|
15316
|
-
cy: cy,
|
|
15317
|
-
steps: steps,
|
|
15318
|
-
hash: colorStr
|
|
15319
|
-
});
|
|
15320
|
-
} // } else if (type === 'repeating-linear-gradient') {
|
|
15321
|
-
// } else if (type === 'repeating-radial-gradient') {
|
|
15322
|
-
|
|
15323
|
-
}
|
|
15324
|
-
});
|
|
15325
|
-
} // legacy format, should be deprecated later
|
|
14640
|
+
}
|
|
14641
|
+
});
|
|
14642
|
+
} // legacy format, should be deprecated later
|
|
15326
14643
|
|
|
15327
14644
|
|
|
15328
14645
|
var type = colorStr[0];
|
|
@@ -16120,6 +15437,10 @@
|
|
|
16120
15437
|
*/
|
|
16121
15438
|
|
|
16122
15439
|
function parseLengthOrPercentage(css) {
|
|
15440
|
+
if (isNumber(css)) {
|
|
15441
|
+
return new CSSUnitValue(css, 'px');
|
|
15442
|
+
}
|
|
15443
|
+
|
|
16123
15444
|
return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
|
|
16124
15445
|
}
|
|
16125
15446
|
function parseAngle(css) {
|
|
@@ -16131,6 +15452,7 @@
|
|
|
16131
15452
|
* @example
|
|
16132
15453
|
* 10px + 20px = 30px
|
|
16133
15454
|
* 10deg + 10rad
|
|
15455
|
+
* 10% + 20% = 30%
|
|
16134
15456
|
*/
|
|
16135
15457
|
|
|
16136
15458
|
function mergeDimensions(left, right, target, nonNegative, index) {
|
|
@@ -16140,23 +15462,29 @@
|
|
|
16140
15462
|
|
|
16141
15463
|
var unit = '';
|
|
16142
15464
|
var leftValue = left.value || 0;
|
|
16143
|
-
var rightValue = right.value || 0;
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
if (
|
|
16149
|
-
leftValue =
|
|
16150
|
-
rightValue =
|
|
16151
|
-
unit =
|
|
16152
|
-
}
|
|
16153
|
-
|
|
15465
|
+
var rightValue = right.value || 0;
|
|
15466
|
+
var canonicalUnit = CSSUnitValue.toCanonicalUnit(left.unit);
|
|
15467
|
+
var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
|
|
15468
|
+
var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
|
|
15469
|
+
|
|
15470
|
+
if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
|
|
15471
|
+
leftValue = leftCanonicalUnitValue.value;
|
|
15472
|
+
rightValue = rightCanonicalUnitValue.value;
|
|
15473
|
+
unit = CSSUnitValue.unitTypeToString(left.unit);
|
|
15474
|
+
} else {
|
|
15475
|
+
// format '%' to 'px'
|
|
15476
|
+
if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
|
|
15477
|
+
leftValue = convertPercentUnit(left, index, target);
|
|
15478
|
+
rightValue = convertPercentUnit(right, index, target);
|
|
15479
|
+
unit = 'px';
|
|
15480
|
+
}
|
|
15481
|
+
} // // format 'rad' 'turn' to 'deg'
|
|
15482
|
+
// if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
|
|
15483
|
+
// leftValue = convertAngleUnit(left);
|
|
15484
|
+
// rightValue = convertAngleUnit(right);
|
|
15485
|
+
// unit = 'deg';
|
|
15486
|
+
// }
|
|
16154
15487
|
|
|
16155
|
-
if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
|
|
16156
|
-
leftValue = convertAngleUnit(left);
|
|
16157
|
-
rightValue = convertAngleUnit(right);
|
|
16158
|
-
unit = 'deg';
|
|
16159
|
-
}
|
|
16160
15488
|
|
|
16161
15489
|
return [leftValue, rightValue, function (value) {
|
|
16162
15490
|
if (nonNegative) {
|
|
@@ -16287,10 +15615,40 @@
|
|
|
16287
15615
|
}
|
|
16288
15616
|
|
|
16289
15617
|
function clonePath(path) {
|
|
16290
|
-
return path.map((x)
|
|
15618
|
+
return path.map(function (x) { return (Array.isArray(x) ? __spreadArray([], x, true) : x); });
|
|
15619
|
+
}
|
|
15620
|
+
|
|
15621
|
+
/**
|
|
15622
|
+
* Rounds the values of a `PathArray` instance to
|
|
15623
|
+
* a specified amount of decimals and returns it.
|
|
15624
|
+
*/
|
|
15625
|
+
function roundPath(path, round) {
|
|
15626
|
+
if (round === 'off')
|
|
15627
|
+
return clonePath(path);
|
|
15628
|
+
// to round values to the power
|
|
15629
|
+
// the `round` value must be integer
|
|
15630
|
+
var pow = typeof round === 'number' && round >= 1 ? Math.pow(10, round) : 1;
|
|
15631
|
+
return path.map(function (pi) {
|
|
15632
|
+
var values = pi
|
|
15633
|
+
.slice(1)
|
|
15634
|
+
.map(Number)
|
|
15635
|
+
.map(function (n) { return (round ? Math.round(n * pow) / pow : Math.round(n)); });
|
|
15636
|
+
return __spreadArray([pi[0]], values, true);
|
|
15637
|
+
});
|
|
15638
|
+
}
|
|
15639
|
+
|
|
15640
|
+
/**
|
|
15641
|
+
* Returns a valid `d` attribute string value created
|
|
15642
|
+
* by rounding values and concatenating the `pathArray` segments.
|
|
15643
|
+
*/
|
|
15644
|
+
function path2String(path, round) {
|
|
15645
|
+
if (round === void 0) { round = 'off'; }
|
|
15646
|
+
return roundPath(path, round)
|
|
15647
|
+
.map(function (x) { return x[0] + x.slice(1).join(' '); })
|
|
15648
|
+
.join('');
|
|
16291
15649
|
}
|
|
16292
15650
|
|
|
16293
|
-
|
|
15651
|
+
var paramsParser = {
|
|
16294
15652
|
x1: 0,
|
|
16295
15653
|
y1: 0,
|
|
16296
15654
|
x2: 0,
|
|
@@ -16304,9 +15662,9 @@
|
|
|
16304
15662
|
function fixArc(pathArray, allPathCommands, i) {
|
|
16305
15663
|
if (pathArray[i].length > 7) {
|
|
16306
15664
|
pathArray[i].shift();
|
|
16307
|
-
|
|
15665
|
+
var pi = pathArray[i];
|
|
16308
15666
|
// const ni = i + 1;
|
|
16309
|
-
|
|
15667
|
+
var ni = i;
|
|
16310
15668
|
while (pi.length) {
|
|
16311
15669
|
// if created multiple C:s, their original seg is saved
|
|
16312
15670
|
allPathCommands[i] = 'A';
|
|
@@ -16317,7 +15675,7 @@
|
|
|
16317
15675
|
}
|
|
16318
15676
|
}
|
|
16319
15677
|
|
|
16320
|
-
|
|
15678
|
+
var paramsCount = {
|
|
16321
15679
|
a: 7,
|
|
16322
15680
|
c: 6,
|
|
16323
15681
|
h: 1,
|
|
@@ -16336,8 +15694,8 @@
|
|
|
16336
15694
|
*/
|
|
16337
15695
|
function isPathArray(path) {
|
|
16338
15696
|
return (Array.isArray(path) &&
|
|
16339
|
-
path.every((seg)
|
|
16340
|
-
|
|
15697
|
+
path.every(function (seg) {
|
|
15698
|
+
var lk = seg[0].toLowerCase();
|
|
16341
15699
|
return paramsCount[lk] === seg.length - 1 && 'achlmqstvz'.includes(lk);
|
|
16342
15700
|
}));
|
|
16343
15701
|
}
|
|
@@ -16349,7 +15707,10 @@
|
|
|
16349
15707
|
function isAbsoluteArray(path) {
|
|
16350
15708
|
return (isPathArray(path) &&
|
|
16351
15709
|
// @ts-ignore -- `isPathArray` also checks if it's `Array`
|
|
16352
|
-
path.every((
|
|
15710
|
+
path.every(function (_a) {
|
|
15711
|
+
var x = _a[0];
|
|
15712
|
+
return x === x.toUpperCase();
|
|
15713
|
+
}));
|
|
16353
15714
|
}
|
|
16354
15715
|
|
|
16355
15716
|
/**
|
|
@@ -16358,28 +15719,31 @@
|
|
|
16358
15719
|
* with absolute values.
|
|
16359
15720
|
*/
|
|
16360
15721
|
function isNormalizedArray(path) {
|
|
16361
|
-
return isAbsoluteArray(path) && path.every((
|
|
15722
|
+
return isAbsoluteArray(path) && path.every(function (_a) {
|
|
15723
|
+
var pc = _a[0];
|
|
15724
|
+
return 'ACLMQZ'.includes(pc);
|
|
15725
|
+
});
|
|
16362
15726
|
}
|
|
16363
15727
|
|
|
16364
15728
|
/**
|
|
16365
15729
|
* Breaks the parsing of a pathString once a segment is finalized.
|
|
16366
15730
|
*/
|
|
16367
15731
|
function finalizeSegment(path) {
|
|
16368
|
-
|
|
16369
|
-
|
|
16370
|
-
|
|
15732
|
+
var pathCommand = path.pathValue[path.segmentStart];
|
|
15733
|
+
var LK = pathCommand.toLowerCase();
|
|
15734
|
+
var data = path.data;
|
|
16371
15735
|
while (data.length >= paramsCount[LK]) {
|
|
16372
15736
|
// overloaded `moveTo`
|
|
16373
15737
|
// https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts
|
|
16374
15738
|
if (LK === 'm' && data.length > 2) {
|
|
16375
15739
|
// @ts-ignore
|
|
16376
|
-
path.segments.push([pathCommand,
|
|
15740
|
+
path.segments.push(__spreadArray([pathCommand], data.splice(0, 2), true));
|
|
16377
15741
|
LK = 'l';
|
|
16378
15742
|
pathCommand = pathCommand === 'm' ? 'l' : 'L';
|
|
16379
15743
|
}
|
|
16380
15744
|
else {
|
|
16381
15745
|
// @ts-ignore
|
|
16382
|
-
path.segments.push([pathCommand,
|
|
15746
|
+
path.segments.push(__spreadArray([pathCommand], data.splice(0, paramsCount[LK]), true));
|
|
16383
15747
|
}
|
|
16384
15748
|
if (!paramsCount[LK]) {
|
|
16385
15749
|
break;
|
|
@@ -16392,8 +15756,8 @@
|
|
|
16392
15756
|
* Usually a `large-arc-flag` or `sweep-flag`.
|
|
16393
15757
|
*/
|
|
16394
15758
|
function scanFlag(path) {
|
|
16395
|
-
|
|
16396
|
-
|
|
15759
|
+
var index = path.index, pathValue = path.pathValue;
|
|
15760
|
+
var code = pathValue.charCodeAt(index);
|
|
16397
15761
|
if (code === 0x30 /* 0 */) {
|
|
16398
15762
|
path.param = 0;
|
|
16399
15763
|
path.index += 1;
|
|
@@ -16404,7 +15768,7 @@
|
|
|
16404
15768
|
path.index += 1;
|
|
16405
15769
|
return;
|
|
16406
15770
|
}
|
|
16407
|
-
path.err =
|
|
15771
|
+
path.err = "[path-util]: invalid Arc flag \"" + pathValue[index] + "\", expecting 0 or 1 at index " + index;
|
|
16408
15772
|
}
|
|
16409
15773
|
|
|
16410
15774
|
/**
|
|
@@ -16423,16 +15787,16 @@
|
|
|
16423
15787
|
* every path command, negative numbers or floating point numbers.
|
|
16424
15788
|
*/
|
|
16425
15789
|
function scanParam(path) {
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
|
|
16431
|
-
|
|
16432
|
-
|
|
15790
|
+
var max = path.max, pathValue = path.pathValue, start = path.index;
|
|
15791
|
+
var index = start;
|
|
15792
|
+
var zeroFirst = false;
|
|
15793
|
+
var hasCeiling = false;
|
|
15794
|
+
var hasDecimal = false;
|
|
15795
|
+
var hasDot = false;
|
|
15796
|
+
var ch;
|
|
16433
15797
|
if (index >= max) {
|
|
16434
15798
|
// path.err = 'SvgPath: missed param (at pos ' + index + ')';
|
|
16435
|
-
path.err =
|
|
15799
|
+
path.err = "[path-util]: Invalid path value at index " + index + ", \"pathValue\" is missing param";
|
|
16436
15800
|
return;
|
|
16437
15801
|
}
|
|
16438
15802
|
ch = pathValue.charCodeAt(index);
|
|
@@ -16445,7 +15809,7 @@
|
|
|
16445
15809
|
// https://github.com/ariya/esprimas
|
|
16446
15810
|
if (!isDigit(ch) && ch !== 0x2e /* . */) {
|
|
16447
15811
|
// path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
|
|
16448
|
-
path.err =
|
|
15812
|
+
path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" is not a number";
|
|
16449
15813
|
return;
|
|
16450
15814
|
}
|
|
16451
15815
|
if (ch !== 0x2e /* . */) {
|
|
@@ -16457,7 +15821,7 @@
|
|
|
16457
15821
|
if (ch && isDigit(ch)) {
|
|
16458
15822
|
// path.err = 'SvgPath: numbers started with `0` such as `09`
|
|
16459
15823
|
// are illegal (at pos ' + start + ')';
|
|
16460
|
-
path.err =
|
|
15824
|
+
path.err = "[path-util]: Invalid path value at index " + start + ", \"" + pathValue[start] + "\" illegal number";
|
|
16461
15825
|
return;
|
|
16462
15826
|
}
|
|
16463
15827
|
}
|
|
@@ -16478,7 +15842,7 @@
|
|
|
16478
15842
|
}
|
|
16479
15843
|
if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {
|
|
16480
15844
|
if (hasDot && !hasCeiling && !hasDecimal) {
|
|
16481
|
-
path.err =
|
|
15845
|
+
path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" invalid float exponent";
|
|
16482
15846
|
return;
|
|
16483
15847
|
}
|
|
16484
15848
|
index += 1;
|
|
@@ -16492,7 +15856,7 @@
|
|
|
16492
15856
|
}
|
|
16493
15857
|
}
|
|
16494
15858
|
else {
|
|
16495
|
-
path.err =
|
|
15859
|
+
path.err = "[path-util]: Invalid path value at index " + index + ", \"" + pathValue[index] + "\" invalid integer exponent";
|
|
16496
15860
|
return;
|
|
16497
15861
|
}
|
|
16498
15862
|
}
|
|
@@ -16504,7 +15868,7 @@
|
|
|
16504
15868
|
* Checks if the character is a space.
|
|
16505
15869
|
*/
|
|
16506
15870
|
function isSpace(ch) {
|
|
16507
|
-
|
|
15871
|
+
var specialSpaces = [
|
|
16508
15872
|
0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f,
|
|
16509
15873
|
0x205f, 0x3000, 0xfeff,
|
|
16510
15874
|
];
|
|
@@ -16528,7 +15892,7 @@
|
|
|
16528
15892
|
* space character.
|
|
16529
15893
|
*/
|
|
16530
15894
|
function skipSpaces(path) {
|
|
16531
|
-
|
|
15895
|
+
var pathValue = path.pathValue, max = path.max;
|
|
16532
15896
|
while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {
|
|
16533
15897
|
path.index += 1;
|
|
16534
15898
|
}
|
|
@@ -16569,12 +15933,12 @@
|
|
|
16569
15933
|
* where a segment starts and where it ends.
|
|
16570
15934
|
*/
|
|
16571
15935
|
function scanSegment(path) {
|
|
16572
|
-
|
|
16573
|
-
|
|
16574
|
-
|
|
15936
|
+
var max = path.max, pathValue = path.pathValue, index = path.index;
|
|
15937
|
+
var cmdCode = pathValue.charCodeAt(index);
|
|
15938
|
+
var reqParams = paramsCount[pathValue[index].toLowerCase()];
|
|
16575
15939
|
path.segmentStart = index;
|
|
16576
15940
|
if (!isPathCommand(cmdCode)) {
|
|
16577
|
-
path.err =
|
|
15941
|
+
path.err = "[path-util]: Invalid path value \"" + pathValue[index] + "\" is not a path command";
|
|
16578
15942
|
return;
|
|
16579
15943
|
}
|
|
16580
15944
|
path.index += 1;
|
|
@@ -16586,7 +15950,7 @@
|
|
|
16586
15950
|
return;
|
|
16587
15951
|
}
|
|
16588
15952
|
for (;;) {
|
|
16589
|
-
for (
|
|
15953
|
+
for (var i = reqParams; i > 0; i -= 1) {
|
|
16590
15954
|
if (isArcCommand(cmdCode) && (i === 3 || i === 4))
|
|
16591
15955
|
scanFlag(path);
|
|
16592
15956
|
else
|
|
@@ -16617,8 +15981,8 @@
|
|
|
16617
15981
|
* The `PathParser` is used by the `parsePathString` static method
|
|
16618
15982
|
* to generate a `pathArray`.
|
|
16619
15983
|
*/
|
|
16620
|
-
|
|
16621
|
-
|
|
15984
|
+
var PathParser = /** @class */ (function () {
|
|
15985
|
+
function PathParser(pathString) {
|
|
16622
15986
|
this.pathValue = pathString;
|
|
16623
15987
|
// @ts-ignore
|
|
16624
15988
|
this.segments = [];
|
|
@@ -16629,7 +15993,8 @@
|
|
|
16629
15993
|
this.data = [];
|
|
16630
15994
|
this.err = '';
|
|
16631
15995
|
}
|
|
16632
|
-
|
|
15996
|
+
return PathParser;
|
|
15997
|
+
}());
|
|
16633
15998
|
|
|
16634
15999
|
/**
|
|
16635
16000
|
* Parses a path string value and returns an array
|
|
@@ -16639,7 +16004,7 @@
|
|
|
16639
16004
|
if (isPathArray(pathInput)) {
|
|
16640
16005
|
return clonePath(pathInput);
|
|
16641
16006
|
}
|
|
16642
|
-
|
|
16007
|
+
var path = new PathParser(pathInput);
|
|
16643
16008
|
skipSpaces(path);
|
|
16644
16009
|
while (path.index < path.max && !path.err.length) {
|
|
16645
16010
|
scanSegment(path);
|
|
@@ -16651,26 +16016,26 @@
|
|
|
16651
16016
|
if (isAbsoluteArray(pathInput)) {
|
|
16652
16017
|
return clonePath(pathInput);
|
|
16653
16018
|
}
|
|
16654
|
-
|
|
16019
|
+
var path = parsePathString(pathInput);
|
|
16655
16020
|
// if (!path || !path.length) {
|
|
16656
16021
|
// return [['M', 0, 0]];
|
|
16657
16022
|
// }
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
|
|
16023
|
+
var x = 0;
|
|
16024
|
+
var y = 0;
|
|
16025
|
+
var mx = 0;
|
|
16026
|
+
var my = 0;
|
|
16662
16027
|
// @ts-ignore
|
|
16663
|
-
return path.map((segment)
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16028
|
+
return path.map(function (segment) {
|
|
16029
|
+
var values = segment.slice(1).map(Number);
|
|
16030
|
+
var pathCommand = segment[0];
|
|
16031
|
+
var absCommand = pathCommand.toUpperCase();
|
|
16667
16032
|
if (pathCommand === 'M') {
|
|
16668
|
-
[
|
|
16033
|
+
x = values[0], y = values[1];
|
|
16669
16034
|
mx = x;
|
|
16670
16035
|
my = y;
|
|
16671
16036
|
return ['M', x, y];
|
|
16672
16037
|
}
|
|
16673
|
-
|
|
16038
|
+
var absoluteSegment;
|
|
16674
16039
|
if (pathCommand !== absCommand) {
|
|
16675
16040
|
switch (absCommand) {
|
|
16676
16041
|
case 'A':
|
|
@@ -16694,26 +16059,26 @@
|
|
|
16694
16059
|
default: {
|
|
16695
16060
|
// use brakets for `eslint: no-case-declaration`
|
|
16696
16061
|
// https://stackoverflow.com/a/50753272/803358
|
|
16697
|
-
|
|
16062
|
+
var absValues = values.map(function (n, j) { return n + (j % 2 ? y : x); });
|
|
16698
16063
|
// for n, l, c, s, q, t
|
|
16699
|
-
absoluteSegment = [absCommand,
|
|
16064
|
+
absoluteSegment = __spreadArray([absCommand], absValues, true);
|
|
16700
16065
|
}
|
|
16701
16066
|
}
|
|
16702
16067
|
}
|
|
16703
16068
|
else {
|
|
16704
|
-
absoluteSegment = [absCommand,
|
|
16069
|
+
absoluteSegment = __spreadArray([absCommand], values, true);
|
|
16705
16070
|
}
|
|
16706
|
-
|
|
16071
|
+
var segLength = absoluteSegment.length;
|
|
16707
16072
|
switch (absCommand) {
|
|
16708
16073
|
case 'Z':
|
|
16709
16074
|
x = mx;
|
|
16710
16075
|
y = my;
|
|
16711
16076
|
break;
|
|
16712
16077
|
case 'H':
|
|
16713
|
-
|
|
16078
|
+
x = absoluteSegment[1];
|
|
16714
16079
|
break;
|
|
16715
16080
|
case 'V':
|
|
16716
|
-
|
|
16081
|
+
y = absoluteSegment[1];
|
|
16717
16082
|
break;
|
|
16718
16083
|
default:
|
|
16719
16084
|
x = absoluteSegment[segLength - 2];
|
|
@@ -16732,10 +16097,10 @@
|
|
|
16732
16097
|
* eg. H/V -> L, T -> Q
|
|
16733
16098
|
*/
|
|
16734
16099
|
function normalizeSegment(segment, params) {
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
|
|
16100
|
+
var pathCommand = segment[0];
|
|
16101
|
+
var px1 = params.x1, py1 = params.y1, px2 = params.x2, py2 = params.y2;
|
|
16102
|
+
var values = segment.slice(1).map(Number);
|
|
16103
|
+
var result = segment;
|
|
16739
16104
|
if (!'TQ'.includes(pathCommand)) {
|
|
16740
16105
|
// optional but good to be cautious
|
|
16741
16106
|
params.qx = null;
|
|
@@ -16748,21 +16113,21 @@
|
|
|
16748
16113
|
result = ['L', px1, segment[1]];
|
|
16749
16114
|
}
|
|
16750
16115
|
else if (pathCommand === 'S') {
|
|
16751
|
-
|
|
16752
|
-
|
|
16116
|
+
var x1 = px1 * 2 - px2;
|
|
16117
|
+
var y1 = py1 * 2 - py2;
|
|
16753
16118
|
params.x1 = x1;
|
|
16754
16119
|
params.y1 = y1;
|
|
16755
|
-
result = ['C', x1, y1,
|
|
16120
|
+
result = __spreadArray(['C', x1, y1], values, true);
|
|
16756
16121
|
}
|
|
16757
16122
|
else if (pathCommand === 'T') {
|
|
16758
|
-
|
|
16759
|
-
|
|
16123
|
+
var qx = px1 * 2 - params.qx;
|
|
16124
|
+
var qy = py1 * 2 - params.qy;
|
|
16760
16125
|
params.qx = qx;
|
|
16761
16126
|
params.qy = qy;
|
|
16762
|
-
result = ['Q', qx, qy,
|
|
16127
|
+
result = __spreadArray(['Q', qx, qy], values, true);
|
|
16763
16128
|
}
|
|
16764
16129
|
else if (pathCommand === 'Q') {
|
|
16765
|
-
|
|
16130
|
+
var nqx = values[0], nqy = values[1];
|
|
16766
16131
|
params.qx = nqx;
|
|
16767
16132
|
params.qy = nqy;
|
|
16768
16133
|
}
|
|
@@ -16779,18 +16144,18 @@
|
|
|
16779
16144
|
if (isNormalizedArray(pathInput)) {
|
|
16780
16145
|
return clonePath(pathInput);
|
|
16781
16146
|
}
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
|
|
16785
|
-
|
|
16786
|
-
|
|
16787
|
-
for (
|
|
16788
|
-
|
|
16147
|
+
var path = path2Absolute(pathInput);
|
|
16148
|
+
var params = __assign({}, paramsParser);
|
|
16149
|
+
var allPathCommands = [];
|
|
16150
|
+
var ii = path.length;
|
|
16151
|
+
var pathCommand = '';
|
|
16152
|
+
for (var i = 0; i < ii; i += 1) {
|
|
16153
|
+
pathCommand = path[i][0];
|
|
16789
16154
|
// Save current path command
|
|
16790
16155
|
allPathCommands[i] = pathCommand;
|
|
16791
16156
|
path[i] = normalizeSegment(path[i], params);
|
|
16792
|
-
|
|
16793
|
-
|
|
16157
|
+
var segment = path[i];
|
|
16158
|
+
var seglen = segment.length;
|
|
16794
16159
|
params.x1 = +segment[seglen - 2];
|
|
16795
16160
|
params.y1 = +segment[seglen - 1];
|
|
16796
16161
|
params.x2 = +segment[seglen - 4] || params.x1;
|
|
@@ -16807,12 +16172,15 @@
|
|
|
16807
16172
|
* @returns {boolean} iteration result
|
|
16808
16173
|
*/
|
|
16809
16174
|
function isCurveArray(path) {
|
|
16810
|
-
return isNormalizedArray(path) && path.every((
|
|
16175
|
+
return isNormalizedArray(path) && path.every(function (_a) {
|
|
16176
|
+
var pc = _a[0];
|
|
16177
|
+
return 'MC'.includes(pc);
|
|
16178
|
+
});
|
|
16811
16179
|
}
|
|
16812
16180
|
|
|
16813
16181
|
function rotateVector(x, y, rad) {
|
|
16814
|
-
|
|
16815
|
-
|
|
16182
|
+
var X = x * Math.cos(rad) - y * Math.sin(rad);
|
|
16183
|
+
var Y = x * Math.sin(rad) + y * Math.cos(rad);
|
|
16816
16184
|
return { x: X, y: Y };
|
|
16817
16185
|
}
|
|
16818
16186
|
|
|
@@ -16823,23 +16191,23 @@
|
|
|
16823
16191
|
* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
|
16824
16192
|
*/
|
|
16825
16193
|
function arcToCubic(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, recursive) {
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
16194
|
+
var x1 = X1;
|
|
16195
|
+
var y1 = Y1;
|
|
16196
|
+
var rx = RX;
|
|
16197
|
+
var ry = RY;
|
|
16198
|
+
var x2 = X2;
|
|
16199
|
+
var y2 = Y2;
|
|
16832
16200
|
// for more information of where this Math came from visit:
|
|
16833
16201
|
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
|
16834
|
-
|
|
16835
|
-
|
|
16202
|
+
var d120 = (Math.PI * 120) / 180;
|
|
16203
|
+
var rad = (Math.PI / 180) * (+angle || 0);
|
|
16836
16204
|
/** @type {number[]} */
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
|
|
16842
|
-
|
|
16205
|
+
var res = [];
|
|
16206
|
+
var xy;
|
|
16207
|
+
var f1;
|
|
16208
|
+
var f2;
|
|
16209
|
+
var cx;
|
|
16210
|
+
var cy;
|
|
16843
16211
|
if (!recursive) {
|
|
16844
16212
|
xy = rotateVector(x1, y1, -rad);
|
|
16845
16213
|
x1 = xy.x;
|
|
@@ -16847,17 +16215,17 @@
|
|
|
16847
16215
|
xy = rotateVector(x2, y2, -rad);
|
|
16848
16216
|
x2 = xy.x;
|
|
16849
16217
|
y2 = xy.y;
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16218
|
+
var x = (x1 - x2) / 2;
|
|
16219
|
+
var y = (y1 - y2) / 2;
|
|
16220
|
+
var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
|
|
16853
16221
|
if (h > 1) {
|
|
16854
16222
|
h = Math.sqrt(h);
|
|
16855
16223
|
rx *= h;
|
|
16856
16224
|
ry *= h;
|
|
16857
16225
|
}
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16226
|
+
var rx2 = rx * rx;
|
|
16227
|
+
var ry2 = ry * ry;
|
|
16228
|
+
var k = (LAF === SF ? -1 : 1) *
|
|
16861
16229
|
Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
|
|
16862
16230
|
cx = (k * rx * y) / ry + (x1 + x2) / 2;
|
|
16863
16231
|
cy = (k * -ry * x) / rx + (y1 + y2) / 2;
|
|
@@ -16879,38 +16247,38 @@
|
|
|
16879
16247
|
}
|
|
16880
16248
|
}
|
|
16881
16249
|
else {
|
|
16882
|
-
[
|
|
16250
|
+
f1 = recursive[0], f2 = recursive[1], cx = recursive[2], cy = recursive[3];
|
|
16883
16251
|
}
|
|
16884
|
-
|
|
16252
|
+
var df = f2 - f1;
|
|
16885
16253
|
if (Math.abs(df) > d120) {
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16254
|
+
var f2old = f2;
|
|
16255
|
+
var x2old = x2;
|
|
16256
|
+
var y2old = y2;
|
|
16889
16257
|
f2 = f1 + d120 * (SF && f2 > f1 ? 1 : -1);
|
|
16890
16258
|
x2 = cx + rx * Math.cos(f2);
|
|
16891
16259
|
y2 = cy + ry * Math.sin(f2);
|
|
16892
16260
|
res = arcToCubic(x2, y2, rx, ry, angle, 0, SF, x2old, y2old, [f2, f2old, cx, cy]);
|
|
16893
16261
|
}
|
|
16894
16262
|
df = f2 - f1;
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16263
|
+
var c1 = Math.cos(f1);
|
|
16264
|
+
var s1 = Math.sin(f1);
|
|
16265
|
+
var c2 = Math.cos(f2);
|
|
16266
|
+
var s2 = Math.sin(f2);
|
|
16267
|
+
var t = Math.tan(df / 4);
|
|
16268
|
+
var hx = (4 / 3) * rx * t;
|
|
16269
|
+
var hy = (4 / 3) * ry * t;
|
|
16270
|
+
var m1 = [x1, y1];
|
|
16271
|
+
var m2 = [x1 + hx * s1, y1 - hy * c1];
|
|
16272
|
+
var m3 = [x2 + hx * s2, y2 - hy * c2];
|
|
16273
|
+
var m4 = [x2, y2];
|
|
16906
16274
|
m2[0] = 2 * m1[0] - m2[0];
|
|
16907
16275
|
m2[1] = 2 * m1[1] - m2[1];
|
|
16908
16276
|
if (recursive) {
|
|
16909
|
-
return [
|
|
16277
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], m2, true), m3, true), m4, true), res, true);
|
|
16910
16278
|
}
|
|
16911
|
-
res = [
|
|
16912
|
-
|
|
16913
|
-
for (
|
|
16279
|
+
res = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], m2, true), m3, true), m4, true), res, true);
|
|
16280
|
+
var newres = [];
|
|
16281
|
+
for (var i = 0, ii = res.length; i < ii; i += 1) {
|
|
16914
16282
|
newres[i] = i % 2 ? rotateVector(res[i - 1], res[i], rad).y : rotateVector(res[i], res[i + 1], rad).x;
|
|
16915
16283
|
}
|
|
16916
16284
|
return newres;
|
|
@@ -17099,8 +16467,8 @@
|
|
|
17099
16467
|
// }
|
|
17100
16468
|
|
|
17101
16469
|
function quadToCubic(x1, y1, qx, qy, x2, y2) {
|
|
17102
|
-
|
|
17103
|
-
|
|
16470
|
+
var r13 = 1 / 3;
|
|
16471
|
+
var r23 = 2 / 3;
|
|
17104
16472
|
return [
|
|
17105
16473
|
r13 * x1 + r23 * qx,
|
|
17106
16474
|
r13 * y1 + r23 * qy,
|
|
@@ -17112,10 +16480,10 @@
|
|
|
17112
16480
|
}
|
|
17113
16481
|
|
|
17114
16482
|
function midPoint(a, b, t) {
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17118
|
-
|
|
16483
|
+
var ax = a[0];
|
|
16484
|
+
var ay = a[1];
|
|
16485
|
+
var bx = b[0];
|
|
16486
|
+
var by = b[1];
|
|
17119
16487
|
return [ax + (bx - ax) * t, ay + (by - ay) * t];
|
|
17120
16488
|
}
|
|
17121
16489
|
|
|
@@ -17128,8 +16496,8 @@
|
|
|
17128
16496
|
* the minimum and maximum {x,y} coordinates of a line (L,V,H,Z) segment.
|
|
17129
16497
|
*/
|
|
17130
16498
|
function segmentLineFactory(x1, y1, x2, y2, distance) {
|
|
17131
|
-
|
|
17132
|
-
|
|
16499
|
+
var length = distanceSquareRoot([x1, y1], [x2, y2]);
|
|
16500
|
+
var point = { x: 0, y: 0 };
|
|
17133
16501
|
if (typeof distance === 'number') {
|
|
17134
16502
|
if (distance <= 0) {
|
|
17135
16503
|
point = { x: x1, y: y1 };
|
|
@@ -17138,13 +16506,13 @@
|
|
|
17138
16506
|
point = { x: x2, y: y2 };
|
|
17139
16507
|
}
|
|
17140
16508
|
else {
|
|
17141
|
-
|
|
17142
|
-
point = { x, y };
|
|
16509
|
+
var _a = midPoint([x1, y1], [x2, y2], distance / length), x = _a[0], y = _a[1];
|
|
16510
|
+
point = { x: x, y: y };
|
|
17143
16511
|
}
|
|
17144
16512
|
}
|
|
17145
16513
|
return {
|
|
17146
|
-
length,
|
|
17147
|
-
point,
|
|
16514
|
+
length: length,
|
|
16515
|
+
point: point,
|
|
17148
16516
|
min: {
|
|
17149
16517
|
x: Math.min(x1, x2),
|
|
17150
16518
|
y: Math.min(y1, y2),
|
|
@@ -17157,29 +16525,29 @@
|
|
|
17157
16525
|
}
|
|
17158
16526
|
|
|
17159
16527
|
function lineToCubic(x1, y1, x2, y2) {
|
|
17160
|
-
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
16528
|
+
var t = 0.5;
|
|
16529
|
+
var p0 = [x1, y1];
|
|
16530
|
+
var p1 = [x2, y2];
|
|
16531
|
+
var p2 = midPoint(p0, p1, t);
|
|
16532
|
+
var p3 = midPoint(p1, p2, t);
|
|
16533
|
+
var p4 = midPoint(p2, p3, t);
|
|
16534
|
+
var p5 = midPoint(p3, p4, t);
|
|
16535
|
+
var p6 = midPoint(p4, p5, t);
|
|
16536
|
+
var seg1 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], p0, true), p2, true), p4, true), p6, true), [t], false);
|
|
17169
16537
|
// @ts-ignore
|
|
17170
|
-
|
|
17171
|
-
|
|
16538
|
+
var cp1 = segmentLineFactory.apply(void 0, seg1).point;
|
|
16539
|
+
var seg2 = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], p6, true), p5, true), p3, true), p1, true), [0], false);
|
|
17172
16540
|
// @ts-ignore
|
|
17173
|
-
|
|
16541
|
+
var cp2 = segmentLineFactory.apply(void 0, seg2).point;
|
|
17174
16542
|
return [cp1.x, cp1.y, cp2.x, cp2.y, x2, y2];
|
|
17175
16543
|
}
|
|
17176
16544
|
|
|
17177
16545
|
function segmentToCubic(segment, params) {
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
16546
|
+
var pathCommand = segment[0];
|
|
16547
|
+
var values = segment.slice(1).map(Number);
|
|
16548
|
+
var x = values[0], y = values[1];
|
|
16549
|
+
var args;
|
|
16550
|
+
var px1 = params.x1, py1 = params.y1, px = params.x, py = params.y;
|
|
17183
16551
|
if (!'TQ'.includes(pathCommand)) {
|
|
17184
16552
|
params.qx = null;
|
|
17185
16553
|
params.qy = null;
|
|
@@ -17190,31 +16558,32 @@
|
|
|
17190
16558
|
params.y = y;
|
|
17191
16559
|
return segment;
|
|
17192
16560
|
case 'A':
|
|
17193
|
-
args = [px1, py1,
|
|
16561
|
+
args = __spreadArray([px1, py1], values, true);
|
|
17194
16562
|
// @ts-ignore
|
|
17195
|
-
return ['C',
|
|
16563
|
+
return __spreadArray(['C'], arcToCubic.apply(void 0, args), true);
|
|
17196
16564
|
case 'Q':
|
|
17197
16565
|
params.qx = x;
|
|
17198
16566
|
params.qy = y;
|
|
17199
|
-
args = [px1, py1,
|
|
16567
|
+
args = __spreadArray([px1, py1], values, true);
|
|
17200
16568
|
// @ts-ignore
|
|
17201
|
-
return ['C',
|
|
16569
|
+
return __spreadArray(['C'], quadToCubic.apply(void 0, args), true);
|
|
17202
16570
|
case 'L':
|
|
17203
|
-
return ['C',
|
|
16571
|
+
return __spreadArray(['C'], lineToCubic(px1, py1, x, y), true);
|
|
17204
16572
|
case 'Z':
|
|
17205
16573
|
// prevent NaN from divide 0
|
|
17206
16574
|
if (px1 === px && py1 === py) {
|
|
17207
16575
|
return ['C', px1, py1, px, py, px, py];
|
|
17208
16576
|
}
|
|
17209
|
-
return ['C',
|
|
16577
|
+
return __spreadArray(['C'], lineToCubic(px1, py1, px, py), true);
|
|
17210
16578
|
}
|
|
17211
16579
|
return segment;
|
|
17212
16580
|
}
|
|
17213
16581
|
|
|
17214
16582
|
// import { fixPath } from '../process/fix-path';
|
|
17215
|
-
function path2Curve(pathInput, needZCommandIndexes
|
|
16583
|
+
function path2Curve(pathInput, needZCommandIndexes) {
|
|
16584
|
+
if (needZCommandIndexes === void 0) { needZCommandIndexes = false; }
|
|
17216
16585
|
if (isCurveArray(pathInput)) {
|
|
17217
|
-
|
|
16586
|
+
var cloned = clonePath(pathInput);
|
|
17218
16587
|
if (needZCommandIndexes) {
|
|
17219
16588
|
return [cloned, []];
|
|
17220
16589
|
}
|
|
@@ -17224,19 +16593,19 @@
|
|
|
17224
16593
|
}
|
|
17225
16594
|
// fixPath will remove 'Z' command
|
|
17226
16595
|
// const path = fixPath(normalizePath(pathInput));
|
|
17227
|
-
|
|
17228
|
-
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
for (
|
|
16596
|
+
var path = normalizePath(pathInput);
|
|
16597
|
+
var params = __assign({}, paramsParser);
|
|
16598
|
+
var allPathCommands = [];
|
|
16599
|
+
var pathCommand = '';
|
|
16600
|
+
var ii = path.length;
|
|
16601
|
+
var segment;
|
|
16602
|
+
var seglen;
|
|
16603
|
+
var zCommandIndexes = [];
|
|
16604
|
+
for (var i = 0; i < ii; i += 1) {
|
|
17236
16605
|
if (path[i])
|
|
17237
|
-
|
|
16606
|
+
pathCommand = path[i][0];
|
|
17238
16607
|
allPathCommands[i] = pathCommand;
|
|
17239
|
-
|
|
16608
|
+
var curveSegment = segmentToCubic(path[i], params);
|
|
17240
16609
|
path[i] = curveSegment;
|
|
17241
16610
|
fixArc(path, allPathCommands, i);
|
|
17242
16611
|
ii = path.length; // solves curveArrays ending in Z
|
|
@@ -17263,24 +16632,25 @@
|
|
|
17263
16632
|
|
|
17264
16633
|
// reverse CURVE based pathArray segments only
|
|
17265
16634
|
function reverseCurve(pathArray) {
|
|
17266
|
-
|
|
16635
|
+
var rotatedCurve = pathArray
|
|
17267
16636
|
.slice(1)
|
|
17268
|
-
.map((x, i, curveOnly)
|
|
17269
|
-
// @ts-ignore
|
|
17270
|
-
!i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1)))
|
|
16637
|
+
.map(function (x, i, curveOnly) {
|
|
17271
16638
|
// @ts-ignore
|
|
17272
|
-
.
|
|
16639
|
+
return !i ? pathArray[0].slice(1).concat(x.slice(1)) : curveOnly[i - 1].slice(-2).concat(x.slice(1));
|
|
16640
|
+
})
|
|
16641
|
+
// @ts-ignore
|
|
16642
|
+
.map(function (x) { return x.map(function (y, i) { return x[x.length - i - 2 * (1 - (i % 2))]; }); })
|
|
17273
16643
|
.reverse();
|
|
17274
|
-
return [['M'].concat(rotatedCurve[0].slice(0, 2))].concat(rotatedCurve.map((x)
|
|
16644
|
+
return [['M'].concat(rotatedCurve[0].slice(0, 2))].concat(rotatedCurve.map(function (x) { return ['C'].concat(x.slice(2)); }));
|
|
17275
16645
|
}
|
|
17276
16646
|
|
|
17277
16647
|
function angleBetween(v0, v1) {
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
16648
|
+
var v0x = v0.x, v0y = v0.y;
|
|
16649
|
+
var v1x = v1.x, v1y = v1.y;
|
|
16650
|
+
var p = v0x * v1x + v0y * v1y;
|
|
16651
|
+
var n = Math.sqrt((Math.pow(v0x, 2) + Math.pow(v0y, 2)) * (Math.pow(v1x, 2) + Math.pow(v1y, 2)));
|
|
16652
|
+
var sign = v0x * v1y - v0y * v1x < 0 ? -1 : 1;
|
|
16653
|
+
var angle = sign * Math.acos(p / n);
|
|
17284
16654
|
return angle;
|
|
17285
16655
|
}
|
|
17286
16656
|
/**
|
|
@@ -17289,51 +16659,51 @@
|
|
|
17289
16659
|
* @see https://github.com/MadLittleMods/svg-curve-lib/blob/master/src/js/svg-curve-lib.js
|
|
17290
16660
|
*/
|
|
17291
16661
|
function getPointAtArcSegmentLength(x1, y1, RX, RY, angle, LAF, SF, x, y, t) {
|
|
17292
|
-
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
16662
|
+
var abs = Math.abs, sin = Math.sin, cos = Math.cos, sqrt = Math.sqrt, PI = Math.PI;
|
|
16663
|
+
var rx = abs(RX);
|
|
16664
|
+
var ry = abs(RY);
|
|
16665
|
+
var xRot = ((angle % 360) + 360) % 360;
|
|
16666
|
+
var xRotRad = xRot * (PI / 180);
|
|
17297
16667
|
if (x1 === x && y1 === y) {
|
|
17298
16668
|
return { x: x1, y: y1 };
|
|
17299
16669
|
}
|
|
17300
16670
|
if (rx === 0 || ry === 0) {
|
|
17301
16671
|
return segmentLineFactory(x1, y1, x, y, t).point;
|
|
17302
16672
|
}
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
|
|
16673
|
+
var dx = (x1 - x) / 2;
|
|
16674
|
+
var dy = (y1 - y) / 2;
|
|
16675
|
+
var transformedPoint = {
|
|
17306
16676
|
x: cos(xRotRad) * dx + sin(xRotRad) * dy,
|
|
17307
16677
|
y: -sin(xRotRad) * dx + cos(xRotRad) * dy,
|
|
17308
16678
|
};
|
|
17309
|
-
|
|
16679
|
+
var radiiCheck = Math.pow(transformedPoint.x, 2) / Math.pow(rx, 2) + Math.pow(transformedPoint.y, 2) / Math.pow(ry, 2);
|
|
17310
16680
|
if (radiiCheck > 1) {
|
|
17311
16681
|
rx *= sqrt(radiiCheck);
|
|
17312
16682
|
ry *= sqrt(radiiCheck);
|
|
17313
16683
|
}
|
|
17314
|
-
|
|
17315
|
-
|
|
17316
|
-
|
|
16684
|
+
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);
|
|
16685
|
+
var cSquareRootDenom = Math.pow(rx, 2) * Math.pow(transformedPoint.y, 2) + Math.pow(ry, 2) * Math.pow(transformedPoint.x, 2);
|
|
16686
|
+
var cRadicand = cSquareNumerator / cSquareRootDenom;
|
|
17317
16687
|
cRadicand = cRadicand < 0 ? 0 : cRadicand;
|
|
17318
|
-
|
|
17319
|
-
|
|
16688
|
+
var cCoef = (LAF !== SF ? 1 : -1) * sqrt(cRadicand);
|
|
16689
|
+
var transformedCenter = {
|
|
17320
16690
|
x: cCoef * ((rx * transformedPoint.y) / ry),
|
|
17321
16691
|
y: cCoef * (-(ry * transformedPoint.x) / rx),
|
|
17322
16692
|
};
|
|
17323
|
-
|
|
16693
|
+
var center = {
|
|
17324
16694
|
x: cos(xRotRad) * transformedCenter.x - sin(xRotRad) * transformedCenter.y + (x1 + x) / 2,
|
|
17325
16695
|
y: sin(xRotRad) * transformedCenter.x + cos(xRotRad) * transformedCenter.y + (y1 + y) / 2,
|
|
17326
16696
|
};
|
|
17327
|
-
|
|
16697
|
+
var startVector = {
|
|
17328
16698
|
x: (transformedPoint.x - transformedCenter.x) / rx,
|
|
17329
16699
|
y: (transformedPoint.y - transformedCenter.y) / ry,
|
|
17330
16700
|
};
|
|
17331
|
-
|
|
17332
|
-
|
|
16701
|
+
var startAngle = angleBetween({ x: 1, y: 0 }, startVector);
|
|
16702
|
+
var endVector = {
|
|
17333
16703
|
x: (-transformedPoint.x - transformedCenter.x) / rx,
|
|
17334
16704
|
y: (-transformedPoint.y - transformedCenter.y) / ry,
|
|
17335
16705
|
};
|
|
17336
|
-
|
|
16706
|
+
var sweepAngle = angleBetween(startVector, endVector);
|
|
17337
16707
|
if (!SF && sweepAngle > 0) {
|
|
17338
16708
|
sweepAngle -= 2 * PI;
|
|
17339
16709
|
}
|
|
@@ -17341,10 +16711,10 @@
|
|
|
17341
16711
|
sweepAngle += 2 * PI;
|
|
17342
16712
|
}
|
|
17343
16713
|
sweepAngle %= 2 * PI;
|
|
17344
|
-
|
|
17345
|
-
|
|
17346
|
-
|
|
17347
|
-
|
|
16714
|
+
var alpha = startAngle + sweepAngle * t;
|
|
16715
|
+
var ellipseComponentX = rx * cos(alpha);
|
|
16716
|
+
var ellipseComponentY = ry * sin(alpha);
|
|
16717
|
+
var point = {
|
|
17348
16718
|
x: cos(xRotRad) * ellipseComponentX - sin(xRotRad) * ellipseComponentY + center.x,
|
|
17349
16719
|
y: sin(xRotRad) * ellipseComponentX + cos(xRotRad) * ellipseComponentY + center.y,
|
|
17350
16720
|
};
|
|
@@ -17362,27 +16732,28 @@
|
|
|
17362
16732
|
* the shape minimum and maximum {x,y} coordinates of an A (arc-to) segment.
|
|
17363
16733
|
*/
|
|
17364
16734
|
function segmentArcFactory(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, distance) {
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
16735
|
+
var _a;
|
|
16736
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
16737
|
+
var x = X1;
|
|
16738
|
+
var y = Y1;
|
|
16739
|
+
var LENGTH = 0;
|
|
16740
|
+
var prev = [x, y, LENGTH];
|
|
16741
|
+
var cur = [x, y];
|
|
16742
|
+
var t = 0;
|
|
16743
|
+
var POINT = { x: 0, y: 0 };
|
|
16744
|
+
var POINTS = [{ x: x, y: y }];
|
|
17374
16745
|
if (distanceIsNumber && distance <= 0) {
|
|
17375
|
-
POINT = { x, y };
|
|
16746
|
+
POINT = { x: x, y: y };
|
|
17376
16747
|
}
|
|
17377
|
-
|
|
17378
|
-
for (
|
|
16748
|
+
var sampleSize = 300;
|
|
16749
|
+
for (var j = 0; j <= sampleSize; j += 1) {
|
|
17379
16750
|
t = j / sampleSize;
|
|
17380
|
-
(
|
|
17381
|
-
POINTS = [
|
|
16751
|
+
(_a = getPointAtArcSegmentLength(X1, Y1, RX, RY, angle, LAF, SF, X2, Y2, t), x = _a.x, y = _a.y);
|
|
16752
|
+
POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
|
|
17382
16753
|
LENGTH += distanceSquareRoot(cur, [x, y]);
|
|
17383
16754
|
cur = [x, y];
|
|
17384
16755
|
if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
|
|
17385
|
-
|
|
16756
|
+
var dv = (LENGTH - distance) / (LENGTH - prev[2]);
|
|
17386
16757
|
POINT = {
|
|
17387
16758
|
x: cur[0] * (1 - dv) + prev[0] * dv,
|
|
17388
16759
|
y: cur[1] * (1 - dv) + prev[1] * dv,
|
|
@@ -17397,12 +16768,12 @@
|
|
|
17397
16768
|
length: LENGTH,
|
|
17398
16769
|
point: POINT,
|
|
17399
16770
|
min: {
|
|
17400
|
-
x: Math.min(
|
|
17401
|
-
y: Math.min(
|
|
16771
|
+
x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
|
|
16772
|
+
y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
|
|
17402
16773
|
},
|
|
17403
16774
|
max: {
|
|
17404
|
-
x: Math.max(
|
|
17405
|
-
y: Math.max(
|
|
16775
|
+
x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
|
|
16776
|
+
y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
|
|
17406
16777
|
},
|
|
17407
16778
|
};
|
|
17408
16779
|
}
|
|
@@ -17412,7 +16783,7 @@
|
|
|
17412
16783
|
* the minimum and maximum {x,y} coordinates of a C (cubic-bezier) segment.
|
|
17413
16784
|
*/
|
|
17414
16785
|
function getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t) {
|
|
17415
|
-
|
|
16786
|
+
var t1 = 1 - t;
|
|
17416
16787
|
return {
|
|
17417
16788
|
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,
|
|
17418
16789
|
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,
|
|
@@ -17423,28 +16794,29 @@
|
|
|
17423
16794
|
* or an {x,y} point at a given length.
|
|
17424
16795
|
*/
|
|
17425
16796
|
function segmentCubicFactory(x1, y1, c1x, c1y, c2x, c2y, x2, y2, distance) {
|
|
17426
|
-
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
-
|
|
17432
|
-
|
|
17433
|
-
|
|
17434
|
-
|
|
16797
|
+
var _a;
|
|
16798
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
16799
|
+
var x = x1;
|
|
16800
|
+
var y = y1;
|
|
16801
|
+
var LENGTH = 0;
|
|
16802
|
+
var prev = [x, y, LENGTH];
|
|
16803
|
+
var cur = [x, y];
|
|
16804
|
+
var t = 0;
|
|
16805
|
+
var POINT = { x: 0, y: 0 };
|
|
16806
|
+
var POINTS = [{ x: x, y: y }];
|
|
17435
16807
|
if (distanceIsNumber && distance <= 0) {
|
|
17436
|
-
POINT = { x, y };
|
|
16808
|
+
POINT = { x: x, y: y };
|
|
17437
16809
|
}
|
|
17438
16810
|
// bad perf when size = 300
|
|
17439
|
-
|
|
17440
|
-
for (
|
|
16811
|
+
var sampleSize = 20;
|
|
16812
|
+
for (var j = 0; j <= sampleSize; j += 1) {
|
|
17441
16813
|
t = j / sampleSize;
|
|
17442
|
-
(
|
|
17443
|
-
POINTS = [
|
|
16814
|
+
(_a = getPointAtCubicSegmentLength(x1, y1, c1x, c1y, c2x, c2y, x2, y2, t), x = _a.x, y = _a.y);
|
|
16815
|
+
POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
|
|
17444
16816
|
LENGTH += distanceSquareRoot(cur, [x, y]);
|
|
17445
16817
|
cur = [x, y];
|
|
17446
16818
|
if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
|
|
17447
|
-
|
|
16819
|
+
var dv = (LENGTH - distance) / (LENGTH - prev[2]);
|
|
17448
16820
|
POINT = {
|
|
17449
16821
|
x: cur[0] * (1 - dv) + prev[0] * dv,
|
|
17450
16822
|
y: cur[1] * (1 - dv) + prev[1] * dv,
|
|
@@ -17459,12 +16831,12 @@
|
|
|
17459
16831
|
length: LENGTH,
|
|
17460
16832
|
point: POINT,
|
|
17461
16833
|
min: {
|
|
17462
|
-
x: Math.min(
|
|
17463
|
-
y: Math.min(
|
|
16834
|
+
x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
|
|
16835
|
+
y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
|
|
17464
16836
|
},
|
|
17465
16837
|
max: {
|
|
17466
|
-
x: Math.max(
|
|
17467
|
-
y: Math.max(
|
|
16838
|
+
x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
|
|
16839
|
+
y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
|
|
17468
16840
|
},
|
|
17469
16841
|
};
|
|
17470
16842
|
}
|
|
@@ -17476,7 +16848,7 @@
|
|
|
17476
16848
|
* @see https://github.com/substack/point-at-length
|
|
17477
16849
|
*/
|
|
17478
16850
|
function getPointAtQuadSegmentLength(x1, y1, cx, cy, x2, y2, t) {
|
|
17479
|
-
|
|
16851
|
+
var t1 = 1 - t;
|
|
17480
16852
|
return {
|
|
17481
16853
|
x: Math.pow(t1, 2) * x1 + 2 * t1 * t * cx + Math.pow(t, 2) * x2,
|
|
17482
16854
|
y: Math.pow(t1, 2) * y1 + 2 * t1 * t * cy + Math.pow(t, 2) * y2,
|
|
@@ -17487,27 +16859,28 @@
|
|
|
17487
16859
|
* the minimum and maximum {x,y} coordinates of a Q (quadratic-bezier) segment.
|
|
17488
16860
|
*/
|
|
17489
16861
|
function segmentQuadFactory(x1, y1, qx, qy, x2, y2, distance) {
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17496
|
-
|
|
17497
|
-
|
|
17498
|
-
|
|
16862
|
+
var _a;
|
|
16863
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
16864
|
+
var x = x1;
|
|
16865
|
+
var y = y1;
|
|
16866
|
+
var LENGTH = 0;
|
|
16867
|
+
var prev = [x, y, LENGTH];
|
|
16868
|
+
var cur = [x, y];
|
|
16869
|
+
var t = 0;
|
|
16870
|
+
var POINT = { x: 0, y: 0 };
|
|
16871
|
+
var POINTS = [{ x: x, y: y }];
|
|
17499
16872
|
if (distanceIsNumber && distance <= 0) {
|
|
17500
|
-
POINT = { x, y };
|
|
16873
|
+
POINT = { x: x, y: y };
|
|
17501
16874
|
}
|
|
17502
|
-
|
|
17503
|
-
for (
|
|
16875
|
+
var sampleSize = 300;
|
|
16876
|
+
for (var j = 0; j <= sampleSize; j += 1) {
|
|
17504
16877
|
t = j / sampleSize;
|
|
17505
|
-
(
|
|
17506
|
-
POINTS = [
|
|
16878
|
+
(_a = getPointAtQuadSegmentLength(x1, y1, qx, qy, x2, y2, t), x = _a.x, y = _a.y);
|
|
16879
|
+
POINTS = __spreadArray(__spreadArray([], POINTS, true), [{ x: x, y: y }], false);
|
|
17507
16880
|
LENGTH += distanceSquareRoot(cur, [x, y]);
|
|
17508
16881
|
cur = [x, y];
|
|
17509
16882
|
if (distanceIsNumber && LENGTH > distance && distance > prev[2]) {
|
|
17510
|
-
|
|
16883
|
+
var dv = (LENGTH - distance) / (LENGTH - prev[2]);
|
|
17511
16884
|
POINT = {
|
|
17512
16885
|
x: cur[0] * (1 - dv) + prev[0] * dv,
|
|
17513
16886
|
y: cur[1] * (1 - dv) + prev[1] * dv,
|
|
@@ -17523,12 +16896,12 @@
|
|
|
17523
16896
|
length: LENGTH,
|
|
17524
16897
|
point: POINT,
|
|
17525
16898
|
min: {
|
|
17526
|
-
x: Math.min(
|
|
17527
|
-
y: Math.min(
|
|
16899
|
+
x: Math.min.apply(Math, POINTS.map(function (n) { return n.x; })),
|
|
16900
|
+
y: Math.min.apply(Math, POINTS.map(function (n) { return n.y; })),
|
|
17528
16901
|
},
|
|
17529
16902
|
max: {
|
|
17530
|
-
x: Math.max(
|
|
17531
|
-
y: Math.max(
|
|
16903
|
+
x: Math.max.apply(Math, POINTS.map(function (n) { return n.x; })),
|
|
16904
|
+
y: Math.max.apply(Math, POINTS.map(function (n) { return n.y; })),
|
|
17532
16905
|
},
|
|
17533
16906
|
};
|
|
17534
16907
|
}
|
|
@@ -17539,34 +16912,35 @@
|
|
|
17539
16912
|
* the shape minimum and maximum {x,y} coordinates.
|
|
17540
16913
|
*/
|
|
17541
16914
|
function pathLengthFactory(pathInput, distance) {
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
16915
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16916
|
+
var path = normalizePath(pathInput);
|
|
16917
|
+
var distanceIsNumber = typeof distance === 'number';
|
|
16918
|
+
var isM;
|
|
16919
|
+
var data = [];
|
|
16920
|
+
var pathCommand;
|
|
16921
|
+
var x = 0;
|
|
16922
|
+
var y = 0;
|
|
16923
|
+
var mx = 0;
|
|
16924
|
+
var my = 0;
|
|
16925
|
+
var seg;
|
|
16926
|
+
var MIN = [];
|
|
16927
|
+
var MAX = [];
|
|
16928
|
+
var length = 0;
|
|
16929
|
+
var min = { x: 0, y: 0 };
|
|
16930
|
+
var max = min;
|
|
16931
|
+
var point = min;
|
|
16932
|
+
var POINT = min;
|
|
16933
|
+
var LENGTH = 0;
|
|
16934
|
+
for (var i = 0, ll = path.length; i < ll; i += 1) {
|
|
17561
16935
|
seg = path[i];
|
|
17562
|
-
|
|
16936
|
+
pathCommand = seg[0];
|
|
17563
16937
|
isM = pathCommand === 'M';
|
|
17564
|
-
data = !isM ? [x, y,
|
|
16938
|
+
data = !isM ? __spreadArray([x, y], seg.slice(1), true) : data;
|
|
17565
16939
|
// this segment is always ZERO
|
|
17566
16940
|
/* istanbul ignore else */
|
|
17567
16941
|
if (isM) {
|
|
17568
16942
|
// remember mx, my for Z
|
|
17569
|
-
[,
|
|
16943
|
+
mx = seg[1], my = seg[2];
|
|
17570
16944
|
min = { x: mx, y: my };
|
|
17571
16945
|
max = min;
|
|
17572
16946
|
length = 0;
|
|
@@ -17576,48 +16950,48 @@
|
|
|
17576
16950
|
}
|
|
17577
16951
|
else if (pathCommand === 'L') {
|
|
17578
16952
|
// @ts-ignore
|
|
17579
|
-
(
|
|
16953
|
+
(_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);
|
|
17580
16954
|
}
|
|
17581
16955
|
else if (pathCommand === 'A') {
|
|
17582
16956
|
// @ts-ignore
|
|
17583
|
-
(
|
|
16957
|
+
(_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);
|
|
17584
16958
|
}
|
|
17585
16959
|
else if (pathCommand === 'C') {
|
|
17586
16960
|
// @ts-ignore
|
|
17587
|
-
(
|
|
16961
|
+
(_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);
|
|
17588
16962
|
}
|
|
17589
16963
|
else if (pathCommand === 'Q') {
|
|
17590
16964
|
// @ts-ignore
|
|
17591
|
-
(
|
|
16965
|
+
(_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);
|
|
17592
16966
|
}
|
|
17593
16967
|
else if (pathCommand === 'Z') {
|
|
17594
16968
|
data = [x, y, mx, my];
|
|
17595
16969
|
// @ts-ignore
|
|
17596
|
-
(
|
|
16970
|
+
(_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);
|
|
17597
16971
|
}
|
|
17598
16972
|
if (distanceIsNumber && LENGTH < distance && LENGTH + length >= distance) {
|
|
17599
16973
|
POINT = point;
|
|
17600
16974
|
}
|
|
17601
|
-
MAX = [
|
|
17602
|
-
MIN = [
|
|
16975
|
+
MAX = __spreadArray(__spreadArray([], MAX, true), [max], false);
|
|
16976
|
+
MIN = __spreadArray(__spreadArray([], MIN, true), [min], false);
|
|
17603
16977
|
LENGTH += length;
|
|
17604
|
-
|
|
16978
|
+
_f = pathCommand !== 'Z' ? seg.slice(-2) : [mx, my], x = _f[0], y = _f[1];
|
|
17605
16979
|
}
|
|
17606
16980
|
// native `getPointAtLength` behavior when the given distance
|
|
17607
16981
|
// is higher than total length
|
|
17608
16982
|
if (distanceIsNumber && distance >= LENGTH) {
|
|
17609
|
-
POINT = { x, y };
|
|
16983
|
+
POINT = { x: x, y: y };
|
|
17610
16984
|
}
|
|
17611
16985
|
return {
|
|
17612
16986
|
length: LENGTH,
|
|
17613
16987
|
point: POINT,
|
|
17614
16988
|
min: {
|
|
17615
|
-
x: Math.min(
|
|
17616
|
-
y: Math.min(
|
|
16989
|
+
x: Math.min.apply(Math, MIN.map(function (n) { return n.x; })),
|
|
16990
|
+
y: Math.min.apply(Math, MIN.map(function (n) { return n.y; })),
|
|
17617
16991
|
},
|
|
17618
16992
|
max: {
|
|
17619
|
-
x: Math.max(
|
|
17620
|
-
y: Math.max(
|
|
16993
|
+
x: Math.max.apply(Math, MAX.map(function (n) { return n.x; })),
|
|
16994
|
+
y: Math.max.apply(Math, MAX.map(function (n) { return n.y; })),
|
|
17621
16995
|
},
|
|
17622
16996
|
};
|
|
17623
16997
|
}
|
|
@@ -17640,13 +17014,13 @@
|
|
|
17640
17014
|
cz: 0,
|
|
17641
17015
|
};
|
|
17642
17016
|
}
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17017
|
+
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;
|
|
17018
|
+
var width = xMax - xMin;
|
|
17019
|
+
var height = yMax - yMin;
|
|
17646
17020
|
return {
|
|
17647
|
-
length,
|
|
17648
|
-
width,
|
|
17649
|
-
height,
|
|
17021
|
+
length: length,
|
|
17022
|
+
width: width,
|
|
17023
|
+
height: height,
|
|
17650
17024
|
x: xMin,
|
|
17651
17025
|
y: yMin,
|
|
17652
17026
|
x2: xMax,
|
|
@@ -17659,28 +17033,30 @@
|
|
|
17659
17033
|
}
|
|
17660
17034
|
|
|
17661
17035
|
function getRotations(a) {
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
return a.map((f, idx)
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
|
|
17668
|
-
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
oldSegIdx
|
|
17673
|
-
|
|
17674
|
-
|
|
17036
|
+
var segCount = a.length;
|
|
17037
|
+
var pointCount = segCount - 1;
|
|
17038
|
+
return a.map(function (f, idx) {
|
|
17039
|
+
return a.map(function (p, i) {
|
|
17040
|
+
var oldSegIdx = idx + i;
|
|
17041
|
+
var seg;
|
|
17042
|
+
if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === 'M')) {
|
|
17043
|
+
seg = a[oldSegIdx];
|
|
17044
|
+
return ['M'].concat(seg.slice(-2));
|
|
17045
|
+
}
|
|
17046
|
+
if (oldSegIdx >= segCount)
|
|
17047
|
+
oldSegIdx -= pointCount;
|
|
17048
|
+
return a[oldSegIdx];
|
|
17049
|
+
});
|
|
17050
|
+
});
|
|
17675
17051
|
}
|
|
17676
17052
|
function getRotatedCurve(a, b) {
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
rotations.forEach((r, i)
|
|
17683
|
-
a.slice(1).forEach((s, j)
|
|
17053
|
+
var segCount = a.length - 1;
|
|
17054
|
+
var lineLengths = [];
|
|
17055
|
+
var computedIndex = 0;
|
|
17056
|
+
var sumLensSqrd = 0;
|
|
17057
|
+
var rotations = getRotations(a);
|
|
17058
|
+
rotations.forEach(function (r, i) {
|
|
17059
|
+
a.slice(1).forEach(function (s, j) {
|
|
17684
17060
|
// @ts-ignore
|
|
17685
17061
|
sumLensSqrd += distanceSquareRoot(a[(i + j) % segCount].slice(-2), b[j % segCount].slice(-2));
|
|
17686
17062
|
});
|
|
@@ -17714,23 +17090,24 @@
|
|
|
17714
17090
|
* @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
|
|
17715
17091
|
*/
|
|
17716
17092
|
function getPathArea(path) {
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17093
|
+
var x = 0;
|
|
17094
|
+
var y = 0;
|
|
17095
|
+
var len = 0;
|
|
17720
17096
|
return path2Curve(path)
|
|
17721
|
-
.map((seg)
|
|
17097
|
+
.map(function (seg) {
|
|
17098
|
+
var _a;
|
|
17722
17099
|
switch (seg[0]) {
|
|
17723
17100
|
case 'M':
|
|
17724
|
-
[,
|
|
17101
|
+
x = seg[1], y = seg[2];
|
|
17725
17102
|
return 0;
|
|
17726
17103
|
default:
|
|
17727
17104
|
// @ts-ignore
|
|
17728
|
-
len = getCubicSegArea(x, y,
|
|
17729
|
-
|
|
17105
|
+
len = getCubicSegArea.apply(void 0, __spreadArray([x, y], seg.slice(1), false));
|
|
17106
|
+
_a = seg.slice(-2), x = _a[0], y = _a[1];
|
|
17730
17107
|
return len;
|
|
17731
17108
|
}
|
|
17732
17109
|
})
|
|
17733
|
-
.reduce((a, b)
|
|
17110
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
17734
17111
|
}
|
|
17735
17112
|
// export function getPathArea(pathArray: AbsoluteArray) {
|
|
17736
17113
|
// let x = 0;
|
|
@@ -17769,17 +17146,18 @@
|
|
|
17769
17146
|
return pathLengthFactory(pathInput, distance).point;
|
|
17770
17147
|
}
|
|
17771
17148
|
|
|
17772
|
-
function splitCubic(pts, t
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17149
|
+
function splitCubic(pts, t) {
|
|
17150
|
+
if (t === void 0) { t = 0.5; }
|
|
17151
|
+
var p0 = pts.slice(0, 2);
|
|
17152
|
+
var p1 = pts.slice(2, 4);
|
|
17153
|
+
var p2 = pts.slice(4, 6);
|
|
17154
|
+
var p3 = pts.slice(6, 8);
|
|
17155
|
+
var p4 = midPoint(p0, p1, t);
|
|
17156
|
+
var p5 = midPoint(p1, p2, t);
|
|
17157
|
+
var p6 = midPoint(p2, p3, t);
|
|
17158
|
+
var p7 = midPoint(p4, p5, t);
|
|
17159
|
+
var p8 = midPoint(p5, p6, t);
|
|
17160
|
+
var p9 = midPoint(p7, p8, t);
|
|
17783
17161
|
return [
|
|
17784
17162
|
// @ts-ignore
|
|
17785
17163
|
['C'].concat(p4, p7, p9),
|
|
@@ -17788,12 +17166,12 @@
|
|
|
17788
17166
|
];
|
|
17789
17167
|
}
|
|
17790
17168
|
function getCurveArray(segments) {
|
|
17791
|
-
return segments.map((segment, i, pathArray)
|
|
17169
|
+
return segments.map(function (segment, i, pathArray) {
|
|
17792
17170
|
// @ts-ignore
|
|
17793
|
-
|
|
17171
|
+
var segmentData = i && pathArray[i - 1].slice(-2).concat(segment.slice(1));
|
|
17794
17172
|
// @ts-ignore
|
|
17795
|
-
|
|
17796
|
-
|
|
17173
|
+
var curveLength = i ? segmentCubicFactory.apply(void 0, segmentData).length : 0;
|
|
17174
|
+
var subsegs;
|
|
17797
17175
|
if (i) {
|
|
17798
17176
|
// must be [segment,segment]
|
|
17799
17177
|
subsegs = curveLength ? splitCubic(segmentData) : [segment, segment];
|
|
@@ -17809,33 +17187,40 @@
|
|
|
17809
17187
|
});
|
|
17810
17188
|
}
|
|
17811
17189
|
function equalizeSegments(path1, path2, TL) {
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
|
|
17832
|
-
|
|
17833
|
-
|
|
17834
|
-
|
|
17190
|
+
var c1 = getCurveArray(path1);
|
|
17191
|
+
var c2 = getCurveArray(path2);
|
|
17192
|
+
var L1 = c1.length;
|
|
17193
|
+
var L2 = c2.length;
|
|
17194
|
+
var l1 = c1.filter(function (x) { return x.l; }).length;
|
|
17195
|
+
var l2 = c2.filter(function (x) { return x.l; }).length;
|
|
17196
|
+
var m1 = c1.filter(function (x) { return x.l; }).reduce(function (a, _a) {
|
|
17197
|
+
var l = _a.l;
|
|
17198
|
+
return a + l;
|
|
17199
|
+
}, 0) / l1 || 0;
|
|
17200
|
+
var m2 = c2.filter(function (x) { return x.l; }).reduce(function (a, _a) {
|
|
17201
|
+
var l = _a.l;
|
|
17202
|
+
return a + l;
|
|
17203
|
+
}, 0) / l2 || 0;
|
|
17204
|
+
var tl = TL || Math.max(L1, L2);
|
|
17205
|
+
var mm = [m1, m2];
|
|
17206
|
+
var dif = [tl - L1, tl - L2];
|
|
17207
|
+
var canSplit = 0;
|
|
17208
|
+
var result = [c1, c2].map(function (x, i) {
|
|
17209
|
+
// @ts-ignore
|
|
17210
|
+
return x.l === tl
|
|
17211
|
+
? x.map(function (y) { return y.s; })
|
|
17212
|
+
: x
|
|
17213
|
+
.map(function (y, j) {
|
|
17214
|
+
canSplit = j && dif[i] && y.l >= mm[i];
|
|
17215
|
+
dif[i] -= canSplit ? 1 : 0;
|
|
17216
|
+
return canSplit ? y.ss : [y.s];
|
|
17217
|
+
})
|
|
17218
|
+
.flat();
|
|
17219
|
+
});
|
|
17835
17220
|
return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
|
|
17836
17221
|
}
|
|
17837
17222
|
|
|
17838
|
-
function
|
|
17223
|
+
var memoizedParsePath = memoize(function (path) {
|
|
17839
17224
|
var absolutePath;
|
|
17840
17225
|
|
|
17841
17226
|
try {
|
|
@@ -17867,11 +17252,6 @@
|
|
|
17867
17252
|
height = _getPathBBoxTotalLeng.height,
|
|
17868
17253
|
length = _getPathBBoxTotalLeng.length;
|
|
17869
17254
|
|
|
17870
|
-
if (object) {
|
|
17871
|
-
object.parsedStyle.defX = x;
|
|
17872
|
-
object.parsedStyle.defY = y;
|
|
17873
|
-
}
|
|
17874
|
-
|
|
17875
17255
|
return {
|
|
17876
17256
|
absolutePath: absolutePath,
|
|
17877
17257
|
hasArc: hasArc,
|
|
@@ -17883,6 +17263,18 @@
|
|
|
17883
17263
|
zCommandIndexes: zCommandIndexes,
|
|
17884
17264
|
rect: new Rectangle(x, y, width, height)
|
|
17885
17265
|
};
|
|
17266
|
+
}, function (path) {
|
|
17267
|
+
return isString(path) ? path : path2String(path);
|
|
17268
|
+
});
|
|
17269
|
+
function parsePath(path, object) {
|
|
17270
|
+
var result = memoizedParsePath(path);
|
|
17271
|
+
|
|
17272
|
+
if (object) {
|
|
17273
|
+
object.parsedStyle.defX = result.rect.x;
|
|
17274
|
+
object.parsedStyle.defY = result.rect.y;
|
|
17275
|
+
}
|
|
17276
|
+
|
|
17277
|
+
return result;
|
|
17886
17278
|
}
|
|
17887
17279
|
function mergePaths(left, right, object) {
|
|
17888
17280
|
var curve1 = left.curve;
|
|
@@ -18325,12 +17717,469 @@
|
|
|
18325
17717
|
});
|
|
18326
17718
|
}
|
|
18327
17719
|
|
|
18328
|
-
if (filterRegExp.lastIndex === filterStr.length) {
|
|
18329
|
-
return result;
|
|
18330
|
-
}
|
|
18331
|
-
}
|
|
17720
|
+
if (filterRegExp.lastIndex === filterStr.length) {
|
|
17721
|
+
return result;
|
|
17722
|
+
}
|
|
17723
|
+
}
|
|
17724
|
+
|
|
17725
|
+
return [];
|
|
17726
|
+
}
|
|
17727
|
+
|
|
17728
|
+
var normalize$4 = function normalize(out, mat) {
|
|
17729
|
+
var m44 = mat[15];
|
|
17730
|
+
// Cannot normalize.
|
|
17731
|
+
if (m44 === 0)
|
|
17732
|
+
return false
|
|
17733
|
+
var scale = 1 / m44;
|
|
17734
|
+
for (var i=0; i<16; i++)
|
|
17735
|
+
out[i] = mat[i] * scale;
|
|
17736
|
+
return true
|
|
17737
|
+
};
|
|
17738
|
+
|
|
17739
|
+
var create_1 = create$6;
|
|
17740
|
+
|
|
17741
|
+
/**
|
|
17742
|
+
* Creates a new identity mat4
|
|
17743
|
+
*
|
|
17744
|
+
* @returns {mat4} a new 4x4 matrix
|
|
17745
|
+
*/
|
|
17746
|
+
function create$6() {
|
|
17747
|
+
var out = new Float32Array(16);
|
|
17748
|
+
out[0] = 1;
|
|
17749
|
+
out[1] = 0;
|
|
17750
|
+
out[2] = 0;
|
|
17751
|
+
out[3] = 0;
|
|
17752
|
+
out[4] = 0;
|
|
17753
|
+
out[5] = 1;
|
|
17754
|
+
out[6] = 0;
|
|
17755
|
+
out[7] = 0;
|
|
17756
|
+
out[8] = 0;
|
|
17757
|
+
out[9] = 0;
|
|
17758
|
+
out[10] = 1;
|
|
17759
|
+
out[11] = 0;
|
|
17760
|
+
out[12] = 0;
|
|
17761
|
+
out[13] = 0;
|
|
17762
|
+
out[14] = 0;
|
|
17763
|
+
out[15] = 1;
|
|
17764
|
+
return out;
|
|
17765
|
+
}
|
|
17766
|
+
|
|
17767
|
+
var clone_1 = clone$2;
|
|
17768
|
+
|
|
17769
|
+
/**
|
|
17770
|
+
* Creates a new mat4 initialized with values from an existing matrix
|
|
17771
|
+
*
|
|
17772
|
+
* @param {mat4} a matrix to clone
|
|
17773
|
+
* @returns {mat4} a new 4x4 matrix
|
|
17774
|
+
*/
|
|
17775
|
+
function clone$2(a) {
|
|
17776
|
+
var out = new Float32Array(16);
|
|
17777
|
+
out[0] = a[0];
|
|
17778
|
+
out[1] = a[1];
|
|
17779
|
+
out[2] = a[2];
|
|
17780
|
+
out[3] = a[3];
|
|
17781
|
+
out[4] = a[4];
|
|
17782
|
+
out[5] = a[5];
|
|
17783
|
+
out[6] = a[6];
|
|
17784
|
+
out[7] = a[7];
|
|
17785
|
+
out[8] = a[8];
|
|
17786
|
+
out[9] = a[9];
|
|
17787
|
+
out[10] = a[10];
|
|
17788
|
+
out[11] = a[11];
|
|
17789
|
+
out[12] = a[12];
|
|
17790
|
+
out[13] = a[13];
|
|
17791
|
+
out[14] = a[14];
|
|
17792
|
+
out[15] = a[15];
|
|
17793
|
+
return out;
|
|
17794
|
+
}
|
|
17795
|
+
|
|
17796
|
+
var determinant_1 = determinant;
|
|
17797
|
+
|
|
17798
|
+
/**
|
|
17799
|
+
* Calculates the determinant of a mat4
|
|
17800
|
+
*
|
|
17801
|
+
* @param {mat4} a the source matrix
|
|
17802
|
+
* @returns {Number} determinant of a
|
|
17803
|
+
*/
|
|
17804
|
+
function determinant(a) {
|
|
17805
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
|
|
17806
|
+
a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
|
|
17807
|
+
a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
|
|
17808
|
+
a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
|
|
17809
|
+
|
|
17810
|
+
b00 = a00 * a11 - a01 * a10,
|
|
17811
|
+
b01 = a00 * a12 - a02 * a10,
|
|
17812
|
+
b02 = a00 * a13 - a03 * a10,
|
|
17813
|
+
b03 = a01 * a12 - a02 * a11,
|
|
17814
|
+
b04 = a01 * a13 - a03 * a11,
|
|
17815
|
+
b05 = a02 * a13 - a03 * a12,
|
|
17816
|
+
b06 = a20 * a31 - a21 * a30,
|
|
17817
|
+
b07 = a20 * a32 - a22 * a30,
|
|
17818
|
+
b08 = a20 * a33 - a23 * a30,
|
|
17819
|
+
b09 = a21 * a32 - a22 * a31,
|
|
17820
|
+
b10 = a21 * a33 - a23 * a31,
|
|
17821
|
+
b11 = a22 * a33 - a23 * a32;
|
|
17822
|
+
|
|
17823
|
+
// Calculate the determinant
|
|
17824
|
+
return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
17825
|
+
}
|
|
17826
|
+
|
|
17827
|
+
var invert_1 = invert$2;
|
|
17828
|
+
|
|
17829
|
+
/**
|
|
17830
|
+
* Inverts a mat4
|
|
17831
|
+
*
|
|
17832
|
+
* @param {mat4} out the receiving matrix
|
|
17833
|
+
* @param {mat4} a the source matrix
|
|
17834
|
+
* @returns {mat4} out
|
|
17835
|
+
*/
|
|
17836
|
+
function invert$2(out, a) {
|
|
17837
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
|
|
17838
|
+
a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
|
|
17839
|
+
a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
|
|
17840
|
+
a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
|
|
17841
|
+
|
|
17842
|
+
b00 = a00 * a11 - a01 * a10,
|
|
17843
|
+
b01 = a00 * a12 - a02 * a10,
|
|
17844
|
+
b02 = a00 * a13 - a03 * a10,
|
|
17845
|
+
b03 = a01 * a12 - a02 * a11,
|
|
17846
|
+
b04 = a01 * a13 - a03 * a11,
|
|
17847
|
+
b05 = a02 * a13 - a03 * a12,
|
|
17848
|
+
b06 = a20 * a31 - a21 * a30,
|
|
17849
|
+
b07 = a20 * a32 - a22 * a30,
|
|
17850
|
+
b08 = a20 * a33 - a23 * a30,
|
|
17851
|
+
b09 = a21 * a32 - a22 * a31,
|
|
17852
|
+
b10 = a21 * a33 - a23 * a31,
|
|
17853
|
+
b11 = a22 * a33 - a23 * a32,
|
|
17854
|
+
|
|
17855
|
+
// Calculate the determinant
|
|
17856
|
+
det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
17857
|
+
|
|
17858
|
+
if (!det) {
|
|
17859
|
+
return null;
|
|
17860
|
+
}
|
|
17861
|
+
det = 1.0 / det;
|
|
17862
|
+
|
|
17863
|
+
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
17864
|
+
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
17865
|
+
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
17866
|
+
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
17867
|
+
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
17868
|
+
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
17869
|
+
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
17870
|
+
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
17871
|
+
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
17872
|
+
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
17873
|
+
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
17874
|
+
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
17875
|
+
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
17876
|
+
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
17877
|
+
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
17878
|
+
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
17879
|
+
|
|
17880
|
+
return out;
|
|
17881
|
+
}
|
|
17882
|
+
|
|
17883
|
+
var transpose_1 = transpose;
|
|
17884
|
+
|
|
17885
|
+
/**
|
|
17886
|
+
* Transpose the values of a mat4
|
|
17887
|
+
*
|
|
17888
|
+
* @param {mat4} out the receiving matrix
|
|
17889
|
+
* @param {mat4} a the source matrix
|
|
17890
|
+
* @returns {mat4} out
|
|
17891
|
+
*/
|
|
17892
|
+
function transpose(out, a) {
|
|
17893
|
+
// If we are transposing ourselves we can skip a few steps but have to cache some values
|
|
17894
|
+
if (out === a) {
|
|
17895
|
+
var a01 = a[1], a02 = a[2], a03 = a[3],
|
|
17896
|
+
a12 = a[6], a13 = a[7],
|
|
17897
|
+
a23 = a[11];
|
|
17898
|
+
|
|
17899
|
+
out[1] = a[4];
|
|
17900
|
+
out[2] = a[8];
|
|
17901
|
+
out[3] = a[12];
|
|
17902
|
+
out[4] = a01;
|
|
17903
|
+
out[6] = a[9];
|
|
17904
|
+
out[7] = a[13];
|
|
17905
|
+
out[8] = a02;
|
|
17906
|
+
out[9] = a12;
|
|
17907
|
+
out[11] = a[14];
|
|
17908
|
+
out[12] = a03;
|
|
17909
|
+
out[13] = a13;
|
|
17910
|
+
out[14] = a23;
|
|
17911
|
+
} else {
|
|
17912
|
+
out[0] = a[0];
|
|
17913
|
+
out[1] = a[4];
|
|
17914
|
+
out[2] = a[8];
|
|
17915
|
+
out[3] = a[12];
|
|
17916
|
+
out[4] = a[1];
|
|
17917
|
+
out[5] = a[5];
|
|
17918
|
+
out[6] = a[9];
|
|
17919
|
+
out[7] = a[13];
|
|
17920
|
+
out[8] = a[2];
|
|
17921
|
+
out[9] = a[6];
|
|
17922
|
+
out[10] = a[10];
|
|
17923
|
+
out[11] = a[14];
|
|
17924
|
+
out[12] = a[3];
|
|
17925
|
+
out[13] = a[7];
|
|
17926
|
+
out[14] = a[11];
|
|
17927
|
+
out[15] = a[15];
|
|
17928
|
+
}
|
|
17929
|
+
|
|
17930
|
+
return out;
|
|
17931
|
+
}
|
|
17932
|
+
|
|
17933
|
+
var length_1 = length$1;
|
|
17934
|
+
|
|
17935
|
+
/**
|
|
17936
|
+
* Calculates the length of a vec3
|
|
17937
|
+
*
|
|
17938
|
+
* @param {vec3} a vector to calculate length of
|
|
17939
|
+
* @returns {Number} length of a
|
|
17940
|
+
*/
|
|
17941
|
+
function length$1(a) {
|
|
17942
|
+
var x = a[0],
|
|
17943
|
+
y = a[1],
|
|
17944
|
+
z = a[2];
|
|
17945
|
+
return Math.sqrt(x*x + y*y + z*z)
|
|
17946
|
+
}
|
|
17947
|
+
|
|
17948
|
+
var normalize_1 = normalize$5;
|
|
17949
|
+
|
|
17950
|
+
/**
|
|
17951
|
+
* Normalize a vec3
|
|
17952
|
+
*
|
|
17953
|
+
* @param {vec3} out the receiving vector
|
|
17954
|
+
* @param {vec3} a vector to normalize
|
|
17955
|
+
* @returns {vec3} out
|
|
17956
|
+
*/
|
|
17957
|
+
function normalize$5(out, a) {
|
|
17958
|
+
var x = a[0],
|
|
17959
|
+
y = a[1],
|
|
17960
|
+
z = a[2];
|
|
17961
|
+
var len = x*x + y*y + z*z;
|
|
17962
|
+
if (len > 0) {
|
|
17963
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
17964
|
+
len = 1 / Math.sqrt(len);
|
|
17965
|
+
out[0] = a[0] * len;
|
|
17966
|
+
out[1] = a[1] * len;
|
|
17967
|
+
out[2] = a[2] * len;
|
|
17968
|
+
}
|
|
17969
|
+
return out
|
|
17970
|
+
}
|
|
17971
|
+
|
|
17972
|
+
var dot_1 = dot$2;
|
|
17973
|
+
|
|
17974
|
+
/**
|
|
17975
|
+
* Calculates the dot product of two vec3's
|
|
17976
|
+
*
|
|
17977
|
+
* @param {vec3} a the first operand
|
|
17978
|
+
* @param {vec3} b the second operand
|
|
17979
|
+
* @returns {Number} dot product of a and b
|
|
17980
|
+
*/
|
|
17981
|
+
function dot$2(a, b) {
|
|
17982
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
|
|
17983
|
+
}
|
|
17984
|
+
|
|
17985
|
+
var cross_1 = cross$1;
|
|
17986
|
+
|
|
17987
|
+
/**
|
|
17988
|
+
* Computes the cross product of two vec3's
|
|
17989
|
+
*
|
|
17990
|
+
* @param {vec3} out the receiving vector
|
|
17991
|
+
* @param {vec3} a the first operand
|
|
17992
|
+
* @param {vec3} b the second operand
|
|
17993
|
+
* @returns {vec3} out
|
|
17994
|
+
*/
|
|
17995
|
+
function cross$1(out, a, b) {
|
|
17996
|
+
var ax = a[0], ay = a[1], az = a[2],
|
|
17997
|
+
bx = b[0], by = b[1], bz = b[2];
|
|
17998
|
+
|
|
17999
|
+
out[0] = ay * bz - az * by;
|
|
18000
|
+
out[1] = az * bx - ax * bz;
|
|
18001
|
+
out[2] = ax * by - ay * bx;
|
|
18002
|
+
return out
|
|
18003
|
+
}
|
|
18004
|
+
|
|
18005
|
+
/*jshint unused:true*/
|
|
18006
|
+
/*
|
|
18007
|
+
Input: matrix ; a 4x4 matrix
|
|
18008
|
+
Output: translation ; a 3 component vector
|
|
18009
|
+
scale ; a 3 component vector
|
|
18010
|
+
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
18011
|
+
perspective ; a 4 component vector
|
|
18012
|
+
quaternion ; a 4 component vector
|
|
18013
|
+
Returns false if the matrix cannot be decomposed, true if it can
|
|
18014
|
+
|
|
18015
|
+
|
|
18016
|
+
References:
|
|
18017
|
+
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
18018
|
+
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
18019
|
+
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
18020
|
+
*/
|
|
18021
|
+
|
|
18022
|
+
|
|
18023
|
+
|
|
18024
|
+
|
|
18025
|
+
|
|
18026
|
+
|
|
18027
|
+
|
|
18028
|
+
|
|
18029
|
+
var vec3 = {
|
|
18030
|
+
length: length_1,
|
|
18031
|
+
normalize: normalize_1,
|
|
18032
|
+
dot: dot_1,
|
|
18033
|
+
cross: cross_1
|
|
18034
|
+
};
|
|
18035
|
+
|
|
18036
|
+
var tmp = create_1();
|
|
18037
|
+
var perspectiveMatrix = create_1();
|
|
18038
|
+
var tmpVec4 = [0, 0, 0, 0];
|
|
18039
|
+
var row = [ [0,0,0], [0,0,0], [0,0,0] ];
|
|
18040
|
+
var pdum3 = [0,0,0];
|
|
18041
|
+
|
|
18042
|
+
var mat4Decompose = function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
|
|
18043
|
+
if (!translation) translation = [0,0,0];
|
|
18044
|
+
if (!scale) scale = [0,0,0];
|
|
18045
|
+
if (!skew) skew = [0,0,0];
|
|
18046
|
+
if (!perspective) perspective = [0,0,0,1];
|
|
18047
|
+
if (!quaternion) quaternion = [0,0,0,1];
|
|
18048
|
+
|
|
18049
|
+
//normalize, if not possible then bail out early
|
|
18050
|
+
if (!normalize$4(tmp, matrix))
|
|
18051
|
+
return false
|
|
18052
|
+
|
|
18053
|
+
// perspectiveMatrix is used to solve for perspective, but it also provides
|
|
18054
|
+
// an easy way to test for singularity of the upper 3x3 component.
|
|
18055
|
+
clone_1(perspectiveMatrix);
|
|
18056
|
+
|
|
18057
|
+
perspectiveMatrix[3] = 0;
|
|
18058
|
+
perspectiveMatrix[7] = 0;
|
|
18059
|
+
perspectiveMatrix[11] = 0;
|
|
18060
|
+
perspectiveMatrix[15] = 1;
|
|
18061
|
+
|
|
18062
|
+
// If the perspectiveMatrix is not invertible, we are also unable to
|
|
18063
|
+
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
18064
|
+
if (Math.abs(determinant_1(perspectiveMatrix) < 1e-8))
|
|
18065
|
+
return false
|
|
18066
|
+
|
|
18067
|
+
var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11],
|
|
18068
|
+
a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15];
|
|
18069
|
+
|
|
18070
|
+
// First, isolate perspective.
|
|
18071
|
+
if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
|
|
18072
|
+
tmpVec4[0] = a03;
|
|
18073
|
+
tmpVec4[1] = a13;
|
|
18074
|
+
tmpVec4[2] = a23;
|
|
18075
|
+
tmpVec4[3] = a33;
|
|
18076
|
+
|
|
18077
|
+
// Solve the equation by inverting perspectiveMatrix and multiplying
|
|
18078
|
+
// rightHandSide by the inverse.
|
|
18079
|
+
// resuing the perspectiveMatrix here since it's no longer needed
|
|
18080
|
+
var ret = invert_1(perspectiveMatrix, perspectiveMatrix);
|
|
18081
|
+
if (!ret) return false
|
|
18082
|
+
transpose_1(perspectiveMatrix, perspectiveMatrix);
|
|
18083
|
+
|
|
18084
|
+
//multiply by transposed inverse perspective matrix, into perspective vec4
|
|
18085
|
+
vec4multMat4(perspective, tmpVec4, perspectiveMatrix);
|
|
18086
|
+
} else {
|
|
18087
|
+
//no perspective
|
|
18088
|
+
perspective[0] = perspective[1] = perspective[2] = 0;
|
|
18089
|
+
perspective[3] = 1;
|
|
18090
|
+
}
|
|
18091
|
+
|
|
18092
|
+
// Next take care of translation
|
|
18093
|
+
translation[0] = a30;
|
|
18094
|
+
translation[1] = a31;
|
|
18095
|
+
translation[2] = a32;
|
|
18096
|
+
|
|
18097
|
+
// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
18098
|
+
mat3from4(row, tmp);
|
|
18099
|
+
|
|
18100
|
+
// Compute X scale factor and normalize first row.
|
|
18101
|
+
scale[0] = vec3.length(row[0]);
|
|
18102
|
+
vec3.normalize(row[0], row[0]);
|
|
18103
|
+
|
|
18104
|
+
// Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
18105
|
+
skew[0] = vec3.dot(row[0], row[1]);
|
|
18106
|
+
combine(row[1], row[1], row[0], 1.0, -skew[0]);
|
|
18107
|
+
|
|
18108
|
+
// Now, compute Y scale and normalize 2nd row.
|
|
18109
|
+
scale[1] = vec3.length(row[1]);
|
|
18110
|
+
vec3.normalize(row[1], row[1]);
|
|
18111
|
+
skew[0] /= scale[1];
|
|
18112
|
+
|
|
18113
|
+
// Compute XZ and YZ shears, orthogonalize 3rd row
|
|
18114
|
+
skew[1] = vec3.dot(row[0], row[2]);
|
|
18115
|
+
combine(row[2], row[2], row[0], 1.0, -skew[1]);
|
|
18116
|
+
skew[2] = vec3.dot(row[1], row[2]);
|
|
18117
|
+
combine(row[2], row[2], row[1], 1.0, -skew[2]);
|
|
18118
|
+
|
|
18119
|
+
// Next, get Z scale and normalize 3rd row.
|
|
18120
|
+
scale[2] = vec3.length(row[2]);
|
|
18121
|
+
vec3.normalize(row[2], row[2]);
|
|
18122
|
+
skew[1] /= scale[2];
|
|
18123
|
+
skew[2] /= scale[2];
|
|
18124
|
+
|
|
18125
|
+
|
|
18126
|
+
// At this point, the matrix (in rows) is orthonormal.
|
|
18127
|
+
// Check for a coordinate system flip. If the determinant
|
|
18128
|
+
// is -1, then negate the matrix and the scaling factors.
|
|
18129
|
+
vec3.cross(pdum3, row[1], row[2]);
|
|
18130
|
+
if (vec3.dot(row[0], pdum3) < 0) {
|
|
18131
|
+
for (var i = 0; i < 3; i++) {
|
|
18132
|
+
scale[i] *= -1;
|
|
18133
|
+
row[i][0] *= -1;
|
|
18134
|
+
row[i][1] *= -1;
|
|
18135
|
+
row[i][2] *= -1;
|
|
18136
|
+
}
|
|
18137
|
+
}
|
|
18138
|
+
|
|
18139
|
+
// Now, get the rotations out
|
|
18140
|
+
quaternion[0] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
|
|
18141
|
+
quaternion[1] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
|
|
18142
|
+
quaternion[2] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
|
|
18143
|
+
quaternion[3] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
18144
|
+
|
|
18145
|
+
if (row[2][1] > row[1][2])
|
|
18146
|
+
quaternion[0] = -quaternion[0];
|
|
18147
|
+
if (row[0][2] > row[2][0])
|
|
18148
|
+
quaternion[1] = -quaternion[1];
|
|
18149
|
+
if (row[1][0] > row[0][1])
|
|
18150
|
+
quaternion[2] = -quaternion[2];
|
|
18151
|
+
return true
|
|
18152
|
+
};
|
|
18153
|
+
|
|
18154
|
+
//will be replaced by gl-vec4 eventually
|
|
18155
|
+
function vec4multMat4(out, a, m) {
|
|
18156
|
+
var x = a[0], y = a[1], z = a[2], w = a[3];
|
|
18157
|
+
out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
|
|
18158
|
+
out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
|
|
18159
|
+
out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
|
|
18160
|
+
out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
|
|
18161
|
+
return out;
|
|
18162
|
+
}
|
|
18332
18163
|
|
|
18333
|
-
|
|
18164
|
+
//gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
18165
|
+
function mat3from4(out, mat4x4) {
|
|
18166
|
+
out[0][0] = mat4x4[0];
|
|
18167
|
+
out[0][1] = mat4x4[1];
|
|
18168
|
+
out[0][2] = mat4x4[2];
|
|
18169
|
+
|
|
18170
|
+
out[1][0] = mat4x4[4];
|
|
18171
|
+
out[1][1] = mat4x4[5];
|
|
18172
|
+
out[1][2] = mat4x4[6];
|
|
18173
|
+
|
|
18174
|
+
out[2][0] = mat4x4[8];
|
|
18175
|
+
out[2][1] = mat4x4[9];
|
|
18176
|
+
out[2][2] = mat4x4[10];
|
|
18177
|
+
}
|
|
18178
|
+
|
|
18179
|
+
function combine(out, a, b, scale1, scale2) {
|
|
18180
|
+
out[0] = a[0] * scale1 + b[0] * scale2;
|
|
18181
|
+
out[1] = a[1] * scale1 + b[1] * scale2;
|
|
18182
|
+
out[2] = a[2] * scale1 + b[2] * scale2;
|
|
18334
18183
|
}
|
|
18335
18184
|
|
|
18336
18185
|
/**
|
|
@@ -18472,22 +18321,23 @@
|
|
|
18472
18321
|
|
|
18473
18322
|
|
|
18474
18323
|
var transformFunctions = {
|
|
18475
|
-
//
|
|
18476
|
-
|
|
18324
|
+
// @ts-ignore
|
|
18325
|
+
matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id$1],
|
|
18326
|
+
matrix3d: ['NNNNNNNNNNNNNNNN', id$1],
|
|
18477
18327
|
rotate: ['A'],
|
|
18478
18328
|
rotatex: ['A'],
|
|
18479
18329
|
rotatey: ['A'],
|
|
18480
18330
|
rotatez: ['A'],
|
|
18481
18331
|
rotate3d: ['NNNA'],
|
|
18482
|
-
|
|
18332
|
+
perspective: ['L'],
|
|
18483
18333
|
scale: ['Nn', cast([_, _, CSS.number(1)]), id$1],
|
|
18484
18334
|
scalex: ['N', cast([_, CSS.number(1), CSS.number(1)]), cast([_, CSS.number(1)])],
|
|
18485
18335
|
scaley: ['N', cast([CSS.number(1), _, CSS.number(1)]), cast([CSS.number(1), _])],
|
|
18486
18336
|
scalez: ['N', cast([CSS.number(1), CSS.number(1), _])],
|
|
18487
18337
|
scale3d: ['NNN', id$1],
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18338
|
+
skew: ['Aa', null, id$1],
|
|
18339
|
+
skewx: ['A', null, cast([_, Odeg])],
|
|
18340
|
+
skewy: ['A', null, cast([Odeg, _])],
|
|
18491
18341
|
translate: ['Tt', cast([_, _, Opx]), id$1],
|
|
18492
18342
|
translatex: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
|
|
18493
18343
|
translatey: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
|
|
@@ -18580,33 +18430,289 @@
|
|
|
18580
18430
|
}
|
|
18581
18431
|
|
|
18582
18432
|
return [];
|
|
18583
|
-
}
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18433
|
+
}
|
|
18434
|
+
function convertItemToMatrix(item) {
|
|
18435
|
+
var x;
|
|
18436
|
+
var y;
|
|
18437
|
+
var z;
|
|
18438
|
+
var angle;
|
|
18439
|
+
|
|
18440
|
+
switch (item.t) {
|
|
18441
|
+
case 'rotatex':
|
|
18442
|
+
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
18443
|
+
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];
|
|
18444
|
+
|
|
18445
|
+
case 'rotatey':
|
|
18446
|
+
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
18447
|
+
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];
|
|
18448
|
+
|
|
18449
|
+
case 'rotate':
|
|
18450
|
+
case 'rotatez':
|
|
18451
|
+
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
18452
|
+
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];
|
|
18453
|
+
|
|
18454
|
+
case 'rotate3d':
|
|
18455
|
+
x = item.d[0].value;
|
|
18456
|
+
y = item.d[1].value;
|
|
18457
|
+
z = item.d[2].value;
|
|
18458
|
+
angle = deg2rad(convertAngleUnit(item.d[3]));
|
|
18459
|
+
var sqrLength = x * x + y * y + z * z;
|
|
18460
|
+
|
|
18461
|
+
if (sqrLength === 0) {
|
|
18462
|
+
x = 1;
|
|
18463
|
+
y = 0;
|
|
18464
|
+
z = 0;
|
|
18465
|
+
} else if (sqrLength !== 1) {
|
|
18466
|
+
var length = Math.sqrt(sqrLength);
|
|
18467
|
+
x /= length;
|
|
18468
|
+
y /= length;
|
|
18469
|
+
z /= length;
|
|
18470
|
+
}
|
|
18471
|
+
|
|
18472
|
+
var s = Math.sin(angle / 2);
|
|
18473
|
+
var sc = s * Math.cos(angle / 2);
|
|
18474
|
+
var sq = s * s;
|
|
18475
|
+
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];
|
|
18476
|
+
|
|
18477
|
+
case 'scale':
|
|
18478
|
+
return [item.d[0].value, 0, 0, 0, 0, item.d[1].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18479
|
+
|
|
18480
|
+
case 'scalex':
|
|
18481
|
+
return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18482
|
+
|
|
18483
|
+
case 'scaley':
|
|
18484
|
+
return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18485
|
+
|
|
18486
|
+
case 'scalez':
|
|
18487
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
|
|
18488
|
+
|
|
18489
|
+
case 'scale3d':
|
|
18490
|
+
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];
|
|
18491
|
+
|
|
18492
|
+
case 'skew':
|
|
18493
|
+
var xAngle = deg2rad(convertAngleUnit(item.d[0]));
|
|
18494
|
+
var yAngle = deg2rad(convertAngleUnit(item.d[1]));
|
|
18495
|
+
return [1, Math.tan(yAngle), 0, 0, Math.tan(xAngle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18496
|
+
|
|
18497
|
+
case 'skewx':
|
|
18498
|
+
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
18499
|
+
return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18500
|
+
|
|
18501
|
+
case 'skewy':
|
|
18502
|
+
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
18503
|
+
return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18504
|
+
|
|
18505
|
+
case 'translate':
|
|
18506
|
+
// TODO: pass target
|
|
18507
|
+
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
18508
|
+
y = convertPercentUnit(item.d[1], 0, null) || 0;
|
|
18509
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
|
|
18510
|
+
|
|
18511
|
+
case 'translatex':
|
|
18512
|
+
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
18513
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
|
|
18514
|
+
|
|
18515
|
+
case 'translatey':
|
|
18516
|
+
y = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
18517
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
|
|
18518
|
+
|
|
18519
|
+
case 'translatez':
|
|
18520
|
+
z = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
18521
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
|
|
18522
|
+
|
|
18523
|
+
case 'translate3d':
|
|
18524
|
+
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
18525
|
+
y = convertPercentUnit(item.d[1], 0, null) || 0;
|
|
18526
|
+
z = convertPercentUnit(item.d[2], 0, null) || 0;
|
|
18527
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1];
|
|
18528
|
+
|
|
18529
|
+
case 'perspective':
|
|
18530
|
+
var t = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
18531
|
+
var p = t ? -1 / t : 0;
|
|
18532
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, p, 0, 0, 0, 1];
|
|
18533
|
+
|
|
18534
|
+
case 'matrix':
|
|
18535
|
+
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];
|
|
18536
|
+
|
|
18537
|
+
case 'matrix3d':
|
|
18538
|
+
return item.d.map(function (d) {
|
|
18539
|
+
return d.value;
|
|
18540
|
+
});
|
|
18541
|
+
}
|
|
18542
|
+
}
|
|
18543
|
+
|
|
18544
|
+
function multiplyMatrices(a, b) {
|
|
18545
|
+
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]];
|
|
18546
|
+
}
|
|
18547
|
+
|
|
18548
|
+
function convertToMatrix(transformList) {
|
|
18549
|
+
if (transformList.length === 0) {
|
|
18550
|
+
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
18551
|
+
}
|
|
18552
|
+
|
|
18553
|
+
return transformList.map(convertItemToMatrix).reduce(multiplyMatrices);
|
|
18554
|
+
}
|
|
18555
|
+
|
|
18556
|
+
function makeMatrixDecomposition(transformList) {
|
|
18557
|
+
var translate = [0, 0, 0];
|
|
18558
|
+
var scale = [0, 0, 0];
|
|
18559
|
+
var skew = [0, 0, 0];
|
|
18560
|
+
var perspective = [0, 0, 0, 1];
|
|
18561
|
+
var quaternion = [0, 0, 0, 1];
|
|
18562
|
+
mat4Decompose(convertToMatrix(transformList), translate, scale, skew, perspective, quaternion);
|
|
18563
|
+
return [translate, scale, skew, quaternion, perspective];
|
|
18564
|
+
}
|
|
18565
|
+
|
|
18566
|
+
var composeMatrix = function () {
|
|
18567
|
+
function multiply(a, b) {
|
|
18568
|
+
var result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
|
|
18569
|
+
|
|
18570
|
+
for (var i = 0; i < 4; i++) {
|
|
18571
|
+
for (var j = 0; j < 4; j++) {
|
|
18572
|
+
for (var k = 0; k < 4; k++) {
|
|
18573
|
+
result[i][j] += b[i][k] * a[k][j];
|
|
18574
|
+
}
|
|
18575
|
+
}
|
|
18576
|
+
}
|
|
18577
|
+
|
|
18578
|
+
return result;
|
|
18579
|
+
}
|
|
18580
|
+
|
|
18581
|
+
function is2D(m) {
|
|
18582
|
+
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;
|
|
18583
|
+
}
|
|
18584
|
+
|
|
18585
|
+
function composeMatrix(translate, scale, skew, quat, perspective) {
|
|
18586
|
+
var matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
|
|
18587
|
+
|
|
18588
|
+
for (var i = 0; i < 4; i++) {
|
|
18589
|
+
matrix[i][3] = perspective[i];
|
|
18590
|
+
}
|
|
18591
|
+
|
|
18592
|
+
for (var _i = 0; _i < 3; _i++) {
|
|
18593
|
+
for (var j = 0; j < 3; j++) {
|
|
18594
|
+
matrix[3][_i] += translate[j] * matrix[j][_i];
|
|
18595
|
+
}
|
|
18596
|
+
}
|
|
18597
|
+
|
|
18598
|
+
var x = quat[0],
|
|
18599
|
+
y = quat[1],
|
|
18600
|
+
z = quat[2],
|
|
18601
|
+
w = quat[3];
|
|
18602
|
+
var rotMatrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
|
|
18603
|
+
rotMatrix[0][0] = 1 - 2 * (y * y + z * z);
|
|
18604
|
+
rotMatrix[0][1] = 2 * (x * y - z * w);
|
|
18605
|
+
rotMatrix[0][2] = 2 * (x * z + y * w);
|
|
18606
|
+
rotMatrix[1][0] = 2 * (x * y + z * w);
|
|
18607
|
+
rotMatrix[1][1] = 1 - 2 * (x * x + z * z);
|
|
18608
|
+
rotMatrix[1][2] = 2 * (y * z - x * w);
|
|
18609
|
+
rotMatrix[2][0] = 2 * (x * z - y * w);
|
|
18610
|
+
rotMatrix[2][1] = 2 * (y * z + x * w);
|
|
18611
|
+
rotMatrix[2][2] = 1 - 2 * (x * x + y * y);
|
|
18612
|
+
matrix = multiply(matrix, rotMatrix);
|
|
18613
|
+
var temp = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
|
|
18614
|
+
|
|
18615
|
+
if (skew[2]) {
|
|
18616
|
+
temp[2][1] = skew[2];
|
|
18617
|
+
matrix = multiply(matrix, temp);
|
|
18618
|
+
}
|
|
18619
|
+
|
|
18620
|
+
if (skew[1]) {
|
|
18621
|
+
temp[2][1] = 0;
|
|
18622
|
+
temp[2][0] = skew[0];
|
|
18623
|
+
matrix = multiply(matrix, temp);
|
|
18624
|
+
}
|
|
18625
|
+
|
|
18626
|
+
if (skew[0]) {
|
|
18627
|
+
temp[2][0] = 0;
|
|
18628
|
+
temp[1][0] = skew[0];
|
|
18629
|
+
matrix = multiply(matrix, temp);
|
|
18630
|
+
}
|
|
18631
|
+
|
|
18632
|
+
for (var _i2 = 0; _i2 < 3; _i2++) {
|
|
18633
|
+
for (var _j = 0; _j < 3; _j++) {
|
|
18634
|
+
matrix[_i2][_j] *= scale[_i2];
|
|
18635
|
+
}
|
|
18636
|
+
}
|
|
18637
|
+
|
|
18638
|
+
if (is2D(matrix)) {
|
|
18639
|
+
return [matrix[0][0], matrix[0][1], matrix[1][0], matrix[1][1], matrix[3][0], matrix[3][1]];
|
|
18640
|
+
}
|
|
18641
|
+
|
|
18642
|
+
return matrix[0].concat(matrix[1], matrix[2], matrix[3]);
|
|
18643
|
+
}
|
|
18644
|
+
|
|
18645
|
+
return composeMatrix;
|
|
18646
|
+
}();
|
|
18647
|
+
|
|
18648
|
+
function numberToLongString(x) {
|
|
18649
|
+
return x.toFixed(6).replace('.000000', '');
|
|
18650
|
+
}
|
|
18651
|
+
|
|
18652
|
+
function mergeMatrices(left, right) {
|
|
18653
|
+
var leftArgs;
|
|
18654
|
+
var rightArgs; // @ts-ignore
|
|
18655
|
+
|
|
18656
|
+
if (left.decompositionPair !== right) {
|
|
18657
|
+
// @ts-ignore
|
|
18658
|
+
left.decompositionPair = right;
|
|
18659
|
+
leftArgs = makeMatrixDecomposition(left);
|
|
18660
|
+
} // @ts-ignore
|
|
18661
|
+
|
|
18662
|
+
|
|
18663
|
+
if (right.decompositionPair !== left) {
|
|
18664
|
+
// @ts-ignore
|
|
18665
|
+
right.decompositionPair = left;
|
|
18666
|
+
rightArgs = makeMatrixDecomposition(right);
|
|
18667
|
+
}
|
|
18668
|
+
|
|
18669
|
+
if (leftArgs[0] === null || rightArgs[0] === null) return [// @ts-ignore
|
|
18670
|
+
[false], // @ts-ignore
|
|
18671
|
+
[true], // @ts-ignore
|
|
18672
|
+
function (x) {
|
|
18673
|
+
return x ? right[0].d : left[0].d;
|
|
18674
|
+
}];
|
|
18675
|
+
leftArgs[0].push(0);
|
|
18676
|
+
rightArgs[0].push(1);
|
|
18677
|
+
return [leftArgs, rightArgs, // @ts-ignore
|
|
18678
|
+
function (list) {
|
|
18679
|
+
// @ts-ignore
|
|
18680
|
+
var q = quat(leftArgs[0][3], rightArgs[0][3], list[5]);
|
|
18681
|
+
var mat = composeMatrix(list[0], list[1], list[2], q, list[4]);
|
|
18682
|
+
var stringifiedArgs = mat.map(numberToLongString).join(',');
|
|
18683
|
+
return stringifiedArgs;
|
|
18684
|
+
}];
|
|
18685
|
+
}
|
|
18686
|
+
|
|
18687
|
+
function dot$3(v1, v2) {
|
|
18688
|
+
var result = 0;
|
|
18689
|
+
|
|
18690
|
+
for (var i = 0; i < v1.length; i++) {
|
|
18691
|
+
result += v1[i] * v2[i];
|
|
18692
|
+
}
|
|
18693
|
+
|
|
18694
|
+
return result;
|
|
18695
|
+
}
|
|
18696
|
+
|
|
18697
|
+
function quat(fromQ, toQ, f) {
|
|
18698
|
+
var product = dot$3(fromQ, toQ);
|
|
18699
|
+
product = clamp(product, -1.0, 1.0);
|
|
18700
|
+
var quat = [];
|
|
18701
|
+
|
|
18702
|
+
if (product === 1.0) {
|
|
18703
|
+
quat = fromQ;
|
|
18704
|
+
} else {
|
|
18705
|
+
var theta = Math.acos(product);
|
|
18706
|
+
var w = Math.sin(f * theta) * 1 / Math.sqrt(1 - product * product);
|
|
18707
|
+
|
|
18708
|
+
for (var i = 0; i < 4; i++) {
|
|
18709
|
+
quat.push(fromQ[i] * (Math.cos(f * theta) - product * w) + toQ[i] * w);
|
|
18710
|
+
}
|
|
18711
|
+
}
|
|
18712
|
+
|
|
18713
|
+
return quat;
|
|
18714
|
+
} // scalex/y/z -> scale
|
|
18715
|
+
|
|
18610
18716
|
|
|
18611
18717
|
function typeTo2D(type) {
|
|
18612
18718
|
return type.replace(/[xy]/, '');
|
|
@@ -18636,7 +18742,7 @@
|
|
|
18636
18742
|
type = _left$i.t,
|
|
18637
18743
|
args = _left$i.d; // none -> scale(1)/translateX(0)
|
|
18638
18744
|
|
|
18639
|
-
var defaultValue = type.
|
|
18745
|
+
var defaultValue = type.substring(0, 5) === 'scale' ? 1 : 0;
|
|
18640
18746
|
right.push({
|
|
18641
18747
|
t: type,
|
|
18642
18748
|
d: args.map(function (arg) {
|
|
@@ -18661,21 +18767,31 @@
|
|
|
18661
18767
|
var rightResult = [];
|
|
18662
18768
|
var types = []; // merge matrix() with matrix3d()
|
|
18663
18769
|
|
|
18664
|
-
if (left.length !== right.length)
|
|
18665
|
-
|
|
18666
|
-
|
|
18667
|
-
|
|
18668
|
-
|
|
18669
|
-
|
|
18770
|
+
if (left.length !== right.length) {
|
|
18771
|
+
var merged = mergeMatrices(left, right); // @ts-ignore
|
|
18772
|
+
|
|
18773
|
+
leftResult = [merged[0]]; // @ts-ignore
|
|
18774
|
+
|
|
18775
|
+
rightResult = [merged[1]];
|
|
18776
|
+
types = [['matrix', [merged[2]]]];
|
|
18777
|
+
} else {
|
|
18778
|
+
for (var _i3 = 0; _i3 < left.length; _i3++) {
|
|
18779
|
+
var leftType = left[_i3].t;
|
|
18780
|
+
var rightType = right[_i3].t;
|
|
18781
|
+
var leftArgs = left[_i3].d;
|
|
18782
|
+
var rightArgs = right[_i3].d;
|
|
18670
18783
|
var leftFunctionData = transformFunctions[leftType];
|
|
18671
18784
|
var rightFunctionData = transformFunctions[rightType];
|
|
18672
18785
|
var type = void 0;
|
|
18673
18786
|
|
|
18674
18787
|
if (isMatrixOrPerspective(leftType, rightType)) {
|
|
18675
|
-
|
|
18676
|
-
|
|
18677
|
-
|
|
18678
|
-
|
|
18788
|
+
var _merged = mergeMatrices([left[_i3]], [right[_i3]]); // @ts-ignore
|
|
18789
|
+
|
|
18790
|
+
|
|
18791
|
+
leftResult.push(_merged[0]); // @ts-ignore
|
|
18792
|
+
|
|
18793
|
+
rightResult.push(_merged[1]);
|
|
18794
|
+
types.push(['matrix', [_merged[2]]]);
|
|
18679
18795
|
continue;
|
|
18680
18796
|
} else if (leftType === rightType) {
|
|
18681
18797
|
type = leftType;
|
|
@@ -18692,10 +18808,13 @@
|
|
|
18692
18808
|
|
|
18693
18809
|
rightArgs = rightFunctionData[1](rightArgs);
|
|
18694
18810
|
} else {
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
|
|
18698
|
-
|
|
18811
|
+
var _merged2 = mergeMatrices(left, right); // @ts-ignore
|
|
18812
|
+
|
|
18813
|
+
|
|
18814
|
+
leftResult = [_merged2[0]]; // @ts-ignore
|
|
18815
|
+
|
|
18816
|
+
rightResult = [_merged2[1]];
|
|
18817
|
+
types = [['matrix', [_merged2[2]]]];
|
|
18699
18818
|
break;
|
|
18700
18819
|
}
|
|
18701
18820
|
|
|
@@ -18706,10 +18825,11 @@
|
|
|
18706
18825
|
for (var j = 0; j < leftArgs.length; j++) {
|
|
18707
18826
|
var merge = leftArgs[j].unit === exports.UnitType.kNumber ? mergeNumbers : mergeDimensions; // @ts-ignore
|
|
18708
18827
|
|
|
18709
|
-
var
|
|
18710
|
-
|
|
18711
|
-
|
|
18712
|
-
|
|
18828
|
+
var _merged3 = merge(leftArgs[j], rightArgs[j], target, false, j);
|
|
18829
|
+
|
|
18830
|
+
leftArgsCopy[j] = _merged3[0];
|
|
18831
|
+
rightArgsCopy[j] = _merged3[1];
|
|
18832
|
+
stringConversions.push(_merged3[2]);
|
|
18713
18833
|
}
|
|
18714
18834
|
|
|
18715
18835
|
leftResult.push(leftArgsCopy);
|
|
@@ -18850,8 +18970,8 @@
|
|
|
18850
18970
|
*/
|
|
18851
18971
|
|
|
18852
18972
|
ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
|
|
18853
|
-
ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
|
|
18854
|
-
|
|
18973
|
+
ElementEvent["BOUNDS_CHANGED"] = "bounds-changed"; // GEOMETRY_BOUNDS_CHANGED = 'geometry-bounds-changed',
|
|
18974
|
+
|
|
18855
18975
|
/**
|
|
18856
18976
|
* trigger when z-index changed
|
|
18857
18977
|
*/
|
|
@@ -19613,6 +19733,7 @@
|
|
|
19613
19733
|
this.localRotation = fromValues$3(0, 0, 0, 1);
|
|
19614
19734
|
this.localScale = fromValues$1(1, 1, 1);
|
|
19615
19735
|
this.localTransform = create$1();
|
|
19736
|
+
this.localSkew = fromValues$4(0, 0);
|
|
19616
19737
|
this.position = fromValues$1(0, 0, 0);
|
|
19617
19738
|
this.rotation = fromValues$3(0, 0, 0, 1);
|
|
19618
19739
|
this.scaling = fromValues$1(1, 1, 1);
|
|
@@ -21065,7 +21186,8 @@
|
|
|
21065
21186
|
fontVariant: '',
|
|
21066
21187
|
textAlign: '',
|
|
21067
21188
|
textBaseline: '',
|
|
21068
|
-
textTransform: ''
|
|
21189
|
+
textTransform: '',
|
|
21190
|
+
zIndex: ''
|
|
21069
21191
|
};
|
|
21070
21192
|
/**
|
|
21071
21193
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
@@ -21097,7 +21219,7 @@
|
|
|
21097
21219
|
* push to active animations after calling `animate()`
|
|
21098
21220
|
*/
|
|
21099
21221
|
function DisplayObject(config) {
|
|
21100
|
-
var _this$config$capture
|
|
21222
|
+
var _this$config$capture;
|
|
21101
21223
|
|
|
21102
21224
|
var _this;
|
|
21103
21225
|
|
|
@@ -21108,6 +21230,7 @@
|
|
|
21108
21230
|
_this.styleValueRegistry = GlobalContainer$1.get(StyleValueRegistry);
|
|
21109
21231
|
_this.isCustomElement = false;
|
|
21110
21232
|
_this.activeAnimations = [];
|
|
21233
|
+
_this.mutationEvent = new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, _assertThisInitialized(_this), null, null, null, MutationEvent.MODIFICATION, null, null);
|
|
21111
21234
|
_this.config = config; // compatible with G 3.0
|
|
21112
21235
|
|
|
21113
21236
|
_this.config.interactive = (_this$config$capture = _this.config.capture) !== null && _this$config$capture !== void 0 ? _this$config$capture : _this.config.interactive; // init scene graph node
|
|
@@ -21121,10 +21244,7 @@
|
|
|
21121
21244
|
|
|
21122
21245
|
_this.nodeName = _this.config.type || exports.Shape.GROUP; // compatible with G 3.0
|
|
21123
21246
|
|
|
21124
|
-
_this.config.style = _extends({}, DEFAULT_STYLE_PROPS,
|
|
21125
|
-
zIndex: (_this$config$zIndex = _this.config.zIndex) !== null && _this$config$zIndex !== void 0 ? _this$config$zIndex : 0,
|
|
21126
|
-
interactive: (_this$config$interact = _this.config.interactive) !== null && _this$config$interact !== void 0 ? _this$config$interact : true
|
|
21127
|
-
}, _this.config.style, _this.config.attrs);
|
|
21247
|
+
_this.config.style = _extends({}, DEFAULT_STYLE_PROPS, _this.config.style, _this.config.attrs);
|
|
21128
21248
|
|
|
21129
21249
|
if (_this.config.visible != null) {
|
|
21130
21250
|
_this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
|
|
@@ -21255,9 +21375,10 @@
|
|
|
21255
21375
|
var oldParsedValue = this.parsedStyle[name];
|
|
21256
21376
|
this.styleValueRegistry.processProperties(this, (_this$styleValueRegis = {}, _this$styleValueRegis[name] = value, _this$styleValueRegis), parseOptions); // inform clip path targets
|
|
21257
21377
|
|
|
21258
|
-
if (this.
|
|
21259
|
-
this.
|
|
21260
|
-
dirtifyToRoot(target);
|
|
21378
|
+
if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
|
|
21379
|
+
this.parsedStyle.clipPathTargets.forEach(function (target) {
|
|
21380
|
+
_this2.sceneGraphService.dirtifyToRoot(target);
|
|
21381
|
+
|
|
21261
21382
|
target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, target, _this2, _this2, 'clipPath', MutationEvent.MODIFICATION, _this2, _this2));
|
|
21262
21383
|
|
|
21263
21384
|
if (target.isCustomElement && target.isConnected) {
|
|
@@ -21269,8 +21390,15 @@
|
|
|
21269
21390
|
} // redraw at next frame
|
|
21270
21391
|
|
|
21271
21392
|
|
|
21272
|
-
renderable.dirty = true;
|
|
21273
|
-
this.
|
|
21393
|
+
renderable.dirty = true; // trigger later
|
|
21394
|
+
// this.sceneGraphService.pendingEvents.push([ElementEvent.ATTR_MODIFIED, { affectChildren }]);
|
|
21395
|
+
|
|
21396
|
+
this.mutationEvent.prevValue = oldValue;
|
|
21397
|
+
this.mutationEvent.newValue = value;
|
|
21398
|
+
this.mutationEvent.attrName = name;
|
|
21399
|
+
this.mutationEvent.prevParsedValue = oldParsedValue;
|
|
21400
|
+
this.mutationEvent.newParsedValue = this.parsedStyle[name];
|
|
21401
|
+
this.dispatchEvent(this.mutationEvent);
|
|
21274
21402
|
|
|
21275
21403
|
if (this.isCustomElement && this.isConnected) {
|
|
21276
21404
|
if (this.attributeChangedCallback) {
|
|
@@ -21526,6 +21654,11 @@
|
|
|
21526
21654
|
return this;
|
|
21527
21655
|
};
|
|
21528
21656
|
|
|
21657
|
+
_proto.setLocalSkew = function setLocalSkew(skew, y) {
|
|
21658
|
+
this.sceneGraphService.setLocalSkew(this, skew, y);
|
|
21659
|
+
return this;
|
|
21660
|
+
};
|
|
21661
|
+
|
|
21529
21662
|
_proto.getRotation = function getRotation() {
|
|
21530
21663
|
return this.sceneGraphService.getRotation(this);
|
|
21531
21664
|
};
|
|
@@ -21534,6 +21667,10 @@
|
|
|
21534
21667
|
return this.sceneGraphService.getLocalRotation(this);
|
|
21535
21668
|
};
|
|
21536
21669
|
|
|
21670
|
+
_proto.getLocalSkew = function getLocalSkew() {
|
|
21671
|
+
return this.sceneGraphService.getLocalSkew(this);
|
|
21672
|
+
};
|
|
21673
|
+
|
|
21537
21674
|
_proto.getLocalTransform = function getLocalTransform() {
|
|
21538
21675
|
return this.sceneGraphService.getLocalTransform(this);
|
|
21539
21676
|
};
|
|
@@ -21572,10 +21709,10 @@
|
|
|
21572
21709
|
|
|
21573
21710
|
var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline; // account for clip path, use target's timeline
|
|
21574
21711
|
|
|
21575
|
-
if (this.
|
|
21712
|
+
if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
|
|
21576
21713
|
var _target$ownerDocument;
|
|
21577
21714
|
|
|
21578
|
-
var target = this.
|
|
21715
|
+
var target = this.parsedStyle.clipPathTargets[0];
|
|
21579
21716
|
timeline = (_target$ownerDocument = target.ownerDocument) === null || _target$ownerDocument === void 0 ? void 0 : _target$ownerDocument.timeline;
|
|
21580
21717
|
} // clear old parsed transform
|
|
21581
21718
|
|
|
@@ -21981,9 +22118,7 @@
|
|
|
21981
22118
|
style: _extends({
|
|
21982
22119
|
cx: '',
|
|
21983
22120
|
cy: '',
|
|
21984
|
-
r: ''
|
|
21985
|
-
anchor: '0.5 0.5',
|
|
21986
|
-
transformOrigin: 'center'
|
|
22121
|
+
r: ''
|
|
21987
22122
|
}, style)
|
|
21988
22123
|
}, rest)) || this;
|
|
21989
22124
|
}
|
|
@@ -22006,9 +22141,7 @@
|
|
|
22006
22141
|
cx: '',
|
|
22007
22142
|
cy: '',
|
|
22008
22143
|
rx: '',
|
|
22009
|
-
ry: ''
|
|
22010
|
-
anchor: '0.5 0.5',
|
|
22011
|
-
transformOrigin: 'center'
|
|
22144
|
+
ry: ''
|
|
22012
22145
|
}, style)
|
|
22013
22146
|
}, rest)) || this;
|
|
22014
22147
|
}
|
|
@@ -22105,9 +22238,17 @@
|
|
|
22105
22238
|
x1 = _this$parsedStyle.x1,
|
|
22106
22239
|
y1 = _this$parsedStyle.y1,
|
|
22107
22240
|
x2 = _this$parsedStyle.x2,
|
|
22108
|
-
y2 = _this$parsedStyle.y2
|
|
22109
|
-
|
|
22110
|
-
|
|
22241
|
+
y2 = _this$parsedStyle.y2,
|
|
22242
|
+
defX = _this$parsedStyle.defX,
|
|
22243
|
+
defY = _this$parsedStyle.defY;
|
|
22244
|
+
|
|
22245
|
+
var _LineUtil$pointAt = line.pointAt(x1.value, y1.value, x2.value, y2.value, ratio),
|
|
22246
|
+
x = _LineUtil$pointAt.x,
|
|
22247
|
+
y = _LineUtil$pointAt.y;
|
|
22248
|
+
|
|
22249
|
+
var transformed = transformMat4(create$2(), fromValues$1(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
|
|
22250
|
+
|
|
22251
|
+
return new Point(transformed[0], transformed[1]);
|
|
22111
22252
|
};
|
|
22112
22253
|
|
|
22113
22254
|
_proto.getTotalLength = function getTotalLength() {
|
|
@@ -22152,7 +22293,10 @@
|
|
|
22152
22293
|
;
|
|
22153
22294
|
|
|
22154
22295
|
_proto.getPoint = function getPoint(ratio) {
|
|
22155
|
-
var _this$parsedStyle
|
|
22296
|
+
var _this$parsedStyle = this.parsedStyle,
|
|
22297
|
+
defX = _this$parsedStyle.defX,
|
|
22298
|
+
defY = _this$parsedStyle.defY,
|
|
22299
|
+
_this$parsedStyle$pat = _this$parsedStyle.path,
|
|
22156
22300
|
totalLength = _this$parsedStyle$pat.totalLength,
|
|
22157
22301
|
absolutePath = _this$parsedStyle$pat.absolutePath;
|
|
22158
22302
|
|
|
@@ -22160,7 +22304,9 @@
|
|
|
22160
22304
|
x = _getPointAtLength.x,
|
|
22161
22305
|
y = _getPointAtLength.y;
|
|
22162
22306
|
|
|
22163
|
-
|
|
22307
|
+
var transformed = transformMat4(create$2(), fromValues$1(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
|
|
22308
|
+
|
|
22309
|
+
return new Point(transformed[0], transformed[1]);
|
|
22164
22310
|
}
|
|
22165
22311
|
/**
|
|
22166
22312
|
* Get start tangent vector
|
|
@@ -22265,7 +22411,10 @@
|
|
|
22265
22411
|
};
|
|
22266
22412
|
|
|
22267
22413
|
_proto.getPoint = function getPoint(ratio) {
|
|
22268
|
-
var _this$parsedStyle
|
|
22414
|
+
var _this$parsedStyle = this.parsedStyle,
|
|
22415
|
+
defX = _this$parsedStyle.defX,
|
|
22416
|
+
defY = _this$parsedStyle.defY,
|
|
22417
|
+
_this$parsedStyle$poi = _this$parsedStyle.points,
|
|
22269
22418
|
points = _this$parsedStyle$poi.points,
|
|
22270
22419
|
segments = _this$parsedStyle$poi.segments;
|
|
22271
22420
|
var subt = 0;
|
|
@@ -22281,7 +22430,9 @@
|
|
|
22281
22430
|
x = _LineUtil$pointAt.x,
|
|
22282
22431
|
y = _LineUtil$pointAt.y;
|
|
22283
22432
|
|
|
22284
|
-
|
|
22433
|
+
var transformed = transformMat4(create$2(), fromValues$1(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
|
|
22434
|
+
|
|
22435
|
+
return new Point(transformed[0], transformed[1]);
|
|
22285
22436
|
};
|
|
22286
22437
|
|
|
22287
22438
|
_proto.getStartTangent = function getStartTangent() {
|
|
@@ -24081,29 +24232,6 @@
|
|
|
24081
24232
|
|
|
24082
24233
|
return zIndex1 - zIndex2;
|
|
24083
24234
|
}
|
|
24084
|
-
function dirtifyToRoot(element, affectChildren) {
|
|
24085
|
-
if (affectChildren === void 0) {
|
|
24086
|
-
affectChildren = false;
|
|
24087
|
-
}
|
|
24088
|
-
|
|
24089
|
-
var p = element;
|
|
24090
|
-
|
|
24091
|
-
while (p) {
|
|
24092
|
-
var renderable = p.renderable;
|
|
24093
|
-
|
|
24094
|
-
if (renderable) {
|
|
24095
|
-
renderable.renderBoundsDirty = true;
|
|
24096
|
-
renderable.boundsDirty = true;
|
|
24097
|
-
renderable.dirty = true;
|
|
24098
|
-
}
|
|
24099
|
-
|
|
24100
|
-
p = p.parentNode;
|
|
24101
|
-
}
|
|
24102
|
-
|
|
24103
|
-
element.dispatchEvent(new CustomEvent(exports.ElementEvent.BOUNDS_CHANGED, {
|
|
24104
|
-
affectChildren: affectChildren
|
|
24105
|
-
}));
|
|
24106
|
-
}
|
|
24107
24235
|
var SceneGraphService = exports.Syringe.defineToken('SceneGraphService');
|
|
24108
24236
|
/**
|
|
24109
24237
|
* update transform in scene graph
|
|
@@ -24116,6 +24244,8 @@
|
|
|
24116
24244
|
var _this = this;
|
|
24117
24245
|
|
|
24118
24246
|
this.sceneGraphSelectorFactory = void 0;
|
|
24247
|
+
this.pendingEvents = [];
|
|
24248
|
+
this.boundsChangedEvent = new CustomEvent(exports.ElementEvent.BOUNDS_CHANGED);
|
|
24119
24249
|
|
|
24120
24250
|
this.rotate = function () {
|
|
24121
24251
|
var parentInvertRotation = create$4();
|
|
@@ -24523,6 +24653,16 @@
|
|
|
24523
24653
|
this.dirtifyLocal(element, transform);
|
|
24524
24654
|
};
|
|
24525
24655
|
|
|
24656
|
+
_proto.setLocalSkew = function setLocalSkew(element, skew, y) {
|
|
24657
|
+
if (typeof skew === 'number') {
|
|
24658
|
+
skew = fromValues$4(skew, y);
|
|
24659
|
+
}
|
|
24660
|
+
|
|
24661
|
+
var transform = element.transformable;
|
|
24662
|
+
copy$4(transform.localSkew, skew);
|
|
24663
|
+
this.dirtifyLocal(element, transform);
|
|
24664
|
+
};
|
|
24665
|
+
|
|
24526
24666
|
_proto.dirtifyLocal = function dirtifyLocal(element, transform) {
|
|
24527
24667
|
if (!transform.localDirtyFlag) {
|
|
24528
24668
|
transform.localDirtyFlag = true;
|
|
@@ -24539,7 +24679,60 @@
|
|
|
24539
24679
|
}
|
|
24540
24680
|
|
|
24541
24681
|
this.dirtifyWorldInternal(element, transform);
|
|
24542
|
-
dirtifyToRoot(element, true);
|
|
24682
|
+
this.dirtifyToRoot(element, true);
|
|
24683
|
+
};
|
|
24684
|
+
|
|
24685
|
+
_proto.triggerPendingEvents = function triggerPendingEvents() {
|
|
24686
|
+
var _this2 = this;
|
|
24687
|
+
|
|
24688
|
+
var set = new Set();
|
|
24689
|
+
|
|
24690
|
+
var trigger = function trigger(element, detail) {
|
|
24691
|
+
if (!set.has(element.entity)) {
|
|
24692
|
+
_this2.boundsChangedEvent.detail = detail;
|
|
24693
|
+
element.dispatchEvent(_this2.boundsChangedEvent);
|
|
24694
|
+
set.add(element.entity);
|
|
24695
|
+
}
|
|
24696
|
+
};
|
|
24697
|
+
|
|
24698
|
+
this.pendingEvents.forEach(function (_ref) {
|
|
24699
|
+
var element = _ref[0],
|
|
24700
|
+
detail = _ref[1];
|
|
24701
|
+
|
|
24702
|
+
if (detail.affectChildren) {
|
|
24703
|
+
element.forEach(function (e) {
|
|
24704
|
+
trigger(e, detail);
|
|
24705
|
+
});
|
|
24706
|
+
} else {
|
|
24707
|
+
trigger(element, detail);
|
|
24708
|
+
}
|
|
24709
|
+
});
|
|
24710
|
+
this.pendingEvents = [];
|
|
24711
|
+
};
|
|
24712
|
+
|
|
24713
|
+
_proto.dirtifyToRoot = function dirtifyToRoot(element, affectChildren) {
|
|
24714
|
+
if (affectChildren === void 0) {
|
|
24715
|
+
affectChildren = false;
|
|
24716
|
+
}
|
|
24717
|
+
|
|
24718
|
+
var p = element;
|
|
24719
|
+
|
|
24720
|
+
while (p) {
|
|
24721
|
+
var renderable = p.renderable;
|
|
24722
|
+
|
|
24723
|
+
if (renderable) {
|
|
24724
|
+
renderable.renderBoundsDirty = true;
|
|
24725
|
+
renderable.boundsDirty = true;
|
|
24726
|
+
renderable.dirty = true;
|
|
24727
|
+
}
|
|
24728
|
+
|
|
24729
|
+
p = p.parentNode;
|
|
24730
|
+
} // reuse the same custom event
|
|
24731
|
+
|
|
24732
|
+
|
|
24733
|
+
this.pendingEvents.push([element, {
|
|
24734
|
+
affectChildren: affectChildren
|
|
24735
|
+
}]);
|
|
24543
24736
|
};
|
|
24544
24737
|
|
|
24545
24738
|
_proto.getPosition = function getPosition(element) {
|
|
@@ -24586,11 +24779,37 @@
|
|
|
24586
24779
|
return element.transformable.localScale;
|
|
24587
24780
|
};
|
|
24588
24781
|
|
|
24782
|
+
_proto.getLocalSkew = function getLocalSkew(element) {
|
|
24783
|
+
return element.transformable.localSkew;
|
|
24784
|
+
};
|
|
24785
|
+
|
|
24786
|
+
_proto.calcLocalTransform = function calcLocalTransform(transform) {
|
|
24787
|
+
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
24788
|
+
// mat4.fromRotationTranslationScaleOrigin(
|
|
24789
|
+
// transform.localTransform,
|
|
24790
|
+
// transform.localRotation,
|
|
24791
|
+
// transform.localPosition,
|
|
24792
|
+
// transform.localScale,
|
|
24793
|
+
// transform.origin,
|
|
24794
|
+
// );
|
|
24795
|
+
fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, fromValues$1(1, 1, 1), transform.origin); // apply skew2D
|
|
24796
|
+
|
|
24797
|
+
if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
|
|
24798
|
+
var tmpMat4 = identity(create$1());
|
|
24799
|
+
tmpMat4[4] = Math.tan(transform.localSkew[0]);
|
|
24800
|
+
tmpMat4[1] = Math.tan(transform.localSkew[1]);
|
|
24801
|
+
multiply(transform.localTransform, transform.localTransform, tmpMat4);
|
|
24802
|
+
}
|
|
24803
|
+
|
|
24804
|
+
var scaling = fromRotationTranslationScaleOrigin(create$1(), fromValues$3(0, 0, 0, 1), create$2(), transform.localScale, transform.origin);
|
|
24805
|
+
multiply(transform.localTransform, transform.localTransform, scaling);
|
|
24806
|
+
};
|
|
24807
|
+
|
|
24589
24808
|
_proto.getLocalTransform = function getLocalTransform(element) {
|
|
24590
24809
|
var transform = element.transformable;
|
|
24591
24810
|
|
|
24592
24811
|
if (transform.localDirtyFlag) {
|
|
24593
|
-
|
|
24812
|
+
this.calcLocalTransform(transform);
|
|
24594
24813
|
transform.localDirtyFlag = false;
|
|
24595
24814
|
}
|
|
24596
24815
|
|
|
@@ -24610,6 +24829,7 @@
|
|
|
24610
24829
|
this.setLocalScale(element, [1, 1, 1]);
|
|
24611
24830
|
this.setLocalPosition(element, [0, 0, 0]);
|
|
24612
24831
|
this.setLocalEulerAngles(element, [0, 0, 0]);
|
|
24832
|
+
this.setLocalSkew(element, [0, 0]);
|
|
24613
24833
|
};
|
|
24614
24834
|
|
|
24615
24835
|
_proto.getTransformedGeometryBounds = function getTransformedGeometryBounds(element, render) {
|
|
@@ -24638,8 +24858,9 @@
|
|
|
24638
24858
|
}
|
|
24639
24859
|
|
|
24640
24860
|
var geometry = element.geometry;
|
|
24641
|
-
var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
|
|
24642
|
-
|
|
24861
|
+
var bounds = render ? geometry.renderBounds : geometry.contentBounds || null; // return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
|
|
24862
|
+
|
|
24863
|
+
return bounds || new AABB();
|
|
24643
24864
|
}
|
|
24644
24865
|
/**
|
|
24645
24866
|
* account for children in world space
|
|
@@ -24647,7 +24868,7 @@
|
|
|
24647
24868
|
;
|
|
24648
24869
|
|
|
24649
24870
|
_proto.getBounds = function getBounds(element, render) {
|
|
24650
|
-
var
|
|
24871
|
+
var _this3 = this;
|
|
24651
24872
|
|
|
24652
24873
|
if (render === void 0) {
|
|
24653
24874
|
render = false;
|
|
@@ -24668,7 +24889,7 @@
|
|
|
24668
24889
|
|
|
24669
24890
|
var children = element.childNodes;
|
|
24670
24891
|
children.forEach(function (child) {
|
|
24671
|
-
var childBounds =
|
|
24892
|
+
var childBounds = _this3.getBounds(child, render);
|
|
24672
24893
|
|
|
24673
24894
|
if (childBounds) {
|
|
24674
24895
|
if (!aabb) {
|
|
@@ -24680,7 +24901,7 @@
|
|
|
24680
24901
|
}
|
|
24681
24902
|
}); // account for clip path
|
|
24682
24903
|
|
|
24683
|
-
var clipPath = element.
|
|
24904
|
+
var clipPath = element.parsedStyle.clipPath;
|
|
24684
24905
|
|
|
24685
24906
|
if (clipPath) {
|
|
24686
24907
|
var clipPathBounds = this.getTransformedGeometryBounds(clipPath, true);
|
|
@@ -24771,7 +24992,7 @@
|
|
|
24771
24992
|
};
|
|
24772
24993
|
|
|
24773
24994
|
_proto.dirtifyWorldInternal = function dirtifyWorldInternal(element, transform) {
|
|
24774
|
-
var
|
|
24995
|
+
var _this4 = this;
|
|
24775
24996
|
|
|
24776
24997
|
if (!transform.dirtyFlag) {
|
|
24777
24998
|
transform.dirtyFlag = true;
|
|
@@ -24780,7 +25001,7 @@
|
|
|
24780
25001
|
var childTransform = child.transformable;
|
|
24781
25002
|
|
|
24782
25003
|
if (!childTransform.dirtyFlag) {
|
|
24783
|
-
|
|
25004
|
+
_this4.dirtifyWorldInternal(child, childTransform);
|
|
24784
25005
|
}
|
|
24785
25006
|
});
|
|
24786
25007
|
var renderable = element.renderable;
|
|
@@ -24790,8 +25011,6 @@
|
|
|
24790
25011
|
renderable.boundsDirty = true;
|
|
24791
25012
|
renderable.dirty = true;
|
|
24792
25013
|
}
|
|
24793
|
-
|
|
24794
|
-
element.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, element, null, null, 'modelMatrix', MutationEvent.MODIFICATION, null, null));
|
|
24795
25014
|
}
|
|
24796
25015
|
};
|
|
24797
25016
|
|
|
@@ -24817,7 +25036,7 @@
|
|
|
24817
25036
|
|
|
24818
25037
|
_proto.sync = function sync(element, transform) {
|
|
24819
25038
|
if (transform.localDirtyFlag) {
|
|
24820
|
-
|
|
25039
|
+
this.calcLocalTransform(transform);
|
|
24821
25040
|
transform.localDirtyFlag = false;
|
|
24822
25041
|
}
|
|
24823
25042
|
|
|
@@ -26029,6 +26248,7 @@
|
|
|
26029
26248
|
exports.RenderingService = /*#__PURE__*/function () {
|
|
26030
26249
|
function RenderingService() {
|
|
26031
26250
|
this.renderingPluginProvider = void 0;
|
|
26251
|
+
this.canvasConfig = void 0;
|
|
26032
26252
|
this.renderingContext = void 0;
|
|
26033
26253
|
this.sceneGraphService = void 0;
|
|
26034
26254
|
this.styleValueRegistry = void 0;
|
|
@@ -26142,6 +26362,21 @@
|
|
|
26142
26362
|
|
|
26143
26363
|
_proto.getStats = function getStats() {
|
|
26144
26364
|
return this.stats;
|
|
26365
|
+
}
|
|
26366
|
+
/**
|
|
26367
|
+
* Meet the following conditions:
|
|
26368
|
+
* * disable DirtyRectangleRendering
|
|
26369
|
+
* * camera changed
|
|
26370
|
+
*/
|
|
26371
|
+
;
|
|
26372
|
+
|
|
26373
|
+
_proto.disableDirtyRectangleRendering = function disableDirtyRectangleRendering() {
|
|
26374
|
+
var renderer = this.canvasConfig.renderer;
|
|
26375
|
+
|
|
26376
|
+
var _renderer$getConfig = renderer.getConfig(),
|
|
26377
|
+
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
26378
|
+
|
|
26379
|
+
return !enableDirtyRectangleRendering || this.renderingContext.renderReasons.has(exports.RenderReason.CAMERA_CHANGED);
|
|
26145
26380
|
};
|
|
26146
26381
|
|
|
26147
26382
|
_proto.render = function render(canvasConfig) {
|
|
@@ -26151,6 +26386,7 @@
|
|
|
26151
26386
|
this.stats.rendered = 0;
|
|
26152
26387
|
this.zIndexCounter = 0;
|
|
26153
26388
|
this.sceneGraphService.syncHierarchy(this.renderingContext.root);
|
|
26389
|
+
this.sceneGraphService.triggerPendingEvents();
|
|
26154
26390
|
|
|
26155
26391
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
26156
26392
|
this.renderDisplayObject(this.renderingContext.root, canvasConfig);
|
|
@@ -26238,6 +26474,8 @@
|
|
|
26238
26474
|
|
|
26239
26475
|
__decorate([contrib(RenderingPluginContribution), __metadata("design:type", Object)], exports.RenderingService.prototype, "renderingPluginProvider", void 0);
|
|
26240
26476
|
|
|
26477
|
+
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], exports.RenderingService.prototype, "canvasConfig", void 0);
|
|
26478
|
+
|
|
26241
26479
|
__decorate([inject(RenderingContext), __metadata("design:type", Object)], exports.RenderingService.prototype, "renderingContext", void 0);
|
|
26242
26480
|
|
|
26243
26481
|
__decorate([inject(SceneGraphService), __metadata("design:type", Object)], exports.RenderingService.prototype, "sceneGraphService", void 0);
|
|
@@ -28231,7 +28469,9 @@
|
|
|
28231
28469
|
*/
|
|
28232
28470
|
|
|
28233
28471
|
exports.CSSPropertyClipPath = /*#__PURE__*/function () {
|
|
28234
|
-
function CSSPropertyClipPath() {
|
|
28472
|
+
function CSSPropertyClipPath() {
|
|
28473
|
+
this.sceneGraphService = void 0;
|
|
28474
|
+
}
|
|
28235
28475
|
|
|
28236
28476
|
var _proto = CSSPropertyClipPath.prototype;
|
|
28237
28477
|
|
|
@@ -28242,26 +28482,28 @@
|
|
|
28242
28482
|
} // clear ref to old clip path
|
|
28243
28483
|
|
|
28244
28484
|
|
|
28245
|
-
if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.
|
|
28246
|
-
var index = oldClipPath.
|
|
28247
|
-
oldClipPath.
|
|
28485
|
+
if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.parsedStyle.clipPathTargets) {
|
|
28486
|
+
var index = oldClipPath.parsedStyle.clipPathTargets.indexOf(object);
|
|
28487
|
+
oldClipPath.parsedStyle.clipPathTargets.splice(index, 1);
|
|
28248
28488
|
}
|
|
28249
28489
|
|
|
28250
28490
|
if (newClipPath) {
|
|
28251
|
-
if (!newClipPath.
|
|
28252
|
-
newClipPath.
|
|
28491
|
+
if (!newClipPath.parsedStyle.clipPathTargets) {
|
|
28492
|
+
newClipPath.parsedStyle.clipPathTargets = [];
|
|
28253
28493
|
}
|
|
28254
28494
|
|
|
28255
|
-
newClipPath.
|
|
28495
|
+
newClipPath.parsedStyle.clipPathTargets.push(object);
|
|
28256
28496
|
}
|
|
28257
28497
|
|
|
28258
|
-
dirtifyToRoot(object);
|
|
28498
|
+
this.sceneGraphService.dirtifyToRoot(object);
|
|
28259
28499
|
return newClipPath;
|
|
28260
28500
|
};
|
|
28261
28501
|
|
|
28262
28502
|
return CSSPropertyClipPath;
|
|
28263
28503
|
}();
|
|
28264
28504
|
|
|
28505
|
+
__decorate([inject(SceneGraphService), __metadata("design:type", Object)], exports.CSSPropertyClipPath.prototype, "sceneGraphService", void 0);
|
|
28506
|
+
|
|
28265
28507
|
exports.CSSPropertyClipPath = __decorate([singleton({
|
|
28266
28508
|
token: {
|
|
28267
28509
|
token: CSSProperty,
|
|
@@ -28341,21 +28583,6 @@
|
|
|
28341
28583
|
_proto.calculator = function calculator(name, oldParsed, computed, object, registry) {
|
|
28342
28584
|
if (CSSUnitValue.isRelativeUnit(computed.unit)) {
|
|
28343
28585
|
if (computed.unit === exports.UnitType.kPercentage) {
|
|
28344
|
-
// try to resolve according to parent's geometry bounds
|
|
28345
|
-
// if (object.parentElement) {
|
|
28346
|
-
// // registry.registerParentGeometryBoundsChangedHandler(object, name);
|
|
28347
|
-
// return this.calculateUsedValueWithParentBounds(object, name);
|
|
28348
|
-
// } else {
|
|
28349
|
-
// registry.addUnresolveProperty(object, name);
|
|
28350
|
-
// // defer calculation after mounted
|
|
28351
|
-
// // object.addEventListener(
|
|
28352
|
-
// // ElementEvent.MOUNTED,
|
|
28353
|
-
// // () => {
|
|
28354
|
-
// // registry.registerParentGeometryBoundsChangedHandler(object, name);
|
|
28355
|
-
// // },
|
|
28356
|
-
// // { once: true },
|
|
28357
|
-
// // );
|
|
28358
|
-
// }
|
|
28359
28586
|
return new CSSUnitValue(0, 'px');
|
|
28360
28587
|
} else if (computed.unit === exports.UnitType.kEms) {
|
|
28361
28588
|
if (object.parentNode) {
|
|
@@ -28389,10 +28616,13 @@
|
|
|
28389
28616
|
}();
|
|
28390
28617
|
|
|
28391
28618
|
exports.CSSPropertyLengthOrPercentage = __decorate([singleton({
|
|
28392
|
-
token: {
|
|
28619
|
+
token: [{
|
|
28393
28620
|
token: CSSProperty,
|
|
28394
28621
|
named: exports.PropertySyntax.LENGTH_PERCENTAGE
|
|
28395
|
-
}
|
|
28622
|
+
}, {
|
|
28623
|
+
token: CSSProperty,
|
|
28624
|
+
named: exports.PropertySyntax.LENGTH
|
|
28625
|
+
}]
|
|
28396
28626
|
})], exports.CSSPropertyLengthOrPercentage);
|
|
28397
28627
|
|
|
28398
28628
|
/**
|
|
@@ -28561,6 +28791,18 @@
|
|
|
28561
28791
|
}
|
|
28562
28792
|
})], exports.CSSPropertyLocalPosition);
|
|
28563
28793
|
|
|
28794
|
+
exports.CSSPropertyNumber = function CSSPropertyNumber() {
|
|
28795
|
+
this.mixer = mergeNumbers;
|
|
28796
|
+
this.parser = parseNumber;
|
|
28797
|
+
};
|
|
28798
|
+
|
|
28799
|
+
exports.CSSPropertyNumber = __decorate([singleton({
|
|
28800
|
+
token: {
|
|
28801
|
+
token: CSSProperty,
|
|
28802
|
+
named: exports.PropertySyntax.NUMBER
|
|
28803
|
+
}
|
|
28804
|
+
})], exports.CSSPropertyNumber);
|
|
28805
|
+
|
|
28564
28806
|
exports.CSSPropertyOffsetDistance = /*#__PURE__*/function () {
|
|
28565
28807
|
function CSSPropertyOffsetDistance() {
|
|
28566
28808
|
this.parser = parseNumber;
|
|
@@ -28869,9 +29111,9 @@
|
|
|
28869
29111
|
// reset transform
|
|
28870
29112
|
object.resetLocalTransform();
|
|
28871
29113
|
object.setLocalPosition(defX, defY);
|
|
28872
|
-
transform.forEach(function (
|
|
28873
|
-
var t =
|
|
28874
|
-
d =
|
|
29114
|
+
transform.forEach(function (parsed) {
|
|
29115
|
+
var t = parsed.t,
|
|
29116
|
+
d = parsed.d;
|
|
28875
29117
|
|
|
28876
29118
|
if (t === 'scale') {
|
|
28877
29119
|
// scale(1) scale(1, 1)
|
|
@@ -28937,7 +29179,24 @@
|
|
|
28937
29179
|
var _newAngles3 = d || [Odeg];
|
|
28938
29180
|
|
|
28939
29181
|
object.rotateLocal(0, 0, _newAngles3[0].value);
|
|
28940
|
-
} else ;
|
|
29182
|
+
} else if (t === 'rotate3d') ; else if (t === 'skew') {
|
|
29183
|
+
var newSkew = d.map(function (s) {
|
|
29184
|
+
return s.value;
|
|
29185
|
+
}) || [0, 0];
|
|
29186
|
+
object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
|
|
29187
|
+
} else if (t === 'skewx') {
|
|
29188
|
+
var _newSkew = d.map(function (s) {
|
|
29189
|
+
return s.value;
|
|
29190
|
+
}) || [0];
|
|
29191
|
+
|
|
29192
|
+
object.setLocalSkew(deg2rad(_newSkew[0]), object.getLocalSkew()[1]);
|
|
29193
|
+
} else if (t === 'skewy') {
|
|
29194
|
+
var _newSkew2 = d.map(function (s) {
|
|
29195
|
+
return s.value;
|
|
29196
|
+
}) || [0];
|
|
29197
|
+
|
|
29198
|
+
object.setLocalSkew(object.getLocalSkew()[0], deg2rad(_newSkew2[0]));
|
|
29199
|
+
}
|
|
28941
29200
|
});
|
|
28942
29201
|
}
|
|
28943
29202
|
};
|
|
@@ -29192,13 +29451,25 @@
|
|
|
29192
29451
|
name: 'transformOrigin',
|
|
29193
29452
|
parsePriority: 100,
|
|
29194
29453
|
// interpolable: true,
|
|
29195
|
-
defaultValue:
|
|
29454
|
+
defaultValue: function defaultValue(nodeName) {
|
|
29455
|
+
if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
|
|
29456
|
+
return 'center';
|
|
29457
|
+
}
|
|
29458
|
+
|
|
29459
|
+
return 'left top';
|
|
29460
|
+
},
|
|
29196
29461
|
layoutDependent: true,
|
|
29197
29462
|
syntax: exports.PropertySyntax.TRANSFORM_ORIGIN
|
|
29198
29463
|
}, {
|
|
29199
29464
|
name: 'anchor',
|
|
29200
29465
|
parsePriority: 99,
|
|
29201
|
-
defaultValue:
|
|
29466
|
+
defaultValue: function defaultValue(nodeName) {
|
|
29467
|
+
if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
|
|
29468
|
+
return '0.5 0.5';
|
|
29469
|
+
}
|
|
29470
|
+
|
|
29471
|
+
return '0 0';
|
|
29472
|
+
},
|
|
29202
29473
|
layoutDependent: true,
|
|
29203
29474
|
syntax: exports.PropertySyntax.LENGTH_PERCENTAGE_12
|
|
29204
29475
|
}, // <circle> & <ellipse>
|
|
@@ -29418,6 +29689,7 @@
|
|
|
29418
29689
|
this.cache = {};
|
|
29419
29690
|
this.unresolvedProperties = {};
|
|
29420
29691
|
this.propertySyntaxFactory = void 0;
|
|
29692
|
+
this.sceneGraphService = void 0;
|
|
29421
29693
|
this.cascadeProperties = {};
|
|
29422
29694
|
}
|
|
29423
29695
|
|
|
@@ -29623,7 +29895,7 @@
|
|
|
29623
29895
|
if (value === 'initial') {
|
|
29624
29896
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
29625
29897
|
if (!isNil(defaultValue)) {
|
|
29626
|
-
computed = this.parseProperty(name, defaultValue, object);
|
|
29898
|
+
computed = this.parseProperty(name, isFunction(defaultValue) ? defaultValue(object.nodeName) : defaultValue, object);
|
|
29627
29899
|
}
|
|
29628
29900
|
} else if (value === 'inherit') {
|
|
29629
29901
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
@@ -29864,8 +30136,7 @@
|
|
|
29864
30136
|
usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0].value || 0) * geometry.contentBounds.halfExtents[0] * 2;
|
|
29865
30137
|
usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1].value || 0) * geometry.contentBounds.halfExtents[1] * 2;
|
|
29866
30138
|
object.setOrigin(usedOriginXValue, usedOriginYValue);
|
|
29867
|
-
|
|
29868
|
-
dirtifyToRoot(object);
|
|
30139
|
+
this.sceneGraphService.dirtifyToRoot(object);
|
|
29869
30140
|
}
|
|
29870
30141
|
};
|
|
29871
30142
|
|
|
@@ -29884,6 +30155,8 @@
|
|
|
29884
30155
|
|
|
29885
30156
|
__decorate([inject(CSSPropertySyntaxFactory), __metadata("design:type", Function)], exports.DefaultStyleValueRegistry.prototype, "propertySyntaxFactory", void 0);
|
|
29886
30157
|
|
|
30158
|
+
__decorate([inject(SceneGraphService), __metadata("design:type", Object)], exports.DefaultStyleValueRegistry.prototype, "sceneGraphService", void 0);
|
|
30159
|
+
|
|
29887
30160
|
__decorate([inversify.postConstruct(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0)], exports.DefaultStyleValueRegistry.prototype, "init", null);
|
|
29888
30161
|
|
|
29889
30162
|
exports.DefaultStyleValueRegistry = __decorate([singleton({
|
|
@@ -29933,6 +30206,7 @@
|
|
|
29933
30206
|
}
|
|
29934
30207
|
}); // bind CSS property handlers
|
|
29935
30208
|
|
|
30209
|
+
register(exports.CSSPropertyNumber);
|
|
29936
30210
|
register(exports.CSSPropertyAngle);
|
|
29937
30211
|
register(exports.CSSPropertyClipPath);
|
|
29938
30212
|
register(exports.CSSPropertyColor);
|
|
@@ -30064,7 +30338,7 @@
|
|
|
30064
30338
|
* only dirty object will cause re-render
|
|
30065
30339
|
*/
|
|
30066
30340
|
enableDirtyCheck: true,
|
|
30067
|
-
enableCulling:
|
|
30341
|
+
enableCulling: false,
|
|
30068
30342
|
|
|
30069
30343
|
/**
|
|
30070
30344
|
* enable auto rendering by default
|
|
@@ -30115,7 +30389,7 @@
|
|
|
30115
30389
|
return AbstractRenderer;
|
|
30116
30390
|
}();
|
|
30117
30391
|
|
|
30118
|
-
let uId=1;const root
|
|
30392
|
+
let uId=1;const root="object"==typeof self&&self.self==self?self:"object"==typeof global&&global.global==global?global:{},nowOffset=Date.now();let reservedCBs={},lastTime=Date.now();const polyfillRaf=e=>{if("function"!=typeof e)throw new TypeError(e+" is not a function");const o=Date.now(),t=o-lastTime,n=t>16?0:16-t,r=uId++;return reservedCBs[r]=e,Object.keys(reservedCBs).length>1||setTimeout((()=>{lastTime=o;const e=reservedCBs;reservedCBs={},Object.keys(e).forEach((o=>e[o](root.performance&&"function"==typeof root.performance.now?root.performance.now():Date.now()-nowOffset)));}),n),r},polyfillCaf=e=>{delete reservedCBs[e];},vendorPrefixes=["","webkit","moz","ms","o"],getRequestAnimationFrame=e=>"string"!=typeof e?polyfillRaf:""===e?root.requestAnimationFrame:root[e+"RequestAnimationFrame"],getCancelAnimationFrame=e=>"string"!=typeof e?polyfillCaf:""===e?root.cancelAnimationFrame:root[e+"CancelAnimationFrame"]||root[e+"CancelRequestAnimationFrame"],find=(e,o)=>{let t=0;for(;void 0!==e[t];){if(o(e[t]))return e[t];t+=1;}},vp=find(vendorPrefixes,(e=>!!getRequestAnimationFrame(e))),raf=getRequestAnimationFrame(vp),caf=getCancelAnimationFrame(vp);root.requestAnimationFrame=raf,root.cancelAnimationFrame=caf,"undefined"!=typeof module&&module.exports&&(module.exports={requestAnimationFrame:raf,cancelAnimationFrame:caf});
|
|
30119
30393
|
|
|
30120
30394
|
var _class$1;
|
|
30121
30395
|
|
|
@@ -30138,26 +30412,29 @@
|
|
|
30138
30412
|
_proto.apply = function apply(renderingService) {
|
|
30139
30413
|
var _this = this;
|
|
30140
30414
|
|
|
30141
|
-
|
|
30415
|
+
var strategies = this.strategyProvider.getContributions();
|
|
30142
30416
|
renderingService.hooks.cull.tap(CullingPlugin_1.tag, function (object) {
|
|
30143
30417
|
if (object) {
|
|
30144
|
-
var cullable = object.cullable;
|
|
30145
|
-
|
|
30146
|
-
//
|
|
30147
|
-
//
|
|
30148
|
-
// // } else {
|
|
30149
|
-
// // const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
|
|
30150
|
-
// // const [p0, p1, p2, p3] = camera.getFrustum().planes;
|
|
30151
|
-
// // tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
|
|
30152
|
-
// // cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
|
|
30153
|
-
// // }
|
|
30154
|
-
// if (strategies.length === 0) {
|
|
30155
|
-
// cullable.visible = this.renderingContext.unculledEntities.indexOf(object.entity) > -1;
|
|
30418
|
+
var cullable = object.cullable; // cullable.visible = true;
|
|
30419
|
+
// const renderBounds = object.getRenderBounds();
|
|
30420
|
+
// if (AABB.isEmpty(renderBounds)) {
|
|
30421
|
+
// cullable.visible = false;
|
|
30156
30422
|
// } else {
|
|
30157
|
-
//
|
|
30158
|
-
//
|
|
30423
|
+
// const isShape2D = shape2D.indexOf(object.nodeName as Shape) > -1;
|
|
30424
|
+
// const [p0, p1, p2, p3] = camera.getFrustum().planes;
|
|
30425
|
+
// tmpAABB.setMinMax([-p1.distance, -p3.distance, 0], [p0.distance, p2.distance, 0]);
|
|
30426
|
+
// cullable.visible = isShape2D ? renderBounds.intersects(tmpAABB) : true;
|
|
30159
30427
|
// }
|
|
30160
30428
|
|
|
30429
|
+
if (strategies.length === 0) {
|
|
30430
|
+
cullable.visible = _this.renderingContext.unculledEntities.indexOf(object.entity) > -1;
|
|
30431
|
+
} else {
|
|
30432
|
+
// eg. implemented by g-webgl(frustum culling)
|
|
30433
|
+
cullable.visible = strategies.every(function (strategy) {
|
|
30434
|
+
return strategy.isVisible(object);
|
|
30435
|
+
});
|
|
30436
|
+
}
|
|
30437
|
+
|
|
30161
30438
|
if (!cullable.isCulled() && object.isVisible()) {
|
|
30162
30439
|
return object;
|
|
30163
30440
|
} else {
|
|
@@ -30195,22 +30472,15 @@
|
|
|
30195
30472
|
*/
|
|
30196
30473
|
|
|
30197
30474
|
var DirtyCheckPlugin = DirtyCheckPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
30198
|
-
function DirtyCheckPlugin() {
|
|
30199
|
-
this.renderingContext = void 0;
|
|
30200
|
-
}
|
|
30475
|
+
function DirtyCheckPlugin() {}
|
|
30201
30476
|
|
|
30202
30477
|
var _proto = DirtyCheckPlugin.prototype;
|
|
30203
30478
|
|
|
30204
30479
|
_proto.apply = function apply(renderingService) {
|
|
30205
|
-
var _this = this;
|
|
30206
|
-
|
|
30207
30480
|
renderingService.hooks.dirtycheck.tap(DirtyCheckPlugin_1.tag, function (object) {
|
|
30208
30481
|
if (object) {
|
|
30209
30482
|
var renderable = object.renderable;
|
|
30210
|
-
|
|
30211
|
-
var isCameraDirty = _this.renderingContext.renderReasons.has(exports.RenderReason.CAMERA_CHANGED);
|
|
30212
|
-
|
|
30213
|
-
var isDirty = renderable.dirty || isCameraDirty;
|
|
30483
|
+
var isDirty = renderable.dirty || renderingService.disableDirtyRectangleRendering();
|
|
30214
30484
|
|
|
30215
30485
|
if (isDirty) {
|
|
30216
30486
|
return object;
|
|
@@ -30225,9 +30495,6 @@
|
|
|
30225
30495
|
|
|
30226
30496
|
return DirtyCheckPlugin;
|
|
30227
30497
|
}(), _class$2.tag = 'DirtyCheck', _class$2);
|
|
30228
|
-
|
|
30229
|
-
__decorate([inject(RenderingContext), __metadata("design:type", Object)], DirtyCheckPlugin.prototype, "renderingContext", void 0);
|
|
30230
|
-
|
|
30231
30498
|
DirtyCheckPlugin = DirtyCheckPlugin_1 = __decorate([singleton({
|
|
30232
30499
|
contrib: RenderingPluginContribution
|
|
30233
30500
|
})], DirtyCheckPlugin);
|
|
@@ -30652,6 +30919,7 @@
|
|
|
30652
30919
|
function PrepareRendererPlugin() {
|
|
30653
30920
|
this.renderingContext = void 0;
|
|
30654
30921
|
this.styleValueRegistry = void 0;
|
|
30922
|
+
this.sceneGraphService = void 0;
|
|
30655
30923
|
this.rBush = void 0;
|
|
30656
30924
|
this.toSync = new Set();
|
|
30657
30925
|
}
|
|
@@ -30698,7 +30966,8 @@
|
|
|
30698
30966
|
|
|
30699
30967
|
_this2.styleValueRegistry.recalc(object);
|
|
30700
30968
|
|
|
30701
|
-
dirtifyToRoot(object);
|
|
30969
|
+
_this2.sceneGraphService.dirtifyToRoot(object);
|
|
30970
|
+
|
|
30702
30971
|
renderingService.dirtify();
|
|
30703
30972
|
};
|
|
30704
30973
|
|
|
@@ -30712,7 +30981,8 @@
|
|
|
30712
30981
|
_this2.toSync.delete(object);
|
|
30713
30982
|
}
|
|
30714
30983
|
|
|
30715
|
-
dirtifyToRoot(e.target);
|
|
30984
|
+
_this2.sceneGraphService.dirtifyToRoot(e.target);
|
|
30985
|
+
|
|
30716
30986
|
renderingService.dirtify();
|
|
30717
30987
|
};
|
|
30718
30988
|
|
|
@@ -30802,6 +31072,8 @@
|
|
|
30802
31072
|
|
|
30803
31073
|
__decorate([inject(StyleValueRegistry), __metadata("design:type", Object)], PrepareRendererPlugin.prototype, "styleValueRegistry", void 0);
|
|
30804
31074
|
|
|
31075
|
+
__decorate([inject(SceneGraphService), __metadata("design:type", Object)], PrepareRendererPlugin.prototype, "sceneGraphService", void 0);
|
|
31076
|
+
|
|
30805
31077
|
__decorate([inject(RBushRoot), __metadata("design:type", RBush)], PrepareRendererPlugin.prototype, "rBush", void 0);
|
|
30806
31078
|
|
|
30807
31079
|
PrepareRendererPlugin = PrepareRendererPlugin_1 = __decorate([singleton({
|
|
@@ -31624,6 +31896,7 @@
|
|
|
31624
31896
|
exports.contrib = contrib;
|
|
31625
31897
|
exports.convertAngleUnit = convertAngleUnit;
|
|
31626
31898
|
exports.convertEffectInput = convertEffectInput;
|
|
31899
|
+
exports.convertItemToMatrix = convertItemToMatrix;
|
|
31627
31900
|
exports.convertPercentUnit = convertPercentUnit;
|
|
31628
31901
|
exports.convertToDash = convertToDash;
|
|
31629
31902
|
exports.convertToPath = convertToPath;
|
|
@@ -31632,7 +31905,6 @@
|
|
|
31632
31905
|
exports.decorate = inversify.decorate;
|
|
31633
31906
|
exports.deg2rad = deg2rad;
|
|
31634
31907
|
exports.deg2turn = deg2turn;
|
|
31635
|
-
exports.dirtifyToRoot = dirtifyToRoot;
|
|
31636
31908
|
exports.equalSet = equalSet;
|
|
31637
31909
|
exports.extractPolygons = extractPolygons;
|
|
31638
31910
|
exports.formatAttribute = formatAttribute;
|
|
@@ -31665,6 +31937,7 @@
|
|
|
31665
31937
|
exports.makePerspective = makePerspective;
|
|
31666
31938
|
exports.makeQuerablePromise = makeQuerablePromise;
|
|
31667
31939
|
exports.makeTiming = makeTiming;
|
|
31940
|
+
exports.memoize = memoize;
|
|
31668
31941
|
exports.mergeColors = mergeColors;
|
|
31669
31942
|
exports.mergeDimensionList = mergeDimensionList;
|
|
31670
31943
|
exports.mergeDimensions = mergeDimensions;
|