@antv/g-lite 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/css/cssom/CSSGradientValue.d.ts +12 -7
- package/dist/css/cssom/CSSGradientValue.d.ts.map +1 -1
- package/dist/css/parser/gradient.d.ts.map +1 -1
- package/dist/dom/Element.d.ts +1 -0
- package/dist/dom/Element.d.ts.map +1 -1
- package/dist/index.esm.js +704 -613
- package/dist/index.js +703 -611
- package/dist/index.umd.js +703 -611
- package/dist/index.umd.min.js +2 -2
- package/dist/plugins/EventPlugin.d.ts +1 -0
- package/dist/plugins/EventPlugin.d.ts.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/gradient.d.ts +3 -2
- package/dist/utils/gradient.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.umd.js
CHANGED
|
@@ -13153,717 +13153,747 @@
|
|
|
13153
13153
|
touchcancel: 'pointercancel'
|
|
13154
13154
|
};
|
|
13155
13155
|
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
var type = colorStop.type,
|
|
13162
|
-
value = colorStop.value;
|
|
13163
|
-
|
|
13164
|
-
if (type === 'hex') {
|
|
13165
|
-
return "#" + value;
|
|
13166
|
-
} else if (type === 'literal') {
|
|
13167
|
-
return value;
|
|
13168
|
-
} else if (type === 'rgb') {
|
|
13169
|
-
return "rgb(" + value.join(',') + ")";
|
|
13170
|
-
} else {
|
|
13171
|
-
return "rgba(" + value.join(',') + ")";
|
|
13156
|
+
function getAngle(angle) {
|
|
13157
|
+
if (angle === undefined) {
|
|
13158
|
+
return 0;
|
|
13159
|
+
} else if (angle > 360 || angle < -360) {
|
|
13160
|
+
return angle % 360;
|
|
13172
13161
|
}
|
|
13173
|
-
}
|
|
13174
|
-
var parseGradient = function () {
|
|
13175
|
-
var tokens = {
|
|
13176
|
-
linearGradient: /^(linear\-gradient)/i,
|
|
13177
|
-
repeatingLinearGradient: /^(repeating\-linear\-gradient)/i,
|
|
13178
|
-
radialGradient: /^(radial\-gradient)/i,
|
|
13179
|
-
repeatingRadialGradient: /^(repeating\-radial\-gradient)/i,
|
|
13180
|
-
|
|
13181
|
-
/**
|
|
13182
|
-
* @see https://projects.verou.me/conic-gradient/
|
|
13183
|
-
*/
|
|
13184
|
-
conicGradient: /^(conic\-gradient)/i,
|
|
13185
|
-
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
13186
|
-
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
13187
|
-
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
13188
|
-
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
13189
|
-
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
13190
|
-
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
13191
|
-
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
13192
|
-
startCall: /^\(/,
|
|
13193
|
-
endCall: /^\)/,
|
|
13194
|
-
comma: /^,/,
|
|
13195
|
-
hexColor: /^\#([0-9a-fA-F]+)/,
|
|
13196
|
-
literalColor: /^([a-zA-Z]+)/,
|
|
13197
|
-
rgbColor: /^rgb/i,
|
|
13198
|
-
rgbaColor: /^rgba/i,
|
|
13199
|
-
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
13200
|
-
};
|
|
13201
|
-
var input = '';
|
|
13202
13162
|
|
|
13203
|
-
|
|
13204
|
-
|
|
13163
|
+
return angle;
|
|
13164
|
+
}
|
|
13165
|
+
function createVec3(x, y, z) {
|
|
13166
|
+
if (y === void 0) {
|
|
13167
|
+
y = 0;
|
|
13205
13168
|
}
|
|
13206
13169
|
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
if (input.length > 0) {
|
|
13211
|
-
error('Invalid input not EOF');
|
|
13212
|
-
}
|
|
13170
|
+
if (z === void 0) {
|
|
13171
|
+
z = 0;
|
|
13172
|
+
}
|
|
13213
13173
|
|
|
13214
|
-
|
|
13174
|
+
if (isNumber(x)) {
|
|
13175
|
+
return fromValues$2(x, y, z);
|
|
13215
13176
|
}
|
|
13216
13177
|
|
|
13217
|
-
|
|
13218
|
-
return
|
|
13178
|
+
if (Array.isArray(x) && x.length === 3) {
|
|
13179
|
+
return clone$1(x);
|
|
13219
13180
|
}
|
|
13220
13181
|
|
|
13221
|
-
|
|
13222
|
-
|
|
13182
|
+
return fromValues$2(x[0], x[1] || y, x[2] || z);
|
|
13183
|
+
}
|
|
13184
|
+
function deg2rad(deg) {
|
|
13185
|
+
return deg * (Math.PI / 180);
|
|
13186
|
+
}
|
|
13187
|
+
function rad2deg(rad) {
|
|
13188
|
+
return rad * (180 / Math.PI);
|
|
13189
|
+
}
|
|
13190
|
+
function grad2deg(grads) {
|
|
13191
|
+
grads = grads % 400;
|
|
13192
|
+
|
|
13193
|
+
if (grads < 0) {
|
|
13194
|
+
grads += 400;
|
|
13223
13195
|
}
|
|
13224
13196
|
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13197
|
+
return grads / 400 * 360;
|
|
13198
|
+
}
|
|
13199
|
+
function deg2turn(deg) {
|
|
13200
|
+
return deg / 360;
|
|
13201
|
+
}
|
|
13202
|
+
function turn2deg(turn) {
|
|
13203
|
+
return 360 * turn;
|
|
13204
|
+
}
|
|
13228
13205
|
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13206
|
+
function getEulerFromQuat(out, quat) {
|
|
13207
|
+
var x = quat[0];
|
|
13208
|
+
var y = quat[1];
|
|
13209
|
+
var z = quat[2];
|
|
13210
|
+
var w = quat[3];
|
|
13211
|
+
var x2 = x * x;
|
|
13212
|
+
var y2 = y * y;
|
|
13213
|
+
var z2 = z * z;
|
|
13214
|
+
var w2 = w * w;
|
|
13215
|
+
var unit = x2 + y2 + z2 + w2;
|
|
13216
|
+
var test = x * w - y * z;
|
|
13234
13217
|
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
}
|
|
13218
|
+
if (test > 0.499995 * unit) {
|
|
13219
|
+
// TODO: Use glmatrix.EPSILON
|
|
13220
|
+
// singularity at the north pole
|
|
13221
|
+
out[0] = Math.PI / 2;
|
|
13222
|
+
out[1] = 2 * Math.atan2(y, x);
|
|
13223
|
+
out[2] = 0;
|
|
13224
|
+
} else if (test < -0.499995 * unit) {
|
|
13225
|
+
//TODO: Use glmatrix.EPSILON
|
|
13226
|
+
// singularity at the south pole
|
|
13227
|
+
out[0] = -Math.PI / 2;
|
|
13228
|
+
out[1] = 2 * Math.atan2(y, x);
|
|
13229
|
+
out[2] = 0;
|
|
13230
|
+
} else {
|
|
13231
|
+
out[0] = Math.asin(2 * (x * z - w * y));
|
|
13232
|
+
out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
|
|
13233
|
+
out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
|
|
13234
|
+
} // TODO: Return them as degrees and not as radians
|
|
13242
13235
|
|
|
13243
|
-
function matchCall(pattern, callback) {
|
|
13244
|
-
var captures = scan(pattern);
|
|
13245
13236
|
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
error('Missing (');
|
|
13249
|
-
}
|
|
13237
|
+
return out;
|
|
13238
|
+
}
|
|
13250
13239
|
|
|
13251
|
-
|
|
13240
|
+
function getEulerFromMat4(out, m) {
|
|
13241
|
+
var x;
|
|
13242
|
+
var z;
|
|
13243
|
+
var halfPi = Math.PI * 0.5;
|
|
13252
13244
|
|
|
13253
|
-
|
|
13254
|
-
|
|
13255
|
-
|
|
13245
|
+
var _mat4$getScaling = getScaling(create$2(), m),
|
|
13246
|
+
sx = _mat4$getScaling[0],
|
|
13247
|
+
sy = _mat4$getScaling[1],
|
|
13248
|
+
sz = _mat4$getScaling[2];
|
|
13256
13249
|
|
|
13257
|
-
|
|
13250
|
+
var y = Math.asin(-m[2] / sx);
|
|
13251
|
+
|
|
13252
|
+
if (y < halfPi) {
|
|
13253
|
+
if (y > -halfPi) {
|
|
13254
|
+
x = Math.atan2(m[6] / sy, m[10] / sz);
|
|
13255
|
+
z = Math.atan2(m[1] / sx, m[0] / sx);
|
|
13256
|
+
} else {
|
|
13257
|
+
// Not a unique solution
|
|
13258
|
+
z = 0;
|
|
13259
|
+
x = -Math.atan2(m[4] / sy, m[5] / sy);
|
|
13258
13260
|
}
|
|
13261
|
+
} else {
|
|
13262
|
+
// Not a unique solution
|
|
13263
|
+
z = 0;
|
|
13264
|
+
x = Math.atan2(m[4] / sy, m[5] / sy);
|
|
13259
13265
|
}
|
|
13260
13266
|
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13267
|
+
out[0] = x;
|
|
13268
|
+
out[1] = y;
|
|
13269
|
+
out[2] = z;
|
|
13270
|
+
return out;
|
|
13271
|
+
}
|
|
13272
|
+
/**
|
|
13273
|
+
* @see https://github.com/toji/gl-matrix/issues/329
|
|
13274
|
+
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
13275
|
+
*/
|
|
13264
13276
|
|
|
13265
|
-
function matchSideOrCorner() {
|
|
13266
|
-
return match('directional', tokens.sideOrCorner, 1);
|
|
13267
|
-
}
|
|
13268
13277
|
|
|
13269
|
-
|
|
13270
|
-
|
|
13278
|
+
function getEuler(out, quat) {
|
|
13279
|
+
if (quat.length === 16) {
|
|
13280
|
+
return getEulerFromMat4(out, quat);
|
|
13281
|
+
} else {
|
|
13282
|
+
return getEulerFromQuat(out, quat);
|
|
13271
13283
|
}
|
|
13284
|
+
}
|
|
13285
|
+
function fromRotationTranslationScale$1(rotation, x, y, scaleX, scaleY) {
|
|
13286
|
+
var cos = Math.cos(rotation);
|
|
13287
|
+
var sin = Math.sin(rotation);
|
|
13288
|
+
return fromValues(scaleX * cos, scaleY * sin, 0, -scaleX * sin, scaleY * cos, 0, x, y, 1);
|
|
13289
|
+
}
|
|
13290
|
+
function makePerspective(out, left, right, top, bottom, near, far) {
|
|
13291
|
+
var x = 2 * near / (right - left);
|
|
13292
|
+
var y = 2 * near / (top - bottom);
|
|
13293
|
+
var a = (right + left) / (right - left);
|
|
13294
|
+
var b = (top + bottom) / (top - bottom);
|
|
13295
|
+
var c = -(far + near) / (far - near);
|
|
13296
|
+
var d = -2 * far * near / (far - near);
|
|
13297
|
+
out[0] = x;
|
|
13298
|
+
out[1] = 0;
|
|
13299
|
+
out[2] = 0;
|
|
13300
|
+
out[3] = 0;
|
|
13301
|
+
out[4] = 0;
|
|
13302
|
+
out[5] = y;
|
|
13303
|
+
out[6] = 0;
|
|
13304
|
+
out[7] = 0;
|
|
13305
|
+
out[8] = a;
|
|
13306
|
+
out[9] = b;
|
|
13307
|
+
out[10] = c;
|
|
13308
|
+
out[11] = -1;
|
|
13309
|
+
out[12] = 0;
|
|
13310
|
+
out[13] = 0;
|
|
13311
|
+
out[14] = d;
|
|
13312
|
+
out[15] = 0;
|
|
13313
|
+
return out;
|
|
13314
|
+
}
|
|
13315
|
+
function decompose(mat) {
|
|
13316
|
+
var row0x = mat[0];
|
|
13317
|
+
var row0y = mat[1];
|
|
13318
|
+
var row1x = mat[3];
|
|
13319
|
+
var row1y = mat[4]; // decompose 3x3 matrix
|
|
13320
|
+
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
13272
13321
|
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
radialOrientation = matchRadialOrientation(),
|
|
13276
|
-
lookaheadCache;
|
|
13277
|
-
|
|
13278
|
-
if (radialOrientation) {
|
|
13279
|
-
radialOrientations = [];
|
|
13280
|
-
radialOrientations.push(radialOrientation);
|
|
13281
|
-
lookaheadCache = input;
|
|
13322
|
+
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
13323
|
+
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
|
|
13282
13324
|
|
|
13283
|
-
|
|
13284
|
-
radialOrientation = matchRadialOrientation();
|
|
13325
|
+
var determinant = row0x * row1y - row0y * row1x;
|
|
13285
13326
|
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13327
|
+
if (determinant < 0) {
|
|
13328
|
+
// Flip axis with minimum unit vector dot product.
|
|
13329
|
+
if (row0x < row1y) {
|
|
13330
|
+
scalingX = -scalingX;
|
|
13331
|
+
} else {
|
|
13332
|
+
scalingY = -scalingY;
|
|
13292
13333
|
}
|
|
13334
|
+
} // Renormalize matrix to remove scale.
|
|
13293
13335
|
|
|
13294
|
-
|
|
13336
|
+
|
|
13337
|
+
if (scalingX) {
|
|
13338
|
+
row0x *= 1 / scalingX;
|
|
13339
|
+
row0y *= 1 / scalingX;
|
|
13295
13340
|
}
|
|
13296
13341
|
|
|
13297
|
-
|
|
13298
|
-
|
|
13342
|
+
if (scalingY) {
|
|
13343
|
+
row1x *= 1 / scalingY;
|
|
13344
|
+
row1y *= 1 / scalingY;
|
|
13345
|
+
} // Compute rotation and renormalize matrix.
|
|
13299
13346
|
|
|
13300
|
-
if (radialType) {
|
|
13301
|
-
// @ts-ignore
|
|
13302
|
-
radialType.at = matchAtPosition();
|
|
13303
|
-
} else {
|
|
13304
|
-
var extent = matchExtentKeyword();
|
|
13305
13347
|
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13348
|
+
var rotation = Math.atan2(row0y, row0x);
|
|
13349
|
+
var angle = rad2deg(rotation);
|
|
13350
|
+
return [mat[6], mat[7], scalingX, scalingY, angle];
|
|
13351
|
+
}
|
|
13352
|
+
var tmp = create$1();
|
|
13353
|
+
var perspectiveMatrix = create$1();
|
|
13354
|
+
var tmpVec4 = create$3();
|
|
13355
|
+
var row = [create$2(), create$2(), create$2()];
|
|
13356
|
+
var pdum3 = create$2();
|
|
13357
|
+
/*
|
|
13358
|
+
Input: matrix ; a 4x4 matrix
|
|
13359
|
+
Output: translation ; a 3 component vector
|
|
13360
|
+
scale ; a 3 component vector
|
|
13361
|
+
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
13362
|
+
perspective ; a 4 component vector
|
|
13363
|
+
quaternion ; a 4 component vector
|
|
13364
|
+
Returns false if the matrix cannot be decomposed, true if it can
|
|
13309
13365
|
|
|
13310
|
-
if (positionAt) {
|
|
13311
|
-
// @ts-ignore
|
|
13312
|
-
radialType.at = positionAt;
|
|
13313
|
-
}
|
|
13314
|
-
} else {
|
|
13315
|
-
var defaultPosition = matchPositioning();
|
|
13316
13366
|
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
};
|
|
13323
|
-
}
|
|
13324
|
-
}
|
|
13325
|
-
}
|
|
13367
|
+
References:
|
|
13368
|
+
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
13369
|
+
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
13370
|
+
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
13371
|
+
*/
|
|
13326
13372
|
|
|
13327
|
-
|
|
13328
|
-
|
|
13373
|
+
function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) {
|
|
13374
|
+
//normalize, if not possible then bail out early
|
|
13375
|
+
if (!normalize$4(tmp, matrix)) return false; // perspectiveMatrix is used to solve for perspective, but it also provides
|
|
13376
|
+
// an easy way to test for singularity of the upper 3x3 component.
|
|
13329
13377
|
|
|
13330
|
-
|
|
13331
|
-
|
|
13378
|
+
copy(perspectiveMatrix, tmp);
|
|
13379
|
+
perspectiveMatrix[3] = 0;
|
|
13380
|
+
perspectiveMatrix[7] = 0;
|
|
13381
|
+
perspectiveMatrix[11] = 0;
|
|
13382
|
+
perspectiveMatrix[15] = 1; // If the perspectiveMatrix is not invertible, we are also unable to
|
|
13383
|
+
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
13332
13384
|
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13385
|
+
if (Math.abs(determinant(perspectiveMatrix)) < 1e-8) return false;
|
|
13386
|
+
var a03 = tmp[3],
|
|
13387
|
+
a13 = tmp[7],
|
|
13388
|
+
a23 = tmp[11],
|
|
13389
|
+
a30 = tmp[12],
|
|
13390
|
+
a31 = tmp[13],
|
|
13391
|
+
a32 = tmp[14],
|
|
13392
|
+
a33 = tmp[15]; // First, isolate perspective.
|
|
13337
13393
|
|
|
13338
|
-
|
|
13339
|
-
|
|
13394
|
+
if (a03 !== 0 || a13 !== 0 || a23 !== 0) {
|
|
13395
|
+
tmpVec4[0] = a03;
|
|
13396
|
+
tmpVec4[1] = a13;
|
|
13397
|
+
tmpVec4[2] = a23;
|
|
13398
|
+
tmpVec4[3] = a33; // Solve the equation by inverting perspectiveMatrix and multiplying
|
|
13399
|
+
// rightHandSide by the inverse.
|
|
13400
|
+
// resuing the perspectiveMatrix here since it's no longer needed
|
|
13340
13401
|
|
|
13341
|
-
|
|
13342
|
-
|
|
13402
|
+
var ret = invert(perspectiveMatrix, perspectiveMatrix);
|
|
13403
|
+
if (!ret) return false;
|
|
13404
|
+
transpose(perspectiveMatrix, perspectiveMatrix); //multiply by transposed inverse perspective matrix, into perspective vec4
|
|
13343
13405
|
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13406
|
+
transformMat4$1(perspective, tmpVec4, perspectiveMatrix);
|
|
13407
|
+
} else {
|
|
13408
|
+
//no perspective
|
|
13409
|
+
perspective[0] = perspective[1] = perspective[2] = 0;
|
|
13410
|
+
perspective[3] = 1;
|
|
13411
|
+
} // Next take care of translation
|
|
13412
|
+
|
|
13413
|
+
|
|
13414
|
+
translation[0] = a30;
|
|
13415
|
+
translation[1] = a31;
|
|
13416
|
+
translation[2] = a32; // Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
13417
|
+
|
|
13418
|
+
mat3from4(row, tmp); // Compute X scale factor and normalize first row.
|
|
13419
|
+
|
|
13420
|
+
scale[0] = length(row[0]);
|
|
13421
|
+
normalize(row[0], row[0]); // Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
13422
|
+
|
|
13423
|
+
skew[0] = dot(row[0], row[1]);
|
|
13424
|
+
combine(row[1], row[1], row[0], 1.0, -skew[0]); // Now, compute Y scale and normalize 2nd row.
|
|
13425
|
+
|
|
13426
|
+
scale[1] = length(row[1]);
|
|
13427
|
+
normalize(row[1], row[1]);
|
|
13428
|
+
skew[0] /= scale[1]; // Compute XZ and YZ shears, orthogonalize 3rd row
|
|
13429
|
+
|
|
13430
|
+
skew[1] = dot(row[0], row[2]);
|
|
13431
|
+
combine(row[2], row[2], row[0], 1.0, -skew[1]);
|
|
13432
|
+
skew[2] = dot(row[1], row[2]);
|
|
13433
|
+
combine(row[2], row[2], row[1], 1.0, -skew[2]); // Next, get Z scale and normalize 3rd row.
|
|
13434
|
+
|
|
13435
|
+
scale[2] = length(row[2]);
|
|
13436
|
+
normalize(row[2], row[2]);
|
|
13437
|
+
skew[1] /= scale[2];
|
|
13438
|
+
skew[2] /= scale[2]; // At this point, the matrix (in rows) is orthonormal.
|
|
13439
|
+
// Check for a coordinate system flip. If the determinant
|
|
13440
|
+
// is -1, then negate the matrix and the scaling factors.
|
|
13441
|
+
|
|
13442
|
+
cross(pdum3, row[1], row[2]);
|
|
13443
|
+
|
|
13444
|
+
if (dot(row[0], pdum3) < 0) {
|
|
13445
|
+
for (var i = 0; i < 3; i++) {
|
|
13446
|
+
scale[i] *= -1;
|
|
13447
|
+
row[i][0] *= -1;
|
|
13448
|
+
row[i][1] *= -1;
|
|
13449
|
+
row[i][2] *= -1;
|
|
13347
13450
|
}
|
|
13451
|
+
} // Now, get the rotations out
|
|
13348
13452
|
|
|
13349
|
-
return ellipse;
|
|
13350
|
-
}
|
|
13351
13453
|
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13454
|
+
quaternion[0] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
|
|
13455
|
+
quaternion[1] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
|
|
13456
|
+
quaternion[2] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
|
|
13457
|
+
quaternion[3] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
13458
|
+
if (row[2][1] > row[1][2]) quaternion[0] = -quaternion[0];
|
|
13459
|
+
if (row[0][2] > row[2][0]) quaternion[1] = -quaternion[1];
|
|
13460
|
+
if (row[1][0] > row[0][1]) quaternion[2] = -quaternion[2];
|
|
13461
|
+
return true;
|
|
13462
|
+
}
|
|
13355
13463
|
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
var positioning = matchPositioning();
|
|
13464
|
+
function normalize$4(out, mat) {
|
|
13465
|
+
var m44 = mat[15]; // Cannot normalize.
|
|
13359
13466
|
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
}
|
|
13467
|
+
if (m44 === 0) return false;
|
|
13468
|
+
var scale = 1 / m44;
|
|
13363
13469
|
|
|
13364
|
-
|
|
13365
|
-
|
|
13470
|
+
for (var i = 0; i < 16; i++) {
|
|
13471
|
+
out[i] = mat[i] * scale;
|
|
13366
13472
|
}
|
|
13367
13473
|
|
|
13368
|
-
|
|
13369
|
-
|
|
13474
|
+
return true;
|
|
13475
|
+
} //gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
13370
13476
|
|
|
13371
|
-
if (location.x || location.y) {
|
|
13372
|
-
return {
|
|
13373
|
-
type: 'position',
|
|
13374
|
-
value: location
|
|
13375
|
-
};
|
|
13376
|
-
}
|
|
13377
|
-
}
|
|
13378
13477
|
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13478
|
+
function mat3from4(out, mat4x4) {
|
|
13479
|
+
out[0][0] = mat4x4[0];
|
|
13480
|
+
out[0][1] = mat4x4[1];
|
|
13481
|
+
out[0][2] = mat4x4[2];
|
|
13482
|
+
out[1][0] = mat4x4[4];
|
|
13483
|
+
out[1][1] = mat4x4[5];
|
|
13484
|
+
out[1][2] = mat4x4[6];
|
|
13485
|
+
out[2][0] = mat4x4[8];
|
|
13486
|
+
out[2][1] = mat4x4[9];
|
|
13487
|
+
out[2][2] = mat4x4[10];
|
|
13488
|
+
}
|
|
13385
13489
|
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13490
|
+
function combine(out, a, b, scale1, scale2) {
|
|
13491
|
+
out[0] = a[0] * scale1 + b[0] * scale2;
|
|
13492
|
+
out[1] = a[1] * scale1 + b[1] * scale2;
|
|
13493
|
+
out[2] = a[2] * scale1 + b[2] * scale2;
|
|
13494
|
+
}
|
|
13389
13495
|
|
|
13390
|
-
|
|
13391
|
-
|
|
13496
|
+
/**
|
|
13497
|
+
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
13498
|
+
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
13499
|
+
*/
|
|
13500
|
+
function colorStopToString(colorStop) {
|
|
13501
|
+
var type = colorStop.type,
|
|
13502
|
+
value = colorStop.value;
|
|
13392
13503
|
|
|
13393
|
-
|
|
13394
|
-
|
|
13504
|
+
if (type === 'hex') {
|
|
13505
|
+
return "#" + value;
|
|
13506
|
+
} else if (type === 'literal') {
|
|
13507
|
+
return value;
|
|
13508
|
+
} else if (type === 'rgb') {
|
|
13509
|
+
return "rgb(" + value.join(',') + ")";
|
|
13510
|
+
} else {
|
|
13511
|
+
return "rgba(" + value.join(',') + ")";
|
|
13512
|
+
}
|
|
13513
|
+
}
|
|
13514
|
+
var parseGradient = function () {
|
|
13515
|
+
var tokens = {
|
|
13516
|
+
linearGradient: /^(linear\-gradient)/i,
|
|
13517
|
+
repeatingLinearGradient: /^(repeating\-linear\-gradient)/i,
|
|
13518
|
+
radialGradient: /^(radial\-gradient)/i,
|
|
13519
|
+
repeatingRadialGradient: /^(repeating\-radial\-gradient)/i,
|
|
13395
13520
|
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13521
|
+
/**
|
|
13522
|
+
* @see https://projects.verou.me/conic-gradient/
|
|
13523
|
+
*/
|
|
13524
|
+
conicGradient: /^(conic\-gradient)/i,
|
|
13525
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
13526
|
+
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
13527
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
13528
|
+
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
13529
|
+
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
13530
|
+
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
13531
|
+
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
13532
|
+
startCall: /^\(/,
|
|
13533
|
+
endCall: /^\)/,
|
|
13534
|
+
comma: /^,/,
|
|
13535
|
+
hexColor: /^\#([0-9a-fA-F]+)/,
|
|
13536
|
+
literalColor: /^([a-zA-Z]+)/,
|
|
13537
|
+
rgbColor: /^rgb/i,
|
|
13538
|
+
rgbaColor: /^rgba/i,
|
|
13539
|
+
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
13540
|
+
};
|
|
13541
|
+
var input = '';
|
|
13403
13542
|
|
|
13404
|
-
|
|
13543
|
+
function error(msg) {
|
|
13544
|
+
throw new Error(input + ': ' + msg);
|
|
13405
13545
|
}
|
|
13406
13546
|
|
|
13407
|
-
function
|
|
13408
|
-
var
|
|
13547
|
+
function getAST() {
|
|
13548
|
+
var ast = matchListDefinitions();
|
|
13409
13549
|
|
|
13410
|
-
if (
|
|
13411
|
-
error('
|
|
13550
|
+
if (input.length > 0) {
|
|
13551
|
+
error('Invalid input not EOF');
|
|
13412
13552
|
}
|
|
13413
13553
|
|
|
13414
|
-
|
|
13415
|
-
return color;
|
|
13554
|
+
return ast;
|
|
13416
13555
|
}
|
|
13417
13556
|
|
|
13418
|
-
function
|
|
13419
|
-
return
|
|
13557
|
+
function matchListDefinitions() {
|
|
13558
|
+
return matchListing(matchDefinition);
|
|
13420
13559
|
}
|
|
13421
13560
|
|
|
13422
|
-
function
|
|
13423
|
-
return
|
|
13561
|
+
function matchDefinition() {
|
|
13562
|
+
return matchGradient('linear-gradient', tokens.linearGradient, matchLinearOrientation) || matchGradient('repeating-linear-gradient', tokens.repeatingLinearGradient, matchLinearOrientation) || matchGradient('radial-gradient', tokens.radialGradient, matchListRadialOrientations) || matchGradient('repeating-radial-gradient', tokens.repeatingRadialGradient, matchListRadialOrientations) || matchGradient('conic-gradient', tokens.conicGradient, matchListRadialOrientations);
|
|
13424
13563
|
}
|
|
13425
13564
|
|
|
13426
|
-
function
|
|
13427
|
-
return
|
|
13428
|
-
|
|
13565
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
13566
|
+
return matchCall(pattern, function (captures) {
|
|
13567
|
+
var orientation = orientationMatcher();
|
|
13429
13568
|
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
};
|
|
13436
|
-
});
|
|
13437
|
-
}
|
|
13569
|
+
if (orientation) {
|
|
13570
|
+
if (!scan(tokens.comma)) {
|
|
13571
|
+
error('Missing comma before color stops');
|
|
13572
|
+
}
|
|
13573
|
+
}
|
|
13438
13574
|
|
|
13439
|
-
function matchRGBAColor() {
|
|
13440
|
-
return matchCall(tokens.rgbaColor, function () {
|
|
13441
13575
|
return {
|
|
13442
|
-
type:
|
|
13443
|
-
|
|
13576
|
+
type: gradientType,
|
|
13577
|
+
orientation: orientation,
|
|
13578
|
+
colorStops: matchListing(matchColorStop)
|
|
13444
13579
|
};
|
|
13445
13580
|
});
|
|
13446
13581
|
}
|
|
13447
13582
|
|
|
13448
|
-
function
|
|
13449
|
-
return scan(tokens.number)[1];
|
|
13450
|
-
}
|
|
13451
|
-
|
|
13452
|
-
function matchDistance() {
|
|
13453
|
-
return match('%', tokens.percentageValue, 1) || matchPositionKeyword() || matchLength();
|
|
13454
|
-
}
|
|
13455
|
-
|
|
13456
|
-
function matchPositionKeyword() {
|
|
13457
|
-
return match('position-keyword', tokens.positionKeywords, 1);
|
|
13458
|
-
}
|
|
13459
|
-
|
|
13460
|
-
function matchLength() {
|
|
13461
|
-
return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1);
|
|
13462
|
-
}
|
|
13463
|
-
|
|
13464
|
-
function match(type, pattern, captureIndex) {
|
|
13583
|
+
function matchCall(pattern, callback) {
|
|
13465
13584
|
var captures = scan(pattern);
|
|
13466
13585
|
|
|
13467
13586
|
if (captures) {
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
};
|
|
13472
|
-
}
|
|
13473
|
-
}
|
|
13474
|
-
|
|
13475
|
-
function scan(regexp) {
|
|
13476
|
-
var blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
13477
|
-
|
|
13478
|
-
if (blankCaptures) {
|
|
13479
|
-
consume(blankCaptures[0].length);
|
|
13480
|
-
}
|
|
13481
|
-
|
|
13482
|
-
var captures = regexp.exec(input);
|
|
13483
|
-
|
|
13484
|
-
if (captures) {
|
|
13485
|
-
consume(captures[0].length);
|
|
13486
|
-
}
|
|
13487
|
-
|
|
13488
|
-
return captures;
|
|
13489
|
-
}
|
|
13490
|
-
|
|
13491
|
-
function consume(size) {
|
|
13492
|
-
input = input.substring(size);
|
|
13493
|
-
}
|
|
13494
|
-
|
|
13495
|
-
return function (code) {
|
|
13496
|
-
input = code;
|
|
13497
|
-
return getAST();
|
|
13498
|
-
};
|
|
13499
|
-
}();
|
|
13500
|
-
function computeLinearGradient(width, height, angle) {
|
|
13501
|
-
var rad = angle * Math.PI / 180;
|
|
13502
|
-
var rx = 0;
|
|
13503
|
-
var ry = 0;
|
|
13504
|
-
var rcx = rx + width / 2;
|
|
13505
|
-
var rcy = ry + height / 2; // get the length of gradient line
|
|
13506
|
-
// @see https://observablehq.com/@danburzo/css-gradient-line
|
|
13587
|
+
if (!scan(tokens.startCall)) {
|
|
13588
|
+
error('Missing (');
|
|
13589
|
+
}
|
|
13507
13590
|
|
|
13508
|
-
|
|
13509
|
-
var x1 = rcx - Math.cos(rad) * length / 2;
|
|
13510
|
-
var y1 = rcy - Math.sin(rad) * length / 2;
|
|
13511
|
-
var x2 = rcx + Math.cos(rad) * length / 2;
|
|
13512
|
-
var y2 = rcy + Math.sin(rad) * length / 2;
|
|
13513
|
-
return {
|
|
13514
|
-
x1: x1,
|
|
13515
|
-
y1: y1,
|
|
13516
|
-
x2: x2,
|
|
13517
|
-
y2: y2
|
|
13518
|
-
};
|
|
13519
|
-
}
|
|
13520
|
-
function computeRadialGradient(width, height, cx, cy) {
|
|
13521
|
-
var r = Math.sqrt(width * width + height * height) / 2;
|
|
13522
|
-
return {
|
|
13523
|
-
x: cx * width,
|
|
13524
|
-
y: cy * height,
|
|
13525
|
-
r: r
|
|
13526
|
-
};
|
|
13527
|
-
}
|
|
13591
|
+
var result = callback(captures);
|
|
13528
13592
|
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
} else if (angle > 360 || angle < -360) {
|
|
13533
|
-
return angle % 360;
|
|
13534
|
-
}
|
|
13593
|
+
if (!scan(tokens.endCall)) {
|
|
13594
|
+
error('Missing )');
|
|
13595
|
+
}
|
|
13535
13596
|
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
function createVec3(x, y, z) {
|
|
13539
|
-
if (y === void 0) {
|
|
13540
|
-
y = 0;
|
|
13597
|
+
return result;
|
|
13598
|
+
}
|
|
13541
13599
|
}
|
|
13542
13600
|
|
|
13543
|
-
|
|
13544
|
-
|
|
13601
|
+
function matchLinearOrientation() {
|
|
13602
|
+
return matchSideOrCorner() || matchAngle();
|
|
13545
13603
|
}
|
|
13546
13604
|
|
|
13547
|
-
|
|
13548
|
-
return
|
|
13605
|
+
function matchSideOrCorner() {
|
|
13606
|
+
return match('directional', tokens.sideOrCorner, 1);
|
|
13549
13607
|
}
|
|
13550
13608
|
|
|
13551
|
-
|
|
13552
|
-
return
|
|
13609
|
+
function matchAngle() {
|
|
13610
|
+
return match('angular', tokens.angleValue, 1);
|
|
13553
13611
|
}
|
|
13554
13612
|
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
}
|
|
13560
|
-
function rad2deg(rad) {
|
|
13561
|
-
return rad * (180 / Math.PI);
|
|
13562
|
-
}
|
|
13563
|
-
function grad2deg(grads) {
|
|
13564
|
-
grads = grads % 400;
|
|
13613
|
+
function matchListRadialOrientations() {
|
|
13614
|
+
var radialOrientations,
|
|
13615
|
+
radialOrientation = matchRadialOrientation(),
|
|
13616
|
+
lookaheadCache;
|
|
13565
13617
|
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13618
|
+
if (radialOrientation) {
|
|
13619
|
+
radialOrientations = [];
|
|
13620
|
+
radialOrientations.push(radialOrientation);
|
|
13621
|
+
lookaheadCache = input;
|
|
13569
13622
|
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
function deg2turn(deg) {
|
|
13573
|
-
return deg / 360;
|
|
13574
|
-
}
|
|
13575
|
-
function turn2deg(turn) {
|
|
13576
|
-
return 360 * turn;
|
|
13577
|
-
}
|
|
13623
|
+
if (scan(tokens.comma)) {
|
|
13624
|
+
radialOrientation = matchRadialOrientation();
|
|
13578
13625
|
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
var z2 = z * z;
|
|
13587
|
-
var w2 = w * w;
|
|
13588
|
-
var unit = x2 + y2 + z2 + w2;
|
|
13589
|
-
var test = x * w - y * z;
|
|
13626
|
+
if (radialOrientation) {
|
|
13627
|
+
radialOrientations.push(radialOrientation);
|
|
13628
|
+
} else {
|
|
13629
|
+
input = lookaheadCache;
|
|
13630
|
+
}
|
|
13631
|
+
}
|
|
13632
|
+
}
|
|
13590
13633
|
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
// singularity at the north pole
|
|
13594
|
-
out[0] = Math.PI / 2;
|
|
13595
|
-
out[1] = 2 * Math.atan2(y, x);
|
|
13596
|
-
out[2] = 0;
|
|
13597
|
-
} else if (test < -0.499995 * unit) {
|
|
13598
|
-
//TODO: Use glmatrix.EPSILON
|
|
13599
|
-
// singularity at the south pole
|
|
13600
|
-
out[0] = -Math.PI / 2;
|
|
13601
|
-
out[1] = 2 * Math.atan2(y, x);
|
|
13602
|
-
out[2] = 0;
|
|
13603
|
-
} else {
|
|
13604
|
-
out[0] = Math.asin(2 * (x * z - w * y));
|
|
13605
|
-
out[1] = Math.atan2(2 * (x * w + y * z), 1 - 2 * (z2 + w2));
|
|
13606
|
-
out[2] = Math.atan2(2 * (x * y + z * w), 1 - 2 * (y2 + z2));
|
|
13607
|
-
} // TODO: Return them as degrees and not as radians
|
|
13634
|
+
return radialOrientations;
|
|
13635
|
+
}
|
|
13608
13636
|
|
|
13637
|
+
function matchRadialOrientation() {
|
|
13638
|
+
var radialType = matchCircle() || matchEllipse();
|
|
13609
13639
|
|
|
13610
|
-
|
|
13611
|
-
|
|
13640
|
+
if (radialType) {
|
|
13641
|
+
// @ts-ignore
|
|
13642
|
+
radialType.at = matchAtPosition();
|
|
13643
|
+
} else {
|
|
13644
|
+
var extent = matchExtentKeyword();
|
|
13612
13645
|
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
var halfPi = Math.PI * 0.5;
|
|
13646
|
+
if (extent) {
|
|
13647
|
+
radialType = extent;
|
|
13648
|
+
var positionAt = matchAtPosition();
|
|
13617
13649
|
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13650
|
+
if (positionAt) {
|
|
13651
|
+
// @ts-ignore
|
|
13652
|
+
radialType.at = positionAt;
|
|
13653
|
+
}
|
|
13654
|
+
} else {
|
|
13655
|
+
var defaultPosition = matchPositioning();
|
|
13622
13656
|
|
|
13623
|
-
|
|
13657
|
+
if (defaultPosition) {
|
|
13658
|
+
radialType = {
|
|
13659
|
+
type: 'default-radial',
|
|
13660
|
+
// @ts-ignore
|
|
13661
|
+
at: defaultPosition
|
|
13662
|
+
};
|
|
13663
|
+
}
|
|
13664
|
+
}
|
|
13665
|
+
}
|
|
13624
13666
|
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13667
|
+
return radialType;
|
|
13668
|
+
}
|
|
13669
|
+
|
|
13670
|
+
function matchCircle() {
|
|
13671
|
+
var circle = match('shape', /^(circle)/i, 0);
|
|
13672
|
+
|
|
13673
|
+
if (circle) {
|
|
13674
|
+
// @ts-ignore
|
|
13675
|
+
circle.style = matchLength() || matchExtentKeyword();
|
|
13633
13676
|
}
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
z = 0;
|
|
13637
|
-
x = Math.atan2(m[4] / sy, m[5] / sy);
|
|
13677
|
+
|
|
13678
|
+
return circle;
|
|
13638
13679
|
}
|
|
13639
13680
|
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
out[2] = z;
|
|
13643
|
-
return out;
|
|
13644
|
-
}
|
|
13645
|
-
/**
|
|
13646
|
-
* @see https://github.com/toji/gl-matrix/issues/329
|
|
13647
|
-
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
13648
|
-
*/
|
|
13681
|
+
function matchEllipse() {
|
|
13682
|
+
var ellipse = match('shape', /^(ellipse)/i, 0);
|
|
13649
13683
|
|
|
13684
|
+
if (ellipse) {
|
|
13685
|
+
// @ts-ignore
|
|
13686
|
+
ellipse.style = matchDistance() || matchExtentKeyword();
|
|
13687
|
+
}
|
|
13650
13688
|
|
|
13651
|
-
|
|
13652
|
-
if (quat.length === 16) {
|
|
13653
|
-
return getEulerFromMat4(out, quat);
|
|
13654
|
-
} else {
|
|
13655
|
-
return getEulerFromQuat(out, quat);
|
|
13689
|
+
return ellipse;
|
|
13656
13690
|
}
|
|
13657
|
-
}
|
|
13658
|
-
function fromRotationTranslationScale$1(rotation, x, y, scaleX, scaleY) {
|
|
13659
|
-
var cos = Math.cos(rotation);
|
|
13660
|
-
var sin = Math.sin(rotation);
|
|
13661
|
-
return fromValues(scaleX * cos, scaleY * sin, 0, -scaleX * sin, scaleY * cos, 0, x, y, 1);
|
|
13662
|
-
}
|
|
13663
|
-
function makePerspective(out, left, right, top, bottom, near, far) {
|
|
13664
|
-
var x = 2 * near / (right - left);
|
|
13665
|
-
var y = 2 * near / (top - bottom);
|
|
13666
|
-
var a = (right + left) / (right - left);
|
|
13667
|
-
var b = (top + bottom) / (top - bottom);
|
|
13668
|
-
var c = -(far + near) / (far - near);
|
|
13669
|
-
var d = -2 * far * near / (far - near);
|
|
13670
|
-
out[0] = x;
|
|
13671
|
-
out[1] = 0;
|
|
13672
|
-
out[2] = 0;
|
|
13673
|
-
out[3] = 0;
|
|
13674
|
-
out[4] = 0;
|
|
13675
|
-
out[5] = y;
|
|
13676
|
-
out[6] = 0;
|
|
13677
|
-
out[7] = 0;
|
|
13678
|
-
out[8] = a;
|
|
13679
|
-
out[9] = b;
|
|
13680
|
-
out[10] = c;
|
|
13681
|
-
out[11] = -1;
|
|
13682
|
-
out[12] = 0;
|
|
13683
|
-
out[13] = 0;
|
|
13684
|
-
out[14] = d;
|
|
13685
|
-
out[15] = 0;
|
|
13686
|
-
return out;
|
|
13687
|
-
}
|
|
13688
|
-
function decompose(mat) {
|
|
13689
|
-
var row0x = mat[0];
|
|
13690
|
-
var row0y = mat[1];
|
|
13691
|
-
var row1x = mat[3];
|
|
13692
|
-
var row1y = mat[4]; // decompose 3x3 matrix
|
|
13693
|
-
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
13694
13691
|
|
|
13695
|
-
|
|
13696
|
-
|
|
13692
|
+
function matchExtentKeyword() {
|
|
13693
|
+
return match('extent-keyword', tokens.extentKeywords, 1);
|
|
13694
|
+
}
|
|
13697
13695
|
|
|
13698
|
-
|
|
13696
|
+
function matchAtPosition() {
|
|
13697
|
+
if (match('position', /^at/, 0)) {
|
|
13698
|
+
var positioning = matchPositioning();
|
|
13699
13699
|
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
scalingY = -scalingY;
|
|
13700
|
+
if (!positioning) {
|
|
13701
|
+
error('Missing positioning value');
|
|
13702
|
+
}
|
|
13703
|
+
|
|
13704
|
+
return positioning;
|
|
13706
13705
|
}
|
|
13707
|
-
}
|
|
13706
|
+
}
|
|
13708
13707
|
|
|
13708
|
+
function matchPositioning() {
|
|
13709
|
+
var location = matchCoordinates();
|
|
13709
13710
|
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13711
|
+
if (location.x || location.y) {
|
|
13712
|
+
return {
|
|
13713
|
+
type: 'position',
|
|
13714
|
+
value: location
|
|
13715
|
+
};
|
|
13716
|
+
}
|
|
13713
13717
|
}
|
|
13714
13718
|
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
+
function matchCoordinates() {
|
|
13720
|
+
return {
|
|
13721
|
+
x: matchDistance(),
|
|
13722
|
+
y: matchDistance()
|
|
13723
|
+
};
|
|
13724
|
+
}
|
|
13725
|
+
|
|
13726
|
+
function matchListing(matcher) {
|
|
13727
|
+
var captures = matcher();
|
|
13728
|
+
var result = [];
|
|
13729
|
+
|
|
13730
|
+
if (captures) {
|
|
13731
|
+
result.push(captures);
|
|
13719
13732
|
|
|
13733
|
+
while (scan(tokens.comma)) {
|
|
13734
|
+
captures = matcher();
|
|
13720
13735
|
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
var row = [create$2(), create$2(), create$2()];
|
|
13729
|
-
var pdum3 = create$2();
|
|
13730
|
-
/*
|
|
13731
|
-
Input: matrix ; a 4x4 matrix
|
|
13732
|
-
Output: translation ; a 3 component vector
|
|
13733
|
-
scale ; a 3 component vector
|
|
13734
|
-
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
13735
|
-
perspective ; a 4 component vector
|
|
13736
|
-
quaternion ; a 4 component vector
|
|
13737
|
-
Returns false if the matrix cannot be decomposed, true if it can
|
|
13736
|
+
if (captures) {
|
|
13737
|
+
result.push(captures);
|
|
13738
|
+
} else {
|
|
13739
|
+
error('One extra comma');
|
|
13740
|
+
}
|
|
13741
|
+
}
|
|
13742
|
+
}
|
|
13738
13743
|
|
|
13744
|
+
return result;
|
|
13745
|
+
}
|
|
13739
13746
|
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
13743
|
-
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
13744
|
-
*/
|
|
13747
|
+
function matchColorStop() {
|
|
13748
|
+
var color = matchColor();
|
|
13745
13749
|
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
// an easy way to test for singularity of the upper 3x3 component.
|
|
13750
|
+
if (!color) {
|
|
13751
|
+
error('Expected color definition');
|
|
13752
|
+
}
|
|
13750
13753
|
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
perspectiveMatrix[11] = 0;
|
|
13755
|
-
perspectiveMatrix[15] = 1; // If the perspectiveMatrix is not invertible, we are also unable to
|
|
13756
|
-
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
13754
|
+
color.length = matchDistance();
|
|
13755
|
+
return color;
|
|
13756
|
+
}
|
|
13757
13757
|
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
a23 = tmp[11],
|
|
13762
|
-
a30 = tmp[12],
|
|
13763
|
-
a31 = tmp[13],
|
|
13764
|
-
a32 = tmp[14],
|
|
13765
|
-
a33 = tmp[15]; // First, isolate perspective.
|
|
13758
|
+
function matchColor() {
|
|
13759
|
+
return matchHexColor() || matchRGBAColor() || matchRGBColor() || matchLiteralColor();
|
|
13760
|
+
}
|
|
13766
13761
|
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
tmpVec4[2] = a23;
|
|
13771
|
-
tmpVec4[3] = a33; // Solve the equation by inverting perspectiveMatrix and multiplying
|
|
13772
|
-
// rightHandSide by the inverse.
|
|
13773
|
-
// resuing the perspectiveMatrix here since it's no longer needed
|
|
13762
|
+
function matchLiteralColor() {
|
|
13763
|
+
return match('literal', tokens.literalColor, 0);
|
|
13764
|
+
}
|
|
13774
13765
|
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13766
|
+
function matchHexColor() {
|
|
13767
|
+
return match('hex', tokens.hexColor, 1);
|
|
13768
|
+
}
|
|
13778
13769
|
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13770
|
+
function matchRGBColor() {
|
|
13771
|
+
return matchCall(tokens.rgbColor, function () {
|
|
13772
|
+
return {
|
|
13773
|
+
type: 'rgb',
|
|
13774
|
+
value: matchListing(matchNumber)
|
|
13775
|
+
};
|
|
13776
|
+
});
|
|
13777
|
+
}
|
|
13785
13778
|
|
|
13779
|
+
function matchRGBAColor() {
|
|
13780
|
+
return matchCall(tokens.rgbaColor, function () {
|
|
13781
|
+
return {
|
|
13782
|
+
type: 'rgba',
|
|
13783
|
+
value: matchListing(matchNumber)
|
|
13784
|
+
};
|
|
13785
|
+
});
|
|
13786
|
+
}
|
|
13786
13787
|
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
|
|
13788
|
+
function matchNumber() {
|
|
13789
|
+
return scan(tokens.number)[1];
|
|
13790
|
+
}
|
|
13790
13791
|
|
|
13791
|
-
|
|
13792
|
+
function matchDistance() {
|
|
13793
|
+
return match('%', tokens.percentageValue, 1) || matchPositionKeyword() || matchLength();
|
|
13794
|
+
}
|
|
13792
13795
|
|
|
13793
|
-
|
|
13794
|
-
|
|
13796
|
+
function matchPositionKeyword() {
|
|
13797
|
+
return match('position-keyword', tokens.positionKeywords, 1);
|
|
13798
|
+
}
|
|
13795
13799
|
|
|
13796
|
-
|
|
13797
|
-
|
|
13800
|
+
function matchLength() {
|
|
13801
|
+
return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1);
|
|
13802
|
+
}
|
|
13798
13803
|
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
skew[0] /= scale[1]; // Compute XZ and YZ shears, orthogonalize 3rd row
|
|
13804
|
+
function match(type, pattern, captureIndex) {
|
|
13805
|
+
var captures = scan(pattern);
|
|
13802
13806
|
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
+
if (captures) {
|
|
13808
|
+
return {
|
|
13809
|
+
type: type,
|
|
13810
|
+
value: captures[captureIndex]
|
|
13811
|
+
};
|
|
13812
|
+
}
|
|
13813
|
+
}
|
|
13807
13814
|
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
skew[1] /= scale[2];
|
|
13811
|
-
skew[2] /= scale[2]; // At this point, the matrix (in rows) is orthonormal.
|
|
13812
|
-
// Check for a coordinate system flip. If the determinant
|
|
13813
|
-
// is -1, then negate the matrix and the scaling factors.
|
|
13815
|
+
function scan(regexp) {
|
|
13816
|
+
var blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
13814
13817
|
|
|
13815
|
-
|
|
13818
|
+
if (blankCaptures) {
|
|
13819
|
+
consume(blankCaptures[0].length);
|
|
13820
|
+
}
|
|
13816
13821
|
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
row[i][1] *= -1;
|
|
13822
|
-
row[i][2] *= -1;
|
|
13822
|
+
var captures = regexp.exec(input);
|
|
13823
|
+
|
|
13824
|
+
if (captures) {
|
|
13825
|
+
consume(captures[0].length);
|
|
13823
13826
|
}
|
|
13824
|
-
} // Now, get the rotations out
|
|
13825
13827
|
|
|
13828
|
+
return captures;
|
|
13829
|
+
}
|
|
13826
13830
|
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
quaternion[3] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
|
|
13831
|
-
if (row[2][1] > row[1][2]) quaternion[0] = -quaternion[0];
|
|
13832
|
-
if (row[0][2] > row[2][0]) quaternion[1] = -quaternion[1];
|
|
13833
|
-
if (row[1][0] > row[0][1]) quaternion[2] = -quaternion[2];
|
|
13834
|
-
return true;
|
|
13835
|
-
}
|
|
13831
|
+
function consume(size) {
|
|
13832
|
+
input = input.substring(size);
|
|
13833
|
+
}
|
|
13836
13834
|
|
|
13837
|
-
|
|
13838
|
-
|
|
13835
|
+
return function (code) {
|
|
13836
|
+
input = code;
|
|
13837
|
+
return getAST();
|
|
13838
|
+
};
|
|
13839
|
+
}();
|
|
13840
|
+
function computeLinearGradient(width, height, angle) {
|
|
13841
|
+
var rad = deg2rad(angle.value);
|
|
13842
|
+
var rx = 0;
|
|
13843
|
+
var ry = 0;
|
|
13844
|
+
var rcx = rx + width / 2;
|
|
13845
|
+
var rcy = ry + height / 2; // get the length of gradient line
|
|
13846
|
+
// @see https://observablehq.com/@danburzo/css-gradient-line
|
|
13839
13847
|
|
|
13840
|
-
|
|
13841
|
-
var
|
|
13848
|
+
var length = Math.abs(width * Math.cos(rad)) + Math.abs(height * Math.sin(rad));
|
|
13849
|
+
var x1 = rcx - Math.cos(rad) * length / 2;
|
|
13850
|
+
var y1 = rcy - Math.sin(rad) * length / 2;
|
|
13851
|
+
var x2 = rcx + Math.cos(rad) * length / 2;
|
|
13852
|
+
var y2 = rcy + Math.sin(rad) * length / 2;
|
|
13853
|
+
return {
|
|
13854
|
+
x1: x1,
|
|
13855
|
+
y1: y1,
|
|
13856
|
+
x2: x2,
|
|
13857
|
+
y2: y2
|
|
13858
|
+
};
|
|
13859
|
+
}
|
|
13860
|
+
function computeRadialGradient(width, height, cx, cy, size) {
|
|
13861
|
+
// 'px'
|
|
13862
|
+
var x = cx.value;
|
|
13863
|
+
var y = cy.value; // TODO: 'em'
|
|
13864
|
+
// '%'
|
|
13842
13865
|
|
|
13843
|
-
|
|
13844
|
-
|
|
13866
|
+
if (cx.unit === exports.UnitType.kPercentage) {
|
|
13867
|
+
x = cx.value / 100 * width;
|
|
13845
13868
|
}
|
|
13846
13869
|
|
|
13847
|
-
|
|
13848
|
-
|
|
13870
|
+
if (cy.unit === exports.UnitType.kPercentage) {
|
|
13871
|
+
y = cy.value / 100 * height;
|
|
13872
|
+
} // default to farthest-side
|
|
13849
13873
|
|
|
13850
13874
|
|
|
13851
|
-
|
|
13852
|
-
out[0][0] = mat4x4[0];
|
|
13853
|
-
out[0][1] = mat4x4[1];
|
|
13854
|
-
out[0][2] = mat4x4[2];
|
|
13855
|
-
out[1][0] = mat4x4[4];
|
|
13856
|
-
out[1][1] = mat4x4[5];
|
|
13857
|
-
out[1][2] = mat4x4[6];
|
|
13858
|
-
out[2][0] = mat4x4[8];
|
|
13859
|
-
out[2][1] = mat4x4[9];
|
|
13860
|
-
out[2][2] = mat4x4[10];
|
|
13861
|
-
}
|
|
13875
|
+
var r = Math.max(distanceSquareRoot([0, 0], [x, y]), distanceSquareRoot([0, height], [x, y]), distanceSquareRoot([width, height], [x, y]), distanceSquareRoot([width, 0], [x, y]));
|
|
13862
13876
|
|
|
13863
|
-
|
|
13864
|
-
|
|
13865
|
-
|
|
13866
|
-
|
|
13877
|
+
if (size) {
|
|
13878
|
+
if (size instanceof CSSUnitValue) {
|
|
13879
|
+
r = size.value;
|
|
13880
|
+
} else if (size instanceof CSSKeywordValue) {
|
|
13881
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Images/Using_CSS_gradients#example_closest-side_for_circles
|
|
13882
|
+
if (size.value === 'closest-side') {
|
|
13883
|
+
r = Math.min(x, width - x, y, height - y);
|
|
13884
|
+
} else if (size.value === 'farthest-side') {
|
|
13885
|
+
r = Math.max(x, width - x, y, height - y);
|
|
13886
|
+
} else if (size.value === 'closest-corner') {
|
|
13887
|
+
r = Math.min(distanceSquareRoot([0, 0], [x, y]), distanceSquareRoot([0, height], [x, y]), distanceSquareRoot([width, height], [x, y]), distanceSquareRoot([width, 0], [x, y]));
|
|
13888
|
+
}
|
|
13889
|
+
}
|
|
13890
|
+
}
|
|
13891
|
+
|
|
13892
|
+
return {
|
|
13893
|
+
x: x,
|
|
13894
|
+
y: y,
|
|
13895
|
+
r: r
|
|
13896
|
+
};
|
|
13867
13897
|
}
|
|
13868
13898
|
|
|
13869
13899
|
(function (Shape) {
|
|
@@ -15431,6 +15461,7 @@
|
|
|
15431
15461
|
for (var i = 1; i < length; i++) {
|
|
15432
15462
|
var _colorStops$i$length;
|
|
15433
15463
|
|
|
15464
|
+
// support '%' & 'px'
|
|
15434
15465
|
var offset = (_colorStops$i$length = colorStops[i].length) === null || _colorStops$i$length === void 0 ? void 0 : _colorStops$i$length.value;
|
|
15435
15466
|
|
|
15436
15467
|
if (!isNil(offset) && !isNil(previousOffset)) {
|
|
@@ -15472,11 +15503,13 @@
|
|
|
15472
15503
|
angle = SideOrCornerToDegMap[orientation.value] || 0;
|
|
15473
15504
|
}
|
|
15474
15505
|
|
|
15475
|
-
return angle;
|
|
15506
|
+
return getOrCreateUnitValue(angle, 'deg');
|
|
15476
15507
|
});
|
|
15477
|
-
var
|
|
15478
|
-
var cx =
|
|
15479
|
-
var cy =
|
|
15508
|
+
var positonToCSSUnitValue = memoize(function (position) {
|
|
15509
|
+
var cx = 50;
|
|
15510
|
+
var cy = 50;
|
|
15511
|
+
var unitX = '%';
|
|
15512
|
+
var unitY = '%';
|
|
15480
15513
|
|
|
15481
15514
|
if ((position === null || position === void 0 ? void 0 : position.type) === 'position') {
|
|
15482
15515
|
var _position$value = position.value,
|
|
@@ -15487,13 +15520,13 @@
|
|
|
15487
15520
|
if (x.value === 'left') {
|
|
15488
15521
|
cx = 0;
|
|
15489
15522
|
} else if (x.value === 'center') {
|
|
15490
|
-
cx =
|
|
15523
|
+
cx = 50;
|
|
15491
15524
|
} else if (x.value === 'right') {
|
|
15492
|
-
cx =
|
|
15525
|
+
cx = 100;
|
|
15493
15526
|
} else if (x.value === 'top') {
|
|
15494
15527
|
cy = 0;
|
|
15495
15528
|
} else if (x.value === 'bottom') {
|
|
15496
|
-
cy =
|
|
15529
|
+
cy = 100;
|
|
15497
15530
|
}
|
|
15498
15531
|
}
|
|
15499
15532
|
|
|
@@ -15501,28 +15534,30 @@
|
|
|
15501
15534
|
if (y.value === 'left') {
|
|
15502
15535
|
cx = 0;
|
|
15503
15536
|
} else if (y.value === 'center') {
|
|
15504
|
-
cy =
|
|
15537
|
+
cy = 50;
|
|
15505
15538
|
} else if (y.value === 'right') {
|
|
15506
|
-
cx =
|
|
15539
|
+
cx = 100;
|
|
15507
15540
|
} else if (y.value === 'top') {
|
|
15508
15541
|
cy = 0;
|
|
15509
15542
|
} else if (y.value === 'bottom') {
|
|
15510
|
-
cy =
|
|
15543
|
+
cy = 100;
|
|
15511
15544
|
}
|
|
15512
15545
|
}
|
|
15513
15546
|
|
|
15514
|
-
if ((x === null || x === void 0 ? void 0 : x.type) === '%') {
|
|
15515
|
-
|
|
15547
|
+
if ((x === null || x === void 0 ? void 0 : x.type) === 'px' || (x === null || x === void 0 ? void 0 : x.type) === '%' || (x === null || x === void 0 ? void 0 : x.type) === 'em') {
|
|
15548
|
+
unitX = x === null || x === void 0 ? void 0 : x.type;
|
|
15549
|
+
cx = Number(x.value);
|
|
15516
15550
|
}
|
|
15517
15551
|
|
|
15518
|
-
if ((y === null || y === void 0 ? void 0 : y.type) === '%') {
|
|
15519
|
-
|
|
15552
|
+
if ((y === null || y === void 0 ? void 0 : y.type) === 'px' || (y === null || y === void 0 ? void 0 : y.type) === '%' || (y === null || y === void 0 ? void 0 : y.type) === 'em') {
|
|
15553
|
+
unitY = y === null || y === void 0 ? void 0 : y.type;
|
|
15554
|
+
cy = Number(y.value);
|
|
15520
15555
|
}
|
|
15521
15556
|
}
|
|
15522
15557
|
|
|
15523
15558
|
return {
|
|
15524
|
-
cx: cx,
|
|
15525
|
-
cy: cy
|
|
15559
|
+
cx: getOrCreateUnitValue(cx, unitX),
|
|
15560
|
+
cy: getOrCreateUnitValue(cy, unitY)
|
|
15526
15561
|
};
|
|
15527
15562
|
});
|
|
15528
15563
|
var parseGradient$1 = memoize(function (colorStr) {
|
|
@@ -15535,14 +15570,16 @@
|
|
|
15535
15570
|
spaceColorStops(colorStops);
|
|
15536
15571
|
var steps = colorStops.map(function (colorStop) {
|
|
15537
15572
|
// TODO: only support % for now, should calc percentage of axis length when using px/em
|
|
15538
|
-
return
|
|
15573
|
+
return {
|
|
15574
|
+
offset: getOrCreateUnitValue(colorStop.length.value, '%'),
|
|
15575
|
+
color: colorStopToString(colorStop)
|
|
15576
|
+
};
|
|
15539
15577
|
});
|
|
15540
15578
|
|
|
15541
15579
|
if (type === 'linear-gradient') {
|
|
15542
15580
|
return new CSSGradientValue(exports.GradientType.LinearGradient, {
|
|
15543
|
-
angle: orientation ? angleToDeg(orientation) :
|
|
15544
|
-
steps: steps
|
|
15545
|
-
hash: colorStr
|
|
15581
|
+
angle: orientation ? angleToDeg(orientation) : Odeg,
|
|
15582
|
+
steps: steps
|
|
15546
15583
|
});
|
|
15547
15584
|
} else if (type === 'radial-gradient') {
|
|
15548
15585
|
if (!orientation) {
|
|
@@ -15553,17 +15590,33 @@
|
|
|
15553
15590
|
}
|
|
15554
15591
|
|
|
15555
15592
|
if (orientation[0].type === 'shape' && orientation[0].value === 'circle') {
|
|
15556
|
-
var
|
|
15557
|
-
cx =
|
|
15558
|
-
cy =
|
|
15593
|
+
var _positonToCSSUnitValu = positonToCSSUnitValue(orientation[0].at),
|
|
15594
|
+
cx = _positonToCSSUnitValu.cx,
|
|
15595
|
+
cy = _positonToCSSUnitValu.cy;
|
|
15596
|
+
|
|
15597
|
+
var size;
|
|
15598
|
+
|
|
15599
|
+
if (orientation[0].style) {
|
|
15600
|
+
var _orientation$0$style = orientation[0].style,
|
|
15601
|
+
_type = _orientation$0$style.type,
|
|
15602
|
+
value = _orientation$0$style.value;
|
|
15603
|
+
|
|
15604
|
+
if (_type === 'extent-keyword') {
|
|
15605
|
+
size = getOrCreateKeyword(value);
|
|
15606
|
+
} else {
|
|
15607
|
+
size = getOrCreateUnitValue(value, _type);
|
|
15608
|
+
}
|
|
15609
|
+
}
|
|
15559
15610
|
|
|
15560
15611
|
return new CSSGradientValue(exports.GradientType.RadialGradient, {
|
|
15561
15612
|
cx: cx,
|
|
15562
15613
|
cy: cy,
|
|
15563
|
-
|
|
15564
|
-
|
|
15614
|
+
size: size,
|
|
15615
|
+
steps: steps
|
|
15565
15616
|
});
|
|
15566
|
-
} //
|
|
15617
|
+
} // TODO: support ellipse shape
|
|
15618
|
+
// TODO: repeating-linear-gradient & repeating-radial-gradient
|
|
15619
|
+
// } else if (type === 'repeating-linear-gradient') {
|
|
15567
15620
|
// } else if (type === 'repeating-radial-gradient') {
|
|
15568
15621
|
|
|
15569
15622
|
}
|
|
@@ -15584,13 +15637,15 @@
|
|
|
15584
15637
|
return stop.split(':');
|
|
15585
15638
|
})) || [];
|
|
15586
15639
|
return [new CSSGradientValue(exports.GradientType.LinearGradient, {
|
|
15587
|
-
angle: parseFloat(arr[1]),
|
|
15640
|
+
angle: getOrCreateUnitValue(parseFloat(arr[1]), 'deg'),
|
|
15588
15641
|
steps: steps.map(function (_ref2) {
|
|
15589
15642
|
var offset = _ref2[0],
|
|
15590
15643
|
color = _ref2[1];
|
|
15591
|
-
return
|
|
15592
|
-
|
|
15593
|
-
|
|
15644
|
+
return {
|
|
15645
|
+
offset: getOrCreateUnitValue(Number(offset) * 100, '%'),
|
|
15646
|
+
color: color
|
|
15647
|
+
};
|
|
15648
|
+
})
|
|
15594
15649
|
})];
|
|
15595
15650
|
}
|
|
15596
15651
|
} else if (type === 'r') {
|
|
@@ -15619,14 +15674,16 @@
|
|
|
15619
15674
|
return stop.split(':');
|
|
15620
15675
|
})) || [];
|
|
15621
15676
|
return {
|
|
15622
|
-
cx:
|
|
15623
|
-
cy:
|
|
15677
|
+
cx: getOrCreateUnitValue(50, '%'),
|
|
15678
|
+
cy: getOrCreateUnitValue(50, '%'),
|
|
15624
15679
|
steps: steps.map(function (_ref3) {
|
|
15625
15680
|
var offset = _ref3[0],
|
|
15626
15681
|
color = _ref3[1];
|
|
15627
|
-
return
|
|
15628
|
-
|
|
15629
|
-
|
|
15682
|
+
return {
|
|
15683
|
+
offset: getOrCreateUnitValue(Number(offset) * 100, '%'),
|
|
15684
|
+
color: color
|
|
15685
|
+
};
|
|
15686
|
+
})
|
|
15630
15687
|
};
|
|
15631
15688
|
}
|
|
15632
15689
|
|
|
@@ -19935,7 +19992,10 @@
|
|
|
19935
19992
|
MutationEvent.MODIFICATION = 1;
|
|
19936
19993
|
MutationEvent.REMOVAL = 3;
|
|
19937
19994
|
|
|
19938
|
-
var entityCounter = 0;
|
|
19995
|
+
var entityCounter = 0;
|
|
19996
|
+
function resetEntityCounter() {
|
|
19997
|
+
entityCounter = 0;
|
|
19998
|
+
} // let this.sceneGraphService: SceneGraphService;
|
|
19939
19999
|
|
|
19940
20000
|
var childInsertedEvent = new CustomEvent(exports.ElementEvent.CHILD_INSERTED, {
|
|
19941
20001
|
child: null
|
|
@@ -28317,6 +28377,35 @@
|
|
|
28317
28377
|
renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
|
|
28318
28378
|
};
|
|
28319
28379
|
|
|
28380
|
+
_proto.getViewportXY = function getViewportXY(nativeEvent) {
|
|
28381
|
+
var x;
|
|
28382
|
+
var y;
|
|
28383
|
+
/**
|
|
28384
|
+
* Should account for CSS Transform applied on container.
|
|
28385
|
+
* @see https://github.com/antvis/G/issues/1161
|
|
28386
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/offsetX
|
|
28387
|
+
*/
|
|
28388
|
+
|
|
28389
|
+
var offsetX = nativeEvent.offsetX,
|
|
28390
|
+
offsetY = nativeEvent.offsetY,
|
|
28391
|
+
clientX = nativeEvent.clientX,
|
|
28392
|
+
clientY = nativeEvent.clientY;
|
|
28393
|
+
|
|
28394
|
+
if (this.canvasConfig.supportsCSSTransform && !isNil(offsetX) && !isNil(offsetY)) {
|
|
28395
|
+
x = offsetX;
|
|
28396
|
+
y = offsetY;
|
|
28397
|
+
} else {
|
|
28398
|
+
var point = this.eventService.client2Viewport(new Point(clientX, clientY));
|
|
28399
|
+
x = point.x;
|
|
28400
|
+
y = point.y;
|
|
28401
|
+
}
|
|
28402
|
+
|
|
28403
|
+
return {
|
|
28404
|
+
x: x,
|
|
28405
|
+
y: y
|
|
28406
|
+
};
|
|
28407
|
+
};
|
|
28408
|
+
|
|
28320
28409
|
_proto.bootstrapEvent = function bootstrapEvent(event, nativeEvent, view) {
|
|
28321
28410
|
event.view = view;
|
|
28322
28411
|
event.originalEvent = null;
|
|
@@ -28333,9 +28422,9 @@
|
|
|
28333
28422
|
event.twist = nativeEvent.twist;
|
|
28334
28423
|
this.transferMouseData(event, nativeEvent);
|
|
28335
28424
|
|
|
28336
|
-
var _this$
|
|
28337
|
-
x = _this$
|
|
28338
|
-
y = _this$
|
|
28425
|
+
var _this$getViewportXY = this.getViewportXY(nativeEvent),
|
|
28426
|
+
x = _this$getViewportXY.x,
|
|
28427
|
+
y = _this$getViewportXY.y;
|
|
28339
28428
|
|
|
28340
28429
|
event.viewport.x = x;
|
|
28341
28430
|
event.viewport.y = y;
|
|
@@ -28373,9 +28462,9 @@
|
|
|
28373
28462
|
event.deltaY = nativeEvent.deltaY;
|
|
28374
28463
|
event.deltaZ = nativeEvent.deltaZ;
|
|
28375
28464
|
|
|
28376
|
-
var _this$
|
|
28377
|
-
x = _this$
|
|
28378
|
-
y = _this$
|
|
28465
|
+
var _this$getViewportXY2 = this.getViewportXY(nativeEvent),
|
|
28466
|
+
x = _this$getViewportXY2.x,
|
|
28467
|
+
y = _this$getViewportXY2.y;
|
|
28379
28468
|
|
|
28380
28469
|
event.viewport.x = x;
|
|
28381
28470
|
event.viewport.y = y;
|
|
@@ -28915,6 +29004,7 @@
|
|
|
28915
29004
|
createImage = config.createImage,
|
|
28916
29005
|
supportsPointerEvents = config.supportsPointerEvents,
|
|
28917
29006
|
supportsTouchEvents = config.supportsTouchEvents,
|
|
29007
|
+
supportsCSSTransform = config.supportsCSSTransform,
|
|
28918
29008
|
isTouchEvent = config.isTouchEvent,
|
|
28919
29009
|
isMouseEvent = config.isMouseEvent;
|
|
28920
29010
|
cleanExistedCanvas(container, _assertThisInitialized(_this));
|
|
@@ -28963,7 +29053,8 @@
|
|
|
28963
29053
|
cursor: cursor || 'default',
|
|
28964
29054
|
background: background || 'transparent',
|
|
28965
29055
|
createImage: createImage,
|
|
28966
|
-
document: document
|
|
29056
|
+
document: document,
|
|
29057
|
+
supportsCSSTransform: supportsCSSTransform
|
|
28967
29058
|
});
|
|
28968
29059
|
|
|
28969
29060
|
_this.initDefaultCamera(canvasWidth, canvasHeight);
|
|
@@ -29549,6 +29640,7 @@
|
|
|
29549
29640
|
exports.parsePath = parsePath;
|
|
29550
29641
|
exports.propertyMetadataCache = propertyMetadataCache;
|
|
29551
29642
|
exports.rad2deg = rad2deg;
|
|
29643
|
+
exports.resetEntityCounter = resetEntityCounter;
|
|
29552
29644
|
exports.setDOMSize = setDOMSize;
|
|
29553
29645
|
exports.singleton = singleton;
|
|
29554
29646
|
exports.styleValueRegistry = styleValueRegistry;
|