逐步完成前后端服务器
This commit is contained in:
23
frontend/node_modules/zrender/lib/tool/color.d.ts
generated
vendored
Normal file
23
frontend/node_modules/zrender/lib/tool/color.d.ts
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import { GradientObject } from '../graphic/Gradient';
|
||||
export declare function parse(colorStr: string, rgbaArr?: number[]): number[];
|
||||
export declare function lift(color: string, level: number): string;
|
||||
export declare function toHex(color: string): string;
|
||||
export declare function fastLerp(normalizedValue: number, colors: number[][], out?: number[]): number[];
|
||||
export declare const fastMapToColor: typeof fastLerp;
|
||||
declare type LerpFullOutput = {
|
||||
color: string;
|
||||
leftIndex: number;
|
||||
rightIndex: number;
|
||||
value: number;
|
||||
};
|
||||
export declare function lerp(normalizedValue: number, colors: string[], fullOutput: boolean): LerpFullOutput;
|
||||
export declare function lerp(normalizedValue: number, colors: string[]): string;
|
||||
export declare const mapToColor: typeof lerp;
|
||||
export declare function modifyHSL(color: string, h?: number, s?: number, l?: number): string;
|
||||
export declare function modifyAlpha(color: string, alpha?: number): string;
|
||||
export declare function stringify(arrColor: number[], type: string): string;
|
||||
export declare function lum(color: string, backgroundLum: number): number;
|
||||
export declare function random(): string;
|
||||
export declare function liftColor(color: GradientObject): GradientObject;
|
||||
export declare function liftColor(color: string): string;
|
||||
export {};
|
429
frontend/node_modules/zrender/lib/tool/color.js
generated
vendored
Normal file
429
frontend/node_modules/zrender/lib/tool/color.js
generated
vendored
Normal file
@ -0,0 +1,429 @@
|
||||
import LRU from '../core/LRU.js';
|
||||
import { extend, isGradientObject, isString, map } from '../core/util.js';
|
||||
var kCSSColorTable = {
|
||||
'transparent': [0, 0, 0, 0], 'aliceblue': [240, 248, 255, 1],
|
||||
'antiquewhite': [250, 235, 215, 1], 'aqua': [0, 255, 255, 1],
|
||||
'aquamarine': [127, 255, 212, 1], 'azure': [240, 255, 255, 1],
|
||||
'beige': [245, 245, 220, 1], 'bisque': [255, 228, 196, 1],
|
||||
'black': [0, 0, 0, 1], 'blanchedalmond': [255, 235, 205, 1],
|
||||
'blue': [0, 0, 255, 1], 'blueviolet': [138, 43, 226, 1],
|
||||
'brown': [165, 42, 42, 1], 'burlywood': [222, 184, 135, 1],
|
||||
'cadetblue': [95, 158, 160, 1], 'chartreuse': [127, 255, 0, 1],
|
||||
'chocolate': [210, 105, 30, 1], 'coral': [255, 127, 80, 1],
|
||||
'cornflowerblue': [100, 149, 237, 1], 'cornsilk': [255, 248, 220, 1],
|
||||
'crimson': [220, 20, 60, 1], 'cyan': [0, 255, 255, 1],
|
||||
'darkblue': [0, 0, 139, 1], 'darkcyan': [0, 139, 139, 1],
|
||||
'darkgoldenrod': [184, 134, 11, 1], 'darkgray': [169, 169, 169, 1],
|
||||
'darkgreen': [0, 100, 0, 1], 'darkgrey': [169, 169, 169, 1],
|
||||
'darkkhaki': [189, 183, 107, 1], 'darkmagenta': [139, 0, 139, 1],
|
||||
'darkolivegreen': [85, 107, 47, 1], 'darkorange': [255, 140, 0, 1],
|
||||
'darkorchid': [153, 50, 204, 1], 'darkred': [139, 0, 0, 1],
|
||||
'darksalmon': [233, 150, 122, 1], 'darkseagreen': [143, 188, 143, 1],
|
||||
'darkslateblue': [72, 61, 139, 1], 'darkslategray': [47, 79, 79, 1],
|
||||
'darkslategrey': [47, 79, 79, 1], 'darkturquoise': [0, 206, 209, 1],
|
||||
'darkviolet': [148, 0, 211, 1], 'deeppink': [255, 20, 147, 1],
|
||||
'deepskyblue': [0, 191, 255, 1], 'dimgray': [105, 105, 105, 1],
|
||||
'dimgrey': [105, 105, 105, 1], 'dodgerblue': [30, 144, 255, 1],
|
||||
'firebrick': [178, 34, 34, 1], 'floralwhite': [255, 250, 240, 1],
|
||||
'forestgreen': [34, 139, 34, 1], 'fuchsia': [255, 0, 255, 1],
|
||||
'gainsboro': [220, 220, 220, 1], 'ghostwhite': [248, 248, 255, 1],
|
||||
'gold': [255, 215, 0, 1], 'goldenrod': [218, 165, 32, 1],
|
||||
'gray': [128, 128, 128, 1], 'green': [0, 128, 0, 1],
|
||||
'greenyellow': [173, 255, 47, 1], 'grey': [128, 128, 128, 1],
|
||||
'honeydew': [240, 255, 240, 1], 'hotpink': [255, 105, 180, 1],
|
||||
'indianred': [205, 92, 92, 1], 'indigo': [75, 0, 130, 1],
|
||||
'ivory': [255, 255, 240, 1], 'khaki': [240, 230, 140, 1],
|
||||
'lavender': [230, 230, 250, 1], 'lavenderblush': [255, 240, 245, 1],
|
||||
'lawngreen': [124, 252, 0, 1], 'lemonchiffon': [255, 250, 205, 1],
|
||||
'lightblue': [173, 216, 230, 1], 'lightcoral': [240, 128, 128, 1],
|
||||
'lightcyan': [224, 255, 255, 1], 'lightgoldenrodyellow': [250, 250, 210, 1],
|
||||
'lightgray': [211, 211, 211, 1], 'lightgreen': [144, 238, 144, 1],
|
||||
'lightgrey': [211, 211, 211, 1], 'lightpink': [255, 182, 193, 1],
|
||||
'lightsalmon': [255, 160, 122, 1], 'lightseagreen': [32, 178, 170, 1],
|
||||
'lightskyblue': [135, 206, 250, 1], 'lightslategray': [119, 136, 153, 1],
|
||||
'lightslategrey': [119, 136, 153, 1], 'lightsteelblue': [176, 196, 222, 1],
|
||||
'lightyellow': [255, 255, 224, 1], 'lime': [0, 255, 0, 1],
|
||||
'limegreen': [50, 205, 50, 1], 'linen': [250, 240, 230, 1],
|
||||
'magenta': [255, 0, 255, 1], 'maroon': [128, 0, 0, 1],
|
||||
'mediumaquamarine': [102, 205, 170, 1], 'mediumblue': [0, 0, 205, 1],
|
||||
'mediumorchid': [186, 85, 211, 1], 'mediumpurple': [147, 112, 219, 1],
|
||||
'mediumseagreen': [60, 179, 113, 1], 'mediumslateblue': [123, 104, 238, 1],
|
||||
'mediumspringgreen': [0, 250, 154, 1], 'mediumturquoise': [72, 209, 204, 1],
|
||||
'mediumvioletred': [199, 21, 133, 1], 'midnightblue': [25, 25, 112, 1],
|
||||
'mintcream': [245, 255, 250, 1], 'mistyrose': [255, 228, 225, 1],
|
||||
'moccasin': [255, 228, 181, 1], 'navajowhite': [255, 222, 173, 1],
|
||||
'navy': [0, 0, 128, 1], 'oldlace': [253, 245, 230, 1],
|
||||
'olive': [128, 128, 0, 1], 'olivedrab': [107, 142, 35, 1],
|
||||
'orange': [255, 165, 0, 1], 'orangered': [255, 69, 0, 1],
|
||||
'orchid': [218, 112, 214, 1], 'palegoldenrod': [238, 232, 170, 1],
|
||||
'palegreen': [152, 251, 152, 1], 'paleturquoise': [175, 238, 238, 1],
|
||||
'palevioletred': [219, 112, 147, 1], 'papayawhip': [255, 239, 213, 1],
|
||||
'peachpuff': [255, 218, 185, 1], 'peru': [205, 133, 63, 1],
|
||||
'pink': [255, 192, 203, 1], 'plum': [221, 160, 221, 1],
|
||||
'powderblue': [176, 224, 230, 1], 'purple': [128, 0, 128, 1],
|
||||
'red': [255, 0, 0, 1], 'rosybrown': [188, 143, 143, 1],
|
||||
'royalblue': [65, 105, 225, 1], 'saddlebrown': [139, 69, 19, 1],
|
||||
'salmon': [250, 128, 114, 1], 'sandybrown': [244, 164, 96, 1],
|
||||
'seagreen': [46, 139, 87, 1], 'seashell': [255, 245, 238, 1],
|
||||
'sienna': [160, 82, 45, 1], 'silver': [192, 192, 192, 1],
|
||||
'skyblue': [135, 206, 235, 1], 'slateblue': [106, 90, 205, 1],
|
||||
'slategray': [112, 128, 144, 1], 'slategrey': [112, 128, 144, 1],
|
||||
'snow': [255, 250, 250, 1], 'springgreen': [0, 255, 127, 1],
|
||||
'steelblue': [70, 130, 180, 1], 'tan': [210, 180, 140, 1],
|
||||
'teal': [0, 128, 128, 1], 'thistle': [216, 191, 216, 1],
|
||||
'tomato': [255, 99, 71, 1], 'turquoise': [64, 224, 208, 1],
|
||||
'violet': [238, 130, 238, 1], 'wheat': [245, 222, 179, 1],
|
||||
'white': [255, 255, 255, 1], 'whitesmoke': [245, 245, 245, 1],
|
||||
'yellow': [255, 255, 0, 1], 'yellowgreen': [154, 205, 50, 1]
|
||||
};
|
||||
function clampCssByte(i) {
|
||||
i = Math.round(i);
|
||||
return i < 0 ? 0 : i > 255 ? 255 : i;
|
||||
}
|
||||
function clampCssAngle(i) {
|
||||
i = Math.round(i);
|
||||
return i < 0 ? 0 : i > 360 ? 360 : i;
|
||||
}
|
||||
function clampCssFloat(f) {
|
||||
return f < 0 ? 0 : f > 1 ? 1 : f;
|
||||
}
|
||||
function parseCssInt(val) {
|
||||
var str = val;
|
||||
if (str.length && str.charAt(str.length - 1) === '%') {
|
||||
return clampCssByte(parseFloat(str) / 100 * 255);
|
||||
}
|
||||
return clampCssByte(parseInt(str, 10));
|
||||
}
|
||||
function parseCssFloat(val) {
|
||||
var str = val;
|
||||
if (str.length && str.charAt(str.length - 1) === '%') {
|
||||
return clampCssFloat(parseFloat(str) / 100);
|
||||
}
|
||||
return clampCssFloat(parseFloat(str));
|
||||
}
|
||||
function cssHueToRgb(m1, m2, h) {
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
}
|
||||
else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
if (h * 6 < 1) {
|
||||
return m1 + (m2 - m1) * h * 6;
|
||||
}
|
||||
if (h * 2 < 1) {
|
||||
return m2;
|
||||
}
|
||||
if (h * 3 < 2) {
|
||||
return m1 + (m2 - m1) * (2 / 3 - h) * 6;
|
||||
}
|
||||
return m1;
|
||||
}
|
||||
function lerpNumber(a, b, p) {
|
||||
return a + (b - a) * p;
|
||||
}
|
||||
function setRgba(out, r, g, b, a) {
|
||||
out[0] = r;
|
||||
out[1] = g;
|
||||
out[2] = b;
|
||||
out[3] = a;
|
||||
return out;
|
||||
}
|
||||
function copyRgba(out, a) {
|
||||
out[0] = a[0];
|
||||
out[1] = a[1];
|
||||
out[2] = a[2];
|
||||
out[3] = a[3];
|
||||
return out;
|
||||
}
|
||||
var colorCache = new LRU(20);
|
||||
var lastRemovedArr = null;
|
||||
function putToCache(colorStr, rgbaArr) {
|
||||
if (lastRemovedArr) {
|
||||
copyRgba(lastRemovedArr, rgbaArr);
|
||||
}
|
||||
lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || (rgbaArr.slice()));
|
||||
}
|
||||
export function parse(colorStr, rgbaArr) {
|
||||
if (!colorStr) {
|
||||
return;
|
||||
}
|
||||
rgbaArr = rgbaArr || [];
|
||||
var cached = colorCache.get(colorStr);
|
||||
if (cached) {
|
||||
return copyRgba(rgbaArr, cached);
|
||||
}
|
||||
colorStr = colorStr + '';
|
||||
var str = colorStr.replace(/ /g, '').toLowerCase();
|
||||
if (str in kCSSColorTable) {
|
||||
copyRgba(rgbaArr, kCSSColorTable[str]);
|
||||
putToCache(colorStr, rgbaArr);
|
||||
return rgbaArr;
|
||||
}
|
||||
var strLen = str.length;
|
||||
if (str.charAt(0) === '#') {
|
||||
if (strLen === 4 || strLen === 5) {
|
||||
var iv = parseInt(str.slice(1, 4), 16);
|
||||
if (!(iv >= 0 && iv <= 0xfff)) {
|
||||
setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
return;
|
||||
}
|
||||
setRgba(rgbaArr, ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), (iv & 0xf0) | ((iv & 0xf0) >> 4), (iv & 0xf) | ((iv & 0xf) << 4), strLen === 5 ? parseInt(str.slice(4), 16) / 0xf : 1);
|
||||
putToCache(colorStr, rgbaArr);
|
||||
return rgbaArr;
|
||||
}
|
||||
else if (strLen === 7 || strLen === 9) {
|
||||
var iv = parseInt(str.slice(1, 7), 16);
|
||||
if (!(iv >= 0 && iv <= 0xffffff)) {
|
||||
setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
return;
|
||||
}
|
||||
setRgba(rgbaArr, (iv & 0xff0000) >> 16, (iv & 0xff00) >> 8, iv & 0xff, strLen === 9 ? parseInt(str.slice(7), 16) / 0xff : 1);
|
||||
putToCache(colorStr, rgbaArr);
|
||||
return rgbaArr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var op = str.indexOf('(');
|
||||
var ep = str.indexOf(')');
|
||||
if (op !== -1 && ep + 1 === strLen) {
|
||||
var fname = str.substr(0, op);
|
||||
var params = str.substr(op + 1, ep - (op + 1)).split(',');
|
||||
var alpha = 1;
|
||||
switch (fname) {
|
||||
case 'rgba':
|
||||
if (params.length !== 4) {
|
||||
return params.length === 3
|
||||
? setRgba(rgbaArr, +params[0], +params[1], +params[2], 1)
|
||||
: setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
}
|
||||
alpha = parseCssFloat(params.pop());
|
||||
case 'rgb':
|
||||
if (params.length >= 3) {
|
||||
setRgba(rgbaArr, parseCssInt(params[0]), parseCssInt(params[1]), parseCssInt(params[2]), params.length === 3 ? alpha : parseCssFloat(params[3]));
|
||||
putToCache(colorStr, rgbaArr);
|
||||
return rgbaArr;
|
||||
}
|
||||
else {
|
||||
setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
return;
|
||||
}
|
||||
case 'hsla':
|
||||
if (params.length !== 4) {
|
||||
setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
return;
|
||||
}
|
||||
params[3] = parseCssFloat(params[3]);
|
||||
hsla2rgba(params, rgbaArr);
|
||||
putToCache(colorStr, rgbaArr);
|
||||
return rgbaArr;
|
||||
case 'hsl':
|
||||
if (params.length !== 3) {
|
||||
setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
return;
|
||||
}
|
||||
hsla2rgba(params, rgbaArr);
|
||||
putToCache(colorStr, rgbaArr);
|
||||
return rgbaArr;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
setRgba(rgbaArr, 0, 0, 0, 1);
|
||||
return;
|
||||
}
|
||||
function hsla2rgba(hsla, rgba) {
|
||||
var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360;
|
||||
var s = parseCssFloat(hsla[1]);
|
||||
var l = parseCssFloat(hsla[2]);
|
||||
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
||||
var m1 = l * 2 - m2;
|
||||
rgba = rgba || [];
|
||||
setRgba(rgba, clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), clampCssByte(cssHueToRgb(m1, m2, h) * 255), clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255), 1);
|
||||
if (hsla.length === 4) {
|
||||
rgba[3] = hsla[3];
|
||||
}
|
||||
return rgba;
|
||||
}
|
||||
function rgba2hsla(rgba) {
|
||||
if (!rgba) {
|
||||
return;
|
||||
}
|
||||
var R = rgba[0] / 255;
|
||||
var G = rgba[1] / 255;
|
||||
var B = rgba[2] / 255;
|
||||
var vMin = Math.min(R, G, B);
|
||||
var vMax = Math.max(R, G, B);
|
||||
var delta = vMax - vMin;
|
||||
var L = (vMax + vMin) / 2;
|
||||
var H;
|
||||
var S;
|
||||
if (delta === 0) {
|
||||
H = 0;
|
||||
S = 0;
|
||||
}
|
||||
else {
|
||||
if (L < 0.5) {
|
||||
S = delta / (vMax + vMin);
|
||||
}
|
||||
else {
|
||||
S = delta / (2 - vMax - vMin);
|
||||
}
|
||||
var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
|
||||
var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
|
||||
var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
|
||||
if (R === vMax) {
|
||||
H = deltaB - deltaG;
|
||||
}
|
||||
else if (G === vMax) {
|
||||
H = (1 / 3) + deltaR - deltaB;
|
||||
}
|
||||
else if (B === vMax) {
|
||||
H = (2 / 3) + deltaG - deltaR;
|
||||
}
|
||||
if (H < 0) {
|
||||
H += 1;
|
||||
}
|
||||
if (H > 1) {
|
||||
H -= 1;
|
||||
}
|
||||
}
|
||||
var hsla = [H * 360, S, L];
|
||||
if (rgba[3] != null) {
|
||||
hsla.push(rgba[3]);
|
||||
}
|
||||
return hsla;
|
||||
}
|
||||
export function lift(color, level) {
|
||||
var colorArr = parse(color);
|
||||
if (colorArr) {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
if (level < 0) {
|
||||
colorArr[i] = colorArr[i] * (1 - level) | 0;
|
||||
}
|
||||
else {
|
||||
colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
|
||||
}
|
||||
if (colorArr[i] > 255) {
|
||||
colorArr[i] = 255;
|
||||
}
|
||||
else if (colorArr[i] < 0) {
|
||||
colorArr[i] = 0;
|
||||
}
|
||||
}
|
||||
return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
|
||||
}
|
||||
}
|
||||
export function toHex(color) {
|
||||
var colorArr = parse(color);
|
||||
if (colorArr) {
|
||||
return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
|
||||
}
|
||||
}
|
||||
export function fastLerp(normalizedValue, colors, out) {
|
||||
if (!(colors && colors.length)
|
||||
|| !(normalizedValue >= 0 && normalizedValue <= 1)) {
|
||||
return;
|
||||
}
|
||||
out = out || [];
|
||||
var value = normalizedValue * (colors.length - 1);
|
||||
var leftIndex = Math.floor(value);
|
||||
var rightIndex = Math.ceil(value);
|
||||
var leftColor = colors[leftIndex];
|
||||
var rightColor = colors[rightIndex];
|
||||
var dv = value - leftIndex;
|
||||
out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
|
||||
out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
|
||||
out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
|
||||
out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
|
||||
return out;
|
||||
}
|
||||
export var fastMapToColor = fastLerp;
|
||||
export function lerp(normalizedValue, colors, fullOutput) {
|
||||
if (!(colors && colors.length)
|
||||
|| !(normalizedValue >= 0 && normalizedValue <= 1)) {
|
||||
return;
|
||||
}
|
||||
var value = normalizedValue * (colors.length - 1);
|
||||
var leftIndex = Math.floor(value);
|
||||
var rightIndex = Math.ceil(value);
|
||||
var leftColor = parse(colors[leftIndex]);
|
||||
var rightColor = parse(colors[rightIndex]);
|
||||
var dv = value - leftIndex;
|
||||
var color = stringify([
|
||||
clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)),
|
||||
clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)),
|
||||
clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)),
|
||||
clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))
|
||||
], 'rgba');
|
||||
return fullOutput
|
||||
? {
|
||||
color: color,
|
||||
leftIndex: leftIndex,
|
||||
rightIndex: rightIndex,
|
||||
value: value
|
||||
}
|
||||
: color;
|
||||
}
|
||||
export var mapToColor = lerp;
|
||||
export function modifyHSL(color, h, s, l) {
|
||||
var colorArr = parse(color);
|
||||
if (color) {
|
||||
colorArr = rgba2hsla(colorArr);
|
||||
h != null && (colorArr[0] = clampCssAngle(h));
|
||||
s != null && (colorArr[1] = parseCssFloat(s));
|
||||
l != null && (colorArr[2] = parseCssFloat(l));
|
||||
return stringify(hsla2rgba(colorArr), 'rgba');
|
||||
}
|
||||
}
|
||||
export function modifyAlpha(color, alpha) {
|
||||
var colorArr = parse(color);
|
||||
if (colorArr && alpha != null) {
|
||||
colorArr[3] = clampCssFloat(alpha);
|
||||
return stringify(colorArr, 'rgba');
|
||||
}
|
||||
}
|
||||
export function stringify(arrColor, type) {
|
||||
if (!arrColor || !arrColor.length) {
|
||||
return;
|
||||
}
|
||||
var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
|
||||
if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
|
||||
colorStr += ',' + arrColor[3];
|
||||
}
|
||||
return type + '(' + colorStr + ')';
|
||||
}
|
||||
export function lum(color, backgroundLum) {
|
||||
var arr = parse(color);
|
||||
return arr
|
||||
? (0.299 * arr[0] + 0.587 * arr[1] + 0.114 * arr[2]) * arr[3] / 255
|
||||
+ (1 - arr[3]) * backgroundLum
|
||||
: 0;
|
||||
}
|
||||
export function random() {
|
||||
return stringify([
|
||||
Math.round(Math.random() * 255),
|
||||
Math.round(Math.random() * 255),
|
||||
Math.round(Math.random() * 255)
|
||||
], 'rgb');
|
||||
}
|
||||
var liftedColorCache = new LRU(100);
|
||||
export function liftColor(color) {
|
||||
if (isString(color)) {
|
||||
var liftedColor = liftedColorCache.get(color);
|
||||
if (!liftedColor) {
|
||||
liftedColor = lift(color, -0.1);
|
||||
liftedColorCache.put(color, liftedColor);
|
||||
}
|
||||
return liftedColor;
|
||||
}
|
||||
else if (isGradientObject(color)) {
|
||||
var ret = extend({}, color);
|
||||
ret.colorStops = map(color.colorStops, function (stop) { return ({
|
||||
offset: stop.offset,
|
||||
color: lift(stop.color, -0.1)
|
||||
}); });
|
||||
return ret;
|
||||
}
|
||||
return color;
|
||||
}
|
3
frontend/node_modules/zrender/lib/tool/convertPath.d.ts
generated
vendored
Normal file
3
frontend/node_modules/zrender/lib/tool/convertPath.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import PathProxy from '../core/PathProxy';
|
||||
export declare function pathToBezierCurves(path: PathProxy): number[][];
|
||||
export declare function pathToPolygons(path: PathProxy, scale?: number): number[][];
|
197
frontend/node_modules/zrender/lib/tool/convertPath.js
generated
vendored
Normal file
197
frontend/node_modules/zrender/lib/tool/convertPath.js
generated
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
import { cubicSubdivide } from '../core/curve.js';
|
||||
import PathProxy from '../core/PathProxy.js';
|
||||
var CMD = PathProxy.CMD;
|
||||
function aroundEqual(a, b) {
|
||||
return Math.abs(a - b) < 1e-5;
|
||||
}
|
||||
export function pathToBezierCurves(path) {
|
||||
var data = path.data;
|
||||
var len = path.len();
|
||||
var bezierArrayGroups = [];
|
||||
var currentSubpath;
|
||||
var xi = 0;
|
||||
var yi = 0;
|
||||
var x0 = 0;
|
||||
var y0 = 0;
|
||||
function createNewSubpath(x, y) {
|
||||
if (currentSubpath && currentSubpath.length > 2) {
|
||||
bezierArrayGroups.push(currentSubpath);
|
||||
}
|
||||
currentSubpath = [x, y];
|
||||
}
|
||||
function addLine(x0, y0, x1, y1) {
|
||||
if (!(aroundEqual(x0, x1) && aroundEqual(y0, y1))) {
|
||||
currentSubpath.push(x0, y0, x1, y1, x1, y1);
|
||||
}
|
||||
}
|
||||
function addArc(startAngle, endAngle, cx, cy, rx, ry) {
|
||||
var delta = Math.abs(endAngle - startAngle);
|
||||
var len = Math.tan(delta / 4) * 4 / 3;
|
||||
var dir = endAngle < startAngle ? -1 : 1;
|
||||
var c1 = Math.cos(startAngle);
|
||||
var s1 = Math.sin(startAngle);
|
||||
var c2 = Math.cos(endAngle);
|
||||
var s2 = Math.sin(endAngle);
|
||||
var x1 = c1 * rx + cx;
|
||||
var y1 = s1 * ry + cy;
|
||||
var x4 = c2 * rx + cx;
|
||||
var y4 = s2 * ry + cy;
|
||||
var hx = rx * len * dir;
|
||||
var hy = ry * len * dir;
|
||||
currentSubpath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
|
||||
}
|
||||
var x1;
|
||||
var y1;
|
||||
var x2;
|
||||
var y2;
|
||||
for (var i = 0; i < len;) {
|
||||
var cmd = data[i++];
|
||||
var isFirst = i === 1;
|
||||
if (isFirst) {
|
||||
xi = data[i];
|
||||
yi = data[i + 1];
|
||||
x0 = xi;
|
||||
y0 = yi;
|
||||
if (cmd === CMD.L || cmd === CMD.C || cmd === CMD.Q) {
|
||||
currentSubpath = [x0, y0];
|
||||
}
|
||||
}
|
||||
switch (cmd) {
|
||||
case CMD.M:
|
||||
xi = x0 = data[i++];
|
||||
yi = y0 = data[i++];
|
||||
createNewSubpath(x0, y0);
|
||||
break;
|
||||
case CMD.L:
|
||||
x1 = data[i++];
|
||||
y1 = data[i++];
|
||||
addLine(xi, yi, x1, y1);
|
||||
xi = x1;
|
||||
yi = y1;
|
||||
break;
|
||||
case CMD.C:
|
||||
currentSubpath.push(data[i++], data[i++], data[i++], data[i++], xi = data[i++], yi = data[i++]);
|
||||
break;
|
||||
case CMD.Q:
|
||||
x1 = data[i++];
|
||||
y1 = data[i++];
|
||||
x2 = data[i++];
|
||||
y2 = data[i++];
|
||||
currentSubpath.push(xi + 2 / 3 * (x1 - xi), yi + 2 / 3 * (y1 - yi), x2 + 2 / 3 * (x1 - x2), y2 + 2 / 3 * (y1 - y2), x2, y2);
|
||||
xi = x2;
|
||||
yi = y2;
|
||||
break;
|
||||
case CMD.A:
|
||||
var cx = data[i++];
|
||||
var cy = data[i++];
|
||||
var rx = data[i++];
|
||||
var ry = data[i++];
|
||||
var startAngle = data[i++];
|
||||
var endAngle = data[i++] + startAngle;
|
||||
i += 1;
|
||||
var anticlockwise = !data[i++];
|
||||
x1 = Math.cos(startAngle) * rx + cx;
|
||||
y1 = Math.sin(startAngle) * ry + cy;
|
||||
if (isFirst) {
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
createNewSubpath(x0, y0);
|
||||
}
|
||||
else {
|
||||
addLine(xi, yi, x1, y1);
|
||||
}
|
||||
xi = Math.cos(endAngle) * rx + cx;
|
||||
yi = Math.sin(endAngle) * ry + cy;
|
||||
var step = (anticlockwise ? -1 : 1) * Math.PI / 2;
|
||||
for (var angle = startAngle; anticlockwise ? angle > endAngle : angle < endAngle; angle += step) {
|
||||
var nextAngle = anticlockwise ? Math.max(angle + step, endAngle)
|
||||
: Math.min(angle + step, endAngle);
|
||||
addArc(angle, nextAngle, cx, cy, rx, ry);
|
||||
}
|
||||
break;
|
||||
case CMD.R:
|
||||
x0 = xi = data[i++];
|
||||
y0 = yi = data[i++];
|
||||
x1 = x0 + data[i++];
|
||||
y1 = y0 + data[i++];
|
||||
createNewSubpath(x1, y0);
|
||||
addLine(x1, y0, x1, y1);
|
||||
addLine(x1, y1, x0, y1);
|
||||
addLine(x0, y1, x0, y0);
|
||||
addLine(x0, y0, x1, y0);
|
||||
break;
|
||||
case CMD.Z:
|
||||
currentSubpath && addLine(xi, yi, x0, y0);
|
||||
xi = x0;
|
||||
yi = y0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentSubpath && currentSubpath.length > 2) {
|
||||
bezierArrayGroups.push(currentSubpath);
|
||||
}
|
||||
return bezierArrayGroups;
|
||||
}
|
||||
function adpativeBezier(x0, y0, x1, y1, x2, y2, x3, y3, out, scale) {
|
||||
if (aroundEqual(x0, x1) && aroundEqual(y0, y1) && aroundEqual(x2, x3) && aroundEqual(y2, y3)) {
|
||||
out.push(x3, y3);
|
||||
return;
|
||||
}
|
||||
var PIXEL_DISTANCE = 2 / scale;
|
||||
var PIXEL_DISTANCE_SQR = PIXEL_DISTANCE * PIXEL_DISTANCE;
|
||||
var dx = x3 - x0;
|
||||
var dy = y3 - y0;
|
||||
var d = Math.sqrt(dx * dx + dy * dy);
|
||||
dx /= d;
|
||||
dy /= d;
|
||||
var dx1 = x1 - x0;
|
||||
var dy1 = y1 - y0;
|
||||
var dx2 = x2 - x3;
|
||||
var dy2 = y2 - y3;
|
||||
var cp1LenSqr = dx1 * dx1 + dy1 * dy1;
|
||||
var cp2LenSqr = dx2 * dx2 + dy2 * dy2;
|
||||
if (cp1LenSqr < PIXEL_DISTANCE_SQR && cp2LenSqr < PIXEL_DISTANCE_SQR) {
|
||||
out.push(x3, y3);
|
||||
return;
|
||||
}
|
||||
var projLen1 = dx * dx1 + dy * dy1;
|
||||
var projLen2 = -dx * dx2 - dy * dy2;
|
||||
var d1Sqr = cp1LenSqr - projLen1 * projLen1;
|
||||
var d2Sqr = cp2LenSqr - projLen2 * projLen2;
|
||||
if (d1Sqr < PIXEL_DISTANCE_SQR && projLen1 >= 0
|
||||
&& d2Sqr < PIXEL_DISTANCE_SQR && projLen2 >= 0) {
|
||||
out.push(x3, y3);
|
||||
return;
|
||||
}
|
||||
var tmpSegX = [];
|
||||
var tmpSegY = [];
|
||||
cubicSubdivide(x0, x1, x2, x3, 0.5, tmpSegX);
|
||||
cubicSubdivide(y0, y1, y2, y3, 0.5, tmpSegY);
|
||||
adpativeBezier(tmpSegX[0], tmpSegY[0], tmpSegX[1], tmpSegY[1], tmpSegX[2], tmpSegY[2], tmpSegX[3], tmpSegY[3], out, scale);
|
||||
adpativeBezier(tmpSegX[4], tmpSegY[4], tmpSegX[5], tmpSegY[5], tmpSegX[6], tmpSegY[6], tmpSegX[7], tmpSegY[7], out, scale);
|
||||
}
|
||||
export function pathToPolygons(path, scale) {
|
||||
var bezierArrayGroups = pathToBezierCurves(path);
|
||||
var polygons = [];
|
||||
scale = scale || 1;
|
||||
for (var i = 0; i < bezierArrayGroups.length; i++) {
|
||||
var beziers = bezierArrayGroups[i];
|
||||
var polygon = [];
|
||||
var x0 = beziers[0];
|
||||
var y0 = beziers[1];
|
||||
polygon.push(x0, y0);
|
||||
for (var k = 2; k < beziers.length;) {
|
||||
var x1 = beziers[k++];
|
||||
var y1 = beziers[k++];
|
||||
var x2 = beziers[k++];
|
||||
var y2 = beziers[k++];
|
||||
var x3 = beziers[k++];
|
||||
var y3 = beziers[k++];
|
||||
adpativeBezier(x0, y0, x1, y1, x2, y2, x3, y3, polygon, scale);
|
||||
x0 = x3;
|
||||
y0 = y3;
|
||||
}
|
||||
polygons.push(polygon);
|
||||
}
|
||||
return polygons;
|
||||
}
|
3
frontend/node_modules/zrender/lib/tool/dividePath.d.ts
generated
vendored
Normal file
3
frontend/node_modules/zrender/lib/tool/dividePath.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import Path from '../graphic/Path';
|
||||
export declare function clone(path: Path, count: number): Path<import("../graphic/Path").PathProps>[];
|
||||
export declare function split(path: Path, count: number): Path<import("../graphic/Path").PathProps>[];
|
312
frontend/node_modules/zrender/lib/tool/dividePath.js
generated
vendored
Normal file
312
frontend/node_modules/zrender/lib/tool/dividePath.js
generated
vendored
Normal file
@ -0,0 +1,312 @@
|
||||
import { fromPoints } from '../core/bbox.js';
|
||||
import BoundingRect from '../core/BoundingRect.js';
|
||||
import Point from '../core/Point.js';
|
||||
import { map } from '../core/util.js';
|
||||
import Polygon from '../graphic/shape/Polygon.js';
|
||||
import Rect from '../graphic/shape/Rect.js';
|
||||
import Sector from '../graphic/shape/Sector.js';
|
||||
import { pathToPolygons } from './convertPath.js';
|
||||
import { clonePath } from './path.js';
|
||||
function getDividingGrids(dimSize, rowDim, count) {
|
||||
var rowSize = dimSize[rowDim];
|
||||
var columnSize = dimSize[1 - rowDim];
|
||||
var ratio = Math.abs(rowSize / columnSize);
|
||||
var rowCount = Math.ceil(Math.sqrt(ratio * count));
|
||||
var columnCount = Math.floor(count / rowCount);
|
||||
if (columnCount === 0) {
|
||||
columnCount = 1;
|
||||
rowCount = count;
|
||||
}
|
||||
var grids = [];
|
||||
for (var i = 0; i < rowCount; i++) {
|
||||
grids.push(columnCount);
|
||||
}
|
||||
var currentCount = rowCount * columnCount;
|
||||
var remained = count - currentCount;
|
||||
if (remained > 0) {
|
||||
for (var i = 0; i < remained; i++) {
|
||||
grids[i % rowCount] += 1;
|
||||
}
|
||||
}
|
||||
return grids;
|
||||
}
|
||||
function divideSector(sectorShape, count, outShapes) {
|
||||
var r0 = sectorShape.r0;
|
||||
var r = sectorShape.r;
|
||||
var startAngle = sectorShape.startAngle;
|
||||
var endAngle = sectorShape.endAngle;
|
||||
var angle = Math.abs(endAngle - startAngle);
|
||||
var arcLen = angle * r;
|
||||
var deltaR = r - r0;
|
||||
var isAngleRow = arcLen > Math.abs(deltaR);
|
||||
var grids = getDividingGrids([arcLen, deltaR], isAngleRow ? 0 : 1, count);
|
||||
var rowSize = (isAngleRow ? angle : deltaR) / grids.length;
|
||||
for (var row = 0; row < grids.length; row++) {
|
||||
var columnSize = (isAngleRow ? deltaR : angle) / grids[row];
|
||||
for (var column = 0; column < grids[row]; column++) {
|
||||
var newShape = {};
|
||||
if (isAngleRow) {
|
||||
newShape.startAngle = startAngle + rowSize * row;
|
||||
newShape.endAngle = startAngle + rowSize * (row + 1);
|
||||
newShape.r0 = r0 + columnSize * column;
|
||||
newShape.r = r0 + columnSize * (column + 1);
|
||||
}
|
||||
else {
|
||||
newShape.startAngle = startAngle + columnSize * column;
|
||||
newShape.endAngle = startAngle + columnSize * (column + 1);
|
||||
newShape.r0 = r0 + rowSize * row;
|
||||
newShape.r = r0 + rowSize * (row + 1);
|
||||
}
|
||||
newShape.clockwise = sectorShape.clockwise;
|
||||
newShape.cx = sectorShape.cx;
|
||||
newShape.cy = sectorShape.cy;
|
||||
outShapes.push(newShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
function divideRect(rectShape, count, outShapes) {
|
||||
var width = rectShape.width;
|
||||
var height = rectShape.height;
|
||||
var isHorizontalRow = width > height;
|
||||
var grids = getDividingGrids([width, height], isHorizontalRow ? 0 : 1, count);
|
||||
var rowSizeDim = isHorizontalRow ? 'width' : 'height';
|
||||
var columnSizeDim = isHorizontalRow ? 'height' : 'width';
|
||||
var rowDim = isHorizontalRow ? 'x' : 'y';
|
||||
var columnDim = isHorizontalRow ? 'y' : 'x';
|
||||
var rowSize = rectShape[rowSizeDim] / grids.length;
|
||||
for (var row = 0; row < grids.length; row++) {
|
||||
var columnSize = rectShape[columnSizeDim] / grids[row];
|
||||
for (var column = 0; column < grids[row]; column++) {
|
||||
var newShape = {};
|
||||
newShape[rowDim] = row * rowSize;
|
||||
newShape[columnDim] = column * columnSize;
|
||||
newShape[rowSizeDim] = rowSize;
|
||||
newShape[columnSizeDim] = columnSize;
|
||||
newShape.x += rectShape.x;
|
||||
newShape.y += rectShape.y;
|
||||
outShapes.push(newShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
function crossProduct2d(x1, y1, x2, y2) {
|
||||
return x1 * y2 - x2 * y1;
|
||||
}
|
||||
function lineLineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
|
||||
var mx = a2x - a1x;
|
||||
var my = a2y - a1y;
|
||||
var nx = b2x - b1x;
|
||||
var ny = b2y - b1y;
|
||||
var nmCrossProduct = crossProduct2d(nx, ny, mx, my);
|
||||
if (Math.abs(nmCrossProduct) < 1e-6) {
|
||||
return null;
|
||||
}
|
||||
var b1a1x = a1x - b1x;
|
||||
var b1a1y = a1y - b1y;
|
||||
var p = crossProduct2d(b1a1x, b1a1y, nx, ny) / nmCrossProduct;
|
||||
if (p < 0 || p > 1) {
|
||||
return null;
|
||||
}
|
||||
return new Point(p * mx + a1x, p * my + a1y);
|
||||
}
|
||||
function projPtOnLine(pt, lineA, lineB) {
|
||||
var dir = new Point();
|
||||
Point.sub(dir, lineB, lineA);
|
||||
dir.normalize();
|
||||
var dir2 = new Point();
|
||||
Point.sub(dir2, pt, lineA);
|
||||
var len = dir2.dot(dir);
|
||||
return len;
|
||||
}
|
||||
function addToPoly(poly, pt) {
|
||||
var last = poly[poly.length - 1];
|
||||
if (last && last[0] === pt[0] && last[1] === pt[1]) {
|
||||
return;
|
||||
}
|
||||
poly.push(pt);
|
||||
}
|
||||
function splitPolygonByLine(points, lineA, lineB) {
|
||||
var len = points.length;
|
||||
var intersections = [];
|
||||
for (var i = 0; i < len; i++) {
|
||||
var p0 = points[i];
|
||||
var p1 = points[(i + 1) % len];
|
||||
var intersectionPt = lineLineIntersect(p0[0], p0[1], p1[0], p1[1], lineA.x, lineA.y, lineB.x, lineB.y);
|
||||
if (intersectionPt) {
|
||||
intersections.push({
|
||||
projPt: projPtOnLine(intersectionPt, lineA, lineB),
|
||||
pt: intersectionPt,
|
||||
idx: i
|
||||
});
|
||||
}
|
||||
}
|
||||
if (intersections.length < 2) {
|
||||
return [{ points: points }, { points: points }];
|
||||
}
|
||||
intersections.sort(function (a, b) {
|
||||
return a.projPt - b.projPt;
|
||||
});
|
||||
var splitPt0 = intersections[0];
|
||||
var splitPt1 = intersections[intersections.length - 1];
|
||||
if (splitPt1.idx < splitPt0.idx) {
|
||||
var tmp = splitPt0;
|
||||
splitPt0 = splitPt1;
|
||||
splitPt1 = tmp;
|
||||
}
|
||||
var splitPt0Arr = [splitPt0.pt.x, splitPt0.pt.y];
|
||||
var splitPt1Arr = [splitPt1.pt.x, splitPt1.pt.y];
|
||||
var newPolyA = [splitPt0Arr];
|
||||
var newPolyB = [splitPt1Arr];
|
||||
for (var i = splitPt0.idx + 1; i <= splitPt1.idx; i++) {
|
||||
addToPoly(newPolyA, points[i].slice());
|
||||
}
|
||||
addToPoly(newPolyA, splitPt1Arr);
|
||||
addToPoly(newPolyA, splitPt0Arr);
|
||||
for (var i = splitPt1.idx + 1; i <= splitPt0.idx + len; i++) {
|
||||
addToPoly(newPolyB, points[i % len].slice());
|
||||
}
|
||||
addToPoly(newPolyB, splitPt0Arr);
|
||||
addToPoly(newPolyB, splitPt1Arr);
|
||||
return [{
|
||||
points: newPolyA
|
||||
}, {
|
||||
points: newPolyB
|
||||
}];
|
||||
}
|
||||
function binaryDividePolygon(polygonShape) {
|
||||
var points = polygonShape.points;
|
||||
var min = [];
|
||||
var max = [];
|
||||
fromPoints(points, min, max);
|
||||
var boundingRect = new BoundingRect(min[0], min[1], max[0] - min[0], max[1] - min[1]);
|
||||
var width = boundingRect.width;
|
||||
var height = boundingRect.height;
|
||||
var x = boundingRect.x;
|
||||
var y = boundingRect.y;
|
||||
var pt0 = new Point();
|
||||
var pt1 = new Point();
|
||||
if (width > height) {
|
||||
pt0.x = pt1.x = x + width / 2;
|
||||
pt0.y = y;
|
||||
pt1.y = y + height;
|
||||
}
|
||||
else {
|
||||
pt0.y = pt1.y = y + height / 2;
|
||||
pt0.x = x;
|
||||
pt1.x = x + width;
|
||||
}
|
||||
return splitPolygonByLine(points, pt0, pt1);
|
||||
}
|
||||
function binaryDivideRecursive(divider, shape, count, out) {
|
||||
if (count === 1) {
|
||||
out.push(shape);
|
||||
}
|
||||
else {
|
||||
var mid = Math.floor(count / 2);
|
||||
var sub = divider(shape);
|
||||
binaryDivideRecursive(divider, sub[0], mid, out);
|
||||
binaryDivideRecursive(divider, sub[1], count - mid, out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
export function clone(path, count) {
|
||||
var paths = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
paths.push(clonePath(path));
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
function copyPathProps(source, target) {
|
||||
target.setStyle(source.style);
|
||||
target.z = source.z;
|
||||
target.z2 = source.z2;
|
||||
target.zlevel = source.zlevel;
|
||||
}
|
||||
function polygonConvert(points) {
|
||||
var out = [];
|
||||
for (var i = 0; i < points.length;) {
|
||||
out.push([points[i++], points[i++]]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
export function split(path, count) {
|
||||
var outShapes = [];
|
||||
var shape = path.shape;
|
||||
var OutShapeCtor;
|
||||
switch (path.type) {
|
||||
case 'rect':
|
||||
divideRect(shape, count, outShapes);
|
||||
OutShapeCtor = Rect;
|
||||
break;
|
||||
case 'sector':
|
||||
divideSector(shape, count, outShapes);
|
||||
OutShapeCtor = Sector;
|
||||
break;
|
||||
case 'circle':
|
||||
divideSector({
|
||||
r0: 0, r: shape.r, startAngle: 0, endAngle: Math.PI * 2,
|
||||
cx: shape.cx, cy: shape.cy
|
||||
}, count, outShapes);
|
||||
OutShapeCtor = Sector;
|
||||
break;
|
||||
default:
|
||||
var m = path.getComputedTransform();
|
||||
var scale = m ? Math.sqrt(Math.max(m[0] * m[0] + m[1] * m[1], m[2] * m[2] + m[3] * m[3])) : 1;
|
||||
var polygons = map(pathToPolygons(path.getUpdatedPathProxy(), scale), function (poly) { return polygonConvert(poly); });
|
||||
var polygonCount = polygons.length;
|
||||
if (polygonCount === 0) {
|
||||
binaryDivideRecursive(binaryDividePolygon, {
|
||||
points: polygons[0]
|
||||
}, count, outShapes);
|
||||
}
|
||||
else if (polygonCount === count) {
|
||||
for (var i = 0; i < polygonCount; i++) {
|
||||
outShapes.push({
|
||||
points: polygons[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
var totalArea_1 = 0;
|
||||
var items = map(polygons, function (poly) {
|
||||
var min = [];
|
||||
var max = [];
|
||||
fromPoints(poly, min, max);
|
||||
var area = (max[1] - min[1]) * (max[0] - min[0]);
|
||||
totalArea_1 += area;
|
||||
return { poly: poly, area: area };
|
||||
});
|
||||
items.sort(function (a, b) { return b.area - a.area; });
|
||||
var left = count;
|
||||
for (var i = 0; i < polygonCount; i++) {
|
||||
var item = items[i];
|
||||
if (left <= 0) {
|
||||
break;
|
||||
}
|
||||
var selfCount = i === polygonCount - 1
|
||||
? left
|
||||
: Math.ceil(item.area / totalArea_1 * count);
|
||||
if (selfCount < 0) {
|
||||
continue;
|
||||
}
|
||||
binaryDivideRecursive(binaryDividePolygon, {
|
||||
points: item.poly
|
||||
}, selfCount, outShapes);
|
||||
left -= selfCount;
|
||||
}
|
||||
;
|
||||
}
|
||||
OutShapeCtor = Polygon;
|
||||
break;
|
||||
}
|
||||
if (!OutShapeCtor) {
|
||||
return clone(path, count);
|
||||
}
|
||||
var out = [];
|
||||
for (var i = 0; i < outShapes.length; i++) {
|
||||
var subPath = new OutShapeCtor();
|
||||
subPath.setShape(outShapes[i]);
|
||||
copyPathProps(path, subPath);
|
||||
out.push(subPath);
|
||||
}
|
||||
return out;
|
||||
}
|
41
frontend/node_modules/zrender/lib/tool/morphPath.d.ts
generated
vendored
Normal file
41
frontend/node_modules/zrender/lib/tool/morphPath.d.ts
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import Path from '../graphic/Path';
|
||||
import Element, { ElementAnimateConfig } from '../Element';
|
||||
import { split } from './dividePath';
|
||||
export declare function alignBezierCurves(array1: number[][], array2: number[][]): number[][][];
|
||||
export interface CombineMorphingPath extends Path {
|
||||
childrenRef(): (CombineMorphingPath | Path)[];
|
||||
__isCombineMorphing: boolean;
|
||||
}
|
||||
export declare function centroid(array: number[]): number[];
|
||||
export declare function isCombineMorphing(path: Element): path is CombineMorphingPath;
|
||||
export declare function isMorphing(el: Element): boolean;
|
||||
export declare function morphPath(fromPath: Path, toPath: Path, animationOpts: ElementAnimateConfig): Path;
|
||||
export interface DividePathParams {
|
||||
path: Path;
|
||||
count: number;
|
||||
}
|
||||
export interface DividePath {
|
||||
(params: DividePathParams): Path[];
|
||||
}
|
||||
export interface IndividualDelay {
|
||||
(index: number, count: number, fromPath: Path, toPath: Path): number;
|
||||
}
|
||||
export interface CombineConfig extends ElementAnimateConfig {
|
||||
dividePath?: DividePath;
|
||||
individualDelay?: IndividualDelay;
|
||||
}
|
||||
export declare function combineMorph(fromList: (CombineMorphingPath | Path)[], toPath: Path, animationOpts: CombineConfig): {
|
||||
fromIndividuals: Path<import("../graphic/Path").PathProps>[];
|
||||
toIndividuals: Path<import("../graphic/Path").PathProps>[];
|
||||
count: number;
|
||||
};
|
||||
export interface SeparateConfig extends ElementAnimateConfig {
|
||||
dividePath?: DividePath;
|
||||
individualDelay?: IndividualDelay;
|
||||
}
|
||||
export declare function separateMorph(fromPath: Path, toPathList: Path[], animationOpts: SeparateConfig): {
|
||||
fromIndividuals: Path<import("../graphic/Path").PathProps>[];
|
||||
toIndividuals: Path<import("../graphic/Path").PathProps>[];
|
||||
count: number;
|
||||
};
|
||||
export { split as defaultDividePath };
|
594
frontend/node_modules/zrender/lib/tool/morphPath.js
generated
vendored
Normal file
594
frontend/node_modules/zrender/lib/tool/morphPath.js
generated
vendored
Normal file
@ -0,0 +1,594 @@
|
||||
import { cubicSubdivide } from '../core/curve.js';
|
||||
import Path from '../graphic/Path.js';
|
||||
import { defaults, map } from '../core/util.js';
|
||||
import { lerp } from '../core/vector.js';
|
||||
import { clonePath } from './path.js';
|
||||
import Transformable from '../core/Transformable.js';
|
||||
import { split } from './dividePath.js';
|
||||
import { pathToBezierCurves } from './convertPath.js';
|
||||
function alignSubpath(subpath1, subpath2) {
|
||||
var len1 = subpath1.length;
|
||||
var len2 = subpath2.length;
|
||||
if (len1 === len2) {
|
||||
return [subpath1, subpath2];
|
||||
}
|
||||
var tmpSegX = [];
|
||||
var tmpSegY = [];
|
||||
var shorterPath = len1 < len2 ? subpath1 : subpath2;
|
||||
var shorterLen = Math.min(len1, len2);
|
||||
var diff = Math.abs(len2 - len1) / 6;
|
||||
var shorterBezierCount = (shorterLen - 2) / 6;
|
||||
var eachCurveSubDivCount = Math.ceil(diff / shorterBezierCount) + 1;
|
||||
var newSubpath = [shorterPath[0], shorterPath[1]];
|
||||
var remained = diff;
|
||||
for (var i = 2; i < shorterLen;) {
|
||||
var x0 = shorterPath[i - 2];
|
||||
var y0 = shorterPath[i - 1];
|
||||
var x1 = shorterPath[i++];
|
||||
var y1 = shorterPath[i++];
|
||||
var x2 = shorterPath[i++];
|
||||
var y2 = shorterPath[i++];
|
||||
var x3 = shorterPath[i++];
|
||||
var y3 = shorterPath[i++];
|
||||
if (remained <= 0) {
|
||||
newSubpath.push(x1, y1, x2, y2, x3, y3);
|
||||
continue;
|
||||
}
|
||||
var actualSubDivCount = Math.min(remained, eachCurveSubDivCount - 1) + 1;
|
||||
for (var k = 1; k <= actualSubDivCount; k++) {
|
||||
var p = k / actualSubDivCount;
|
||||
cubicSubdivide(x0, x1, x2, x3, p, tmpSegX);
|
||||
cubicSubdivide(y0, y1, y2, y3, p, tmpSegY);
|
||||
x0 = tmpSegX[3];
|
||||
y0 = tmpSegY[3];
|
||||
newSubpath.push(tmpSegX[1], tmpSegY[1], tmpSegX[2], tmpSegY[2], x0, y0);
|
||||
x1 = tmpSegX[5];
|
||||
y1 = tmpSegY[5];
|
||||
x2 = tmpSegX[6];
|
||||
y2 = tmpSegY[6];
|
||||
}
|
||||
remained -= actualSubDivCount - 1;
|
||||
}
|
||||
return shorterPath === subpath1 ? [newSubpath, subpath2] : [subpath1, newSubpath];
|
||||
}
|
||||
function createSubpath(lastSubpathSubpath, otherSubpath) {
|
||||
var len = lastSubpathSubpath.length;
|
||||
var lastX = lastSubpathSubpath[len - 2];
|
||||
var lastY = lastSubpathSubpath[len - 1];
|
||||
var newSubpath = [];
|
||||
for (var i = 0; i < otherSubpath.length;) {
|
||||
newSubpath[i++] = lastX;
|
||||
newSubpath[i++] = lastY;
|
||||
}
|
||||
return newSubpath;
|
||||
}
|
||||
export function alignBezierCurves(array1, array2) {
|
||||
var _a;
|
||||
var lastSubpath1;
|
||||
var lastSubpath2;
|
||||
var newArray1 = [];
|
||||
var newArray2 = [];
|
||||
for (var i = 0; i < Math.max(array1.length, array2.length); i++) {
|
||||
var subpath1 = array1[i];
|
||||
var subpath2 = array2[i];
|
||||
var newSubpath1 = void 0;
|
||||
var newSubpath2 = void 0;
|
||||
if (!subpath1) {
|
||||
newSubpath1 = createSubpath(lastSubpath1 || subpath2, subpath2);
|
||||
newSubpath2 = subpath2;
|
||||
}
|
||||
else if (!subpath2) {
|
||||
newSubpath2 = createSubpath(lastSubpath2 || subpath1, subpath1);
|
||||
newSubpath1 = subpath1;
|
||||
}
|
||||
else {
|
||||
_a = alignSubpath(subpath1, subpath2), newSubpath1 = _a[0], newSubpath2 = _a[1];
|
||||
lastSubpath1 = newSubpath1;
|
||||
lastSubpath2 = newSubpath2;
|
||||
}
|
||||
newArray1.push(newSubpath1);
|
||||
newArray2.push(newSubpath2);
|
||||
}
|
||||
return [newArray1, newArray2];
|
||||
}
|
||||
export function centroid(array) {
|
||||
var signedArea = 0;
|
||||
var cx = 0;
|
||||
var cy = 0;
|
||||
var len = array.length;
|
||||
for (var i = 0, j = len - 2; i < len; j = i, i += 2) {
|
||||
var x0 = array[j];
|
||||
var y0 = array[j + 1];
|
||||
var x1 = array[i];
|
||||
var y1 = array[i + 1];
|
||||
var a = x0 * y1 - x1 * y0;
|
||||
signedArea += a;
|
||||
cx += (x0 + x1) * a;
|
||||
cy += (y0 + y1) * a;
|
||||
}
|
||||
if (signedArea === 0) {
|
||||
return [array[0] || 0, array[1] || 0];
|
||||
}
|
||||
return [cx / signedArea / 3, cy / signedArea / 3, signedArea];
|
||||
}
|
||||
function findBestRingOffset(fromSubBeziers, toSubBeziers, fromCp, toCp) {
|
||||
var bezierCount = (fromSubBeziers.length - 2) / 6;
|
||||
var bestScore = Infinity;
|
||||
var bestOffset = 0;
|
||||
var len = fromSubBeziers.length;
|
||||
var len2 = len - 2;
|
||||
for (var offset = 0; offset < bezierCount; offset++) {
|
||||
var cursorOffset = offset * 6;
|
||||
var score = 0;
|
||||
for (var k = 0; k < len; k += 2) {
|
||||
var idx = k === 0 ? cursorOffset : ((cursorOffset + k - 2) % len2 + 2);
|
||||
var x0 = fromSubBeziers[idx] - fromCp[0];
|
||||
var y0 = fromSubBeziers[idx + 1] - fromCp[1];
|
||||
var x1 = toSubBeziers[k] - toCp[0];
|
||||
var y1 = toSubBeziers[k + 1] - toCp[1];
|
||||
var dx = x1 - x0;
|
||||
var dy = y1 - y0;
|
||||
score += dx * dx + dy * dy;
|
||||
}
|
||||
if (score < bestScore) {
|
||||
bestScore = score;
|
||||
bestOffset = offset;
|
||||
}
|
||||
}
|
||||
return bestOffset;
|
||||
}
|
||||
function reverse(array) {
|
||||
var newArr = [];
|
||||
var len = array.length;
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
newArr[i] = array[len - i - 2];
|
||||
newArr[i + 1] = array[len - i - 1];
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
function findBestMorphingRotation(fromArr, toArr, searchAngleIteration, searchAngleRange) {
|
||||
var result = [];
|
||||
var fromNeedsReverse;
|
||||
for (var i = 0; i < fromArr.length; i++) {
|
||||
var fromSubpathBezier = fromArr[i];
|
||||
var toSubpathBezier = toArr[i];
|
||||
var fromCp = centroid(fromSubpathBezier);
|
||||
var toCp = centroid(toSubpathBezier);
|
||||
if (fromNeedsReverse == null) {
|
||||
fromNeedsReverse = fromCp[2] < 0 !== toCp[2] < 0;
|
||||
}
|
||||
var newFromSubpathBezier = [];
|
||||
var newToSubpathBezier = [];
|
||||
var bestAngle = 0;
|
||||
var bestScore = Infinity;
|
||||
var tmpArr = [];
|
||||
var len = fromSubpathBezier.length;
|
||||
if (fromNeedsReverse) {
|
||||
fromSubpathBezier = reverse(fromSubpathBezier);
|
||||
}
|
||||
var offset = findBestRingOffset(fromSubpathBezier, toSubpathBezier, fromCp, toCp) * 6;
|
||||
var len2 = len - 2;
|
||||
for (var k = 0; k < len2; k += 2) {
|
||||
var idx = (offset + k) % len2 + 2;
|
||||
newFromSubpathBezier[k + 2] = fromSubpathBezier[idx] - fromCp[0];
|
||||
newFromSubpathBezier[k + 3] = fromSubpathBezier[idx + 1] - fromCp[1];
|
||||
}
|
||||
newFromSubpathBezier[0] = fromSubpathBezier[offset] - fromCp[0];
|
||||
newFromSubpathBezier[1] = fromSubpathBezier[offset + 1] - fromCp[1];
|
||||
if (searchAngleIteration > 0) {
|
||||
var step = searchAngleRange / searchAngleIteration;
|
||||
for (var angle = -searchAngleRange / 2; angle <= searchAngleRange / 2; angle += step) {
|
||||
var sa = Math.sin(angle);
|
||||
var ca = Math.cos(angle);
|
||||
var score = 0;
|
||||
for (var k = 0; k < fromSubpathBezier.length; k += 2) {
|
||||
var x0 = newFromSubpathBezier[k];
|
||||
var y0 = newFromSubpathBezier[k + 1];
|
||||
var x1 = toSubpathBezier[k] - toCp[0];
|
||||
var y1 = toSubpathBezier[k + 1] - toCp[1];
|
||||
var newX1 = x1 * ca - y1 * sa;
|
||||
var newY1 = x1 * sa + y1 * ca;
|
||||
tmpArr[k] = newX1;
|
||||
tmpArr[k + 1] = newY1;
|
||||
var dx = newX1 - x0;
|
||||
var dy = newY1 - y0;
|
||||
score += dx * dx + dy * dy;
|
||||
}
|
||||
if (score < bestScore) {
|
||||
bestScore = score;
|
||||
bestAngle = angle;
|
||||
for (var m = 0; m < tmpArr.length; m++) {
|
||||
newToSubpathBezier[m] = tmpArr[m];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i_1 = 0; i_1 < len; i_1 += 2) {
|
||||
newToSubpathBezier[i_1] = toSubpathBezier[i_1] - toCp[0];
|
||||
newToSubpathBezier[i_1 + 1] = toSubpathBezier[i_1 + 1] - toCp[1];
|
||||
}
|
||||
}
|
||||
result.push({
|
||||
from: newFromSubpathBezier,
|
||||
to: newToSubpathBezier,
|
||||
fromCp: fromCp,
|
||||
toCp: toCp,
|
||||
rotation: -bestAngle
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export function isCombineMorphing(path) {
|
||||
return path.__isCombineMorphing;
|
||||
}
|
||||
export function isMorphing(el) {
|
||||
return el.__morphT >= 0;
|
||||
}
|
||||
var SAVED_METHOD_PREFIX = '__mOriginal_';
|
||||
function saveAndModifyMethod(obj, methodName, modifiers) {
|
||||
var savedMethodName = SAVED_METHOD_PREFIX + methodName;
|
||||
var originalMethod = obj[savedMethodName] || obj[methodName];
|
||||
if (!obj[savedMethodName]) {
|
||||
obj[savedMethodName] = obj[methodName];
|
||||
}
|
||||
var replace = modifiers.replace;
|
||||
var after = modifiers.after;
|
||||
var before = modifiers.before;
|
||||
obj[methodName] = function () {
|
||||
var args = arguments;
|
||||
var res;
|
||||
before && before.apply(this, args);
|
||||
if (replace) {
|
||||
res = replace.apply(this, args);
|
||||
}
|
||||
else {
|
||||
res = originalMethod.apply(this, args);
|
||||
}
|
||||
after && after.apply(this, args);
|
||||
return res;
|
||||
};
|
||||
}
|
||||
function restoreMethod(obj, methodName) {
|
||||
var savedMethodName = SAVED_METHOD_PREFIX + methodName;
|
||||
if (obj[savedMethodName]) {
|
||||
obj[methodName] = obj[savedMethodName];
|
||||
obj[savedMethodName] = null;
|
||||
}
|
||||
}
|
||||
function applyTransformOnBeziers(bezierCurves, mm) {
|
||||
for (var i = 0; i < bezierCurves.length; i++) {
|
||||
var subBeziers = bezierCurves[i];
|
||||
for (var k = 0; k < subBeziers.length;) {
|
||||
var x = subBeziers[k];
|
||||
var y = subBeziers[k + 1];
|
||||
subBeziers[k++] = mm[0] * x + mm[2] * y + mm[4];
|
||||
subBeziers[k++] = mm[1] * x + mm[3] * y + mm[5];
|
||||
}
|
||||
}
|
||||
}
|
||||
function prepareMorphPath(fromPath, toPath) {
|
||||
var fromPathProxy = fromPath.getUpdatedPathProxy();
|
||||
var toPathProxy = toPath.getUpdatedPathProxy();
|
||||
var _a = alignBezierCurves(pathToBezierCurves(fromPathProxy), pathToBezierCurves(toPathProxy)), fromBezierCurves = _a[0], toBezierCurves = _a[1];
|
||||
var fromPathTransform = fromPath.getComputedTransform();
|
||||
var toPathTransform = toPath.getComputedTransform();
|
||||
function updateIdentityTransform() {
|
||||
this.transform = null;
|
||||
}
|
||||
fromPathTransform && applyTransformOnBeziers(fromBezierCurves, fromPathTransform);
|
||||
toPathTransform && applyTransformOnBeziers(toBezierCurves, toPathTransform);
|
||||
saveAndModifyMethod(toPath, 'updateTransform', { replace: updateIdentityTransform });
|
||||
toPath.transform = null;
|
||||
var morphingData = findBestMorphingRotation(fromBezierCurves, toBezierCurves, 10, Math.PI);
|
||||
var tmpArr = [];
|
||||
saveAndModifyMethod(toPath, 'buildPath', { replace: function (path) {
|
||||
var t = toPath.__morphT;
|
||||
var onet = 1 - t;
|
||||
var newCp = [];
|
||||
for (var i = 0; i < morphingData.length; i++) {
|
||||
var item = morphingData[i];
|
||||
var from = item.from;
|
||||
var to = item.to;
|
||||
var angle = item.rotation * t;
|
||||
var fromCp = item.fromCp;
|
||||
var toCp = item.toCp;
|
||||
var sa = Math.sin(angle);
|
||||
var ca = Math.cos(angle);
|
||||
lerp(newCp, fromCp, toCp, t);
|
||||
for (var m = 0; m < from.length; m += 2) {
|
||||
var x0_1 = from[m];
|
||||
var y0_1 = from[m + 1];
|
||||
var x1 = to[m];
|
||||
var y1 = to[m + 1];
|
||||
var x = x0_1 * onet + x1 * t;
|
||||
var y = y0_1 * onet + y1 * t;
|
||||
tmpArr[m] = (x * ca - y * sa) + newCp[0];
|
||||
tmpArr[m + 1] = (x * sa + y * ca) + newCp[1];
|
||||
}
|
||||
var x0 = tmpArr[0];
|
||||
var y0 = tmpArr[1];
|
||||
path.moveTo(x0, y0);
|
||||
for (var m = 2; m < from.length;) {
|
||||
var x1 = tmpArr[m++];
|
||||
var y1 = tmpArr[m++];
|
||||
var x2 = tmpArr[m++];
|
||||
var y2 = tmpArr[m++];
|
||||
var x3 = tmpArr[m++];
|
||||
var y3 = tmpArr[m++];
|
||||
if (x0 === x1 && y0 === y1 && x2 === x3 && y2 === y3) {
|
||||
path.lineTo(x3, y3);
|
||||
}
|
||||
else {
|
||||
path.bezierCurveTo(x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
x0 = x3;
|
||||
y0 = y3;
|
||||
}
|
||||
}
|
||||
} });
|
||||
}
|
||||
export function morphPath(fromPath, toPath, animationOpts) {
|
||||
if (!fromPath || !toPath) {
|
||||
return toPath;
|
||||
}
|
||||
var oldDone = animationOpts.done;
|
||||
var oldDuring = animationOpts.during;
|
||||
prepareMorphPath(fromPath, toPath);
|
||||
toPath.__morphT = 0;
|
||||
function restoreToPath() {
|
||||
restoreMethod(toPath, 'buildPath');
|
||||
restoreMethod(toPath, 'updateTransform');
|
||||
toPath.__morphT = -1;
|
||||
toPath.createPathProxy();
|
||||
toPath.dirtyShape();
|
||||
}
|
||||
toPath.animateTo({
|
||||
__morphT: 1
|
||||
}, defaults({
|
||||
during: function (p) {
|
||||
toPath.dirtyShape();
|
||||
oldDuring && oldDuring(p);
|
||||
},
|
||||
done: function () {
|
||||
restoreToPath();
|
||||
oldDone && oldDone();
|
||||
}
|
||||
}, animationOpts));
|
||||
return toPath;
|
||||
}
|
||||
function hilbert(x, y, minX, minY, maxX, maxY) {
|
||||
var bits = 16;
|
||||
x = (maxX === minX) ? 0 : Math.round(32767 * (x - minX) / (maxX - minX));
|
||||
y = (maxY === minY) ? 0 : Math.round(32767 * (y - minY) / (maxY - minY));
|
||||
var d = 0;
|
||||
var tmp;
|
||||
for (var s = (1 << bits) / 2; s > 0; s /= 2) {
|
||||
var rx = 0;
|
||||
var ry = 0;
|
||||
if ((x & s) > 0) {
|
||||
rx = 1;
|
||||
}
|
||||
if ((y & s) > 0) {
|
||||
ry = 1;
|
||||
}
|
||||
d += s * s * ((3 * rx) ^ ry);
|
||||
if (ry === 0) {
|
||||
if (rx === 1) {
|
||||
x = s - 1 - x;
|
||||
y = s - 1 - y;
|
||||
}
|
||||
tmp = x;
|
||||
x = y;
|
||||
y = tmp;
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
function sortPaths(pathList) {
|
||||
var xMin = Infinity;
|
||||
var yMin = Infinity;
|
||||
var xMax = -Infinity;
|
||||
var yMax = -Infinity;
|
||||
var cps = map(pathList, function (path) {
|
||||
var rect = path.getBoundingRect();
|
||||
var m = path.getComputedTransform();
|
||||
var x = rect.x + rect.width / 2 + (m ? m[4] : 0);
|
||||
var y = rect.y + rect.height / 2 + (m ? m[5] : 0);
|
||||
xMin = Math.min(x, xMin);
|
||||
yMin = Math.min(y, yMin);
|
||||
xMax = Math.max(x, xMax);
|
||||
yMax = Math.max(y, yMax);
|
||||
return [x, y];
|
||||
});
|
||||
var items = map(cps, function (cp, idx) {
|
||||
return {
|
||||
cp: cp,
|
||||
z: hilbert(cp[0], cp[1], xMin, yMin, xMax, yMax),
|
||||
path: pathList[idx]
|
||||
};
|
||||
});
|
||||
return items.sort(function (a, b) { return a.z - b.z; }).map(function (item) { return item.path; });
|
||||
}
|
||||
;
|
||||
function defaultDividePath(param) {
|
||||
return split(param.path, param.count);
|
||||
}
|
||||
function createEmptyReturn() {
|
||||
return {
|
||||
fromIndividuals: [],
|
||||
toIndividuals: [],
|
||||
count: 0
|
||||
};
|
||||
}
|
||||
export function combineMorph(fromList, toPath, animationOpts) {
|
||||
var fromPathList = [];
|
||||
function addFromPath(fromList) {
|
||||
for (var i = 0; i < fromList.length; i++) {
|
||||
var from = fromList[i];
|
||||
if (isCombineMorphing(from)) {
|
||||
addFromPath(from.childrenRef());
|
||||
}
|
||||
else if (from instanceof Path) {
|
||||
fromPathList.push(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
addFromPath(fromList);
|
||||
var separateCount = fromPathList.length;
|
||||
if (!separateCount) {
|
||||
return createEmptyReturn();
|
||||
}
|
||||
var dividePath = animationOpts.dividePath || defaultDividePath;
|
||||
var toSubPathList = dividePath({
|
||||
path: toPath, count: separateCount
|
||||
});
|
||||
if (toSubPathList.length !== separateCount) {
|
||||
console.error('Invalid morphing: unmatched splitted path');
|
||||
return createEmptyReturn();
|
||||
}
|
||||
fromPathList = sortPaths(fromPathList);
|
||||
toSubPathList = sortPaths(toSubPathList);
|
||||
var oldDone = animationOpts.done;
|
||||
var oldDuring = animationOpts.during;
|
||||
var individualDelay = animationOpts.individualDelay;
|
||||
var identityTransform = new Transformable();
|
||||
for (var i = 0; i < separateCount; i++) {
|
||||
var from = fromPathList[i];
|
||||
var to = toSubPathList[i];
|
||||
to.parent = toPath;
|
||||
to.copyTransform(identityTransform);
|
||||
if (!individualDelay) {
|
||||
prepareMorphPath(from, to);
|
||||
}
|
||||
}
|
||||
toPath.__isCombineMorphing = true;
|
||||
toPath.childrenRef = function () {
|
||||
return toSubPathList;
|
||||
};
|
||||
function addToSubPathListToZr(zr) {
|
||||
for (var i = 0; i < toSubPathList.length; i++) {
|
||||
toSubPathList[i].addSelfToZr(zr);
|
||||
}
|
||||
}
|
||||
saveAndModifyMethod(toPath, 'addSelfToZr', {
|
||||
after: function (zr) {
|
||||
addToSubPathListToZr(zr);
|
||||
}
|
||||
});
|
||||
saveAndModifyMethod(toPath, 'removeSelfFromZr', {
|
||||
after: function (zr) {
|
||||
for (var i = 0; i < toSubPathList.length; i++) {
|
||||
toSubPathList[i].removeSelfFromZr(zr);
|
||||
}
|
||||
}
|
||||
});
|
||||
function restoreToPath() {
|
||||
toPath.__isCombineMorphing = false;
|
||||
toPath.__morphT = -1;
|
||||
toPath.childrenRef = null;
|
||||
restoreMethod(toPath, 'addSelfToZr');
|
||||
restoreMethod(toPath, 'removeSelfFromZr');
|
||||
}
|
||||
var toLen = toSubPathList.length;
|
||||
if (individualDelay) {
|
||||
var animating_1 = toLen;
|
||||
var eachDone = function () {
|
||||
animating_1--;
|
||||
if (animating_1 === 0) {
|
||||
restoreToPath();
|
||||
oldDone && oldDone();
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < toLen; i++) {
|
||||
var indivdualAnimationOpts = individualDelay ? defaults({
|
||||
delay: (animationOpts.delay || 0) + individualDelay(i, toLen, fromPathList[i], toSubPathList[i]),
|
||||
done: eachDone
|
||||
}, animationOpts) : animationOpts;
|
||||
morphPath(fromPathList[i], toSubPathList[i], indivdualAnimationOpts);
|
||||
}
|
||||
}
|
||||
else {
|
||||
toPath.__morphT = 0;
|
||||
toPath.animateTo({
|
||||
__morphT: 1
|
||||
}, defaults({
|
||||
during: function (p) {
|
||||
for (var i = 0; i < toLen; i++) {
|
||||
var child = toSubPathList[i];
|
||||
child.__morphT = toPath.__morphT;
|
||||
child.dirtyShape();
|
||||
}
|
||||
oldDuring && oldDuring(p);
|
||||
},
|
||||
done: function () {
|
||||
restoreToPath();
|
||||
for (var i = 0; i < fromList.length; i++) {
|
||||
restoreMethod(fromList[i], 'updateTransform');
|
||||
}
|
||||
oldDone && oldDone();
|
||||
}
|
||||
}, animationOpts));
|
||||
}
|
||||
if (toPath.__zr) {
|
||||
addToSubPathListToZr(toPath.__zr);
|
||||
}
|
||||
return {
|
||||
fromIndividuals: fromPathList,
|
||||
toIndividuals: toSubPathList,
|
||||
count: toLen
|
||||
};
|
||||
}
|
||||
export function separateMorph(fromPath, toPathList, animationOpts) {
|
||||
var toLen = toPathList.length;
|
||||
var fromPathList = [];
|
||||
var dividePath = animationOpts.dividePath || defaultDividePath;
|
||||
function addFromPath(fromList) {
|
||||
for (var i = 0; i < fromList.length; i++) {
|
||||
var from = fromList[i];
|
||||
if (isCombineMorphing(from)) {
|
||||
addFromPath(from.childrenRef());
|
||||
}
|
||||
else if (from instanceof Path) {
|
||||
fromPathList.push(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isCombineMorphing(fromPath)) {
|
||||
addFromPath(fromPath.childrenRef());
|
||||
var fromLen = fromPathList.length;
|
||||
if (fromLen < toLen) {
|
||||
var k = 0;
|
||||
for (var i = fromLen; i < toLen; i++) {
|
||||
fromPathList.push(clonePath(fromPathList[k++ % fromLen]));
|
||||
}
|
||||
}
|
||||
fromPathList.length = toLen;
|
||||
}
|
||||
else {
|
||||
fromPathList = dividePath({ path: fromPath, count: toLen });
|
||||
var fromPathTransform = fromPath.getComputedTransform();
|
||||
for (var i = 0; i < fromPathList.length; i++) {
|
||||
fromPathList[i].setLocalTransform(fromPathTransform);
|
||||
}
|
||||
if (fromPathList.length !== toLen) {
|
||||
console.error('Invalid morphing: unmatched splitted path');
|
||||
return createEmptyReturn();
|
||||
}
|
||||
}
|
||||
fromPathList = sortPaths(fromPathList);
|
||||
toPathList = sortPaths(toPathList);
|
||||
var individualDelay = animationOpts.individualDelay;
|
||||
for (var i = 0; i < toLen; i++) {
|
||||
var indivdualAnimationOpts = individualDelay ? defaults({
|
||||
delay: (animationOpts.delay || 0) + individualDelay(i, toLen, fromPathList[i], toPathList[i])
|
||||
}, animationOpts) : animationOpts;
|
||||
morphPath(fromPathList[i], toPathList[i], indivdualAnimationOpts);
|
||||
}
|
||||
return {
|
||||
fromIndividuals: fromPathList,
|
||||
toIndividuals: toPathList,
|
||||
count: toPathList.length
|
||||
};
|
||||
}
|
||||
export { split as defaultDividePath };
|
36
frontend/node_modules/zrender/lib/tool/parseSVG.d.ts
generated
vendored
Normal file
36
frontend/node_modules/zrender/lib/tool/parseSVG.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import Group from '../graphic/Group';
|
||||
import Element from '../Element';
|
||||
import { RectLike } from '../core/BoundingRect';
|
||||
import { parseXML } from './parseXML';
|
||||
interface SVGParserOption {
|
||||
width?: number;
|
||||
height?: number;
|
||||
ignoreViewBox?: boolean;
|
||||
ignoreRootClip?: boolean;
|
||||
}
|
||||
export interface SVGParserResult {
|
||||
root: Group;
|
||||
width: number;
|
||||
height: number;
|
||||
viewBoxRect: RectLike;
|
||||
viewBoxTransform: {
|
||||
x: number;
|
||||
y: number;
|
||||
scale: number;
|
||||
};
|
||||
named: SVGParserResultNamedItem[];
|
||||
}
|
||||
export interface SVGParserResultNamedItem {
|
||||
name: string;
|
||||
namedFrom: SVGParserResultNamedItem;
|
||||
svgNodeTagLower: SVGNodeTagLower;
|
||||
el: Element;
|
||||
}
|
||||
export declare type SVGNodeTagLower = 'g' | 'rect' | 'circle' | 'line' | 'ellipse' | 'polygon' | 'polyline' | 'image' | 'text' | 'tspan' | 'path' | 'defs' | 'switch';
|
||||
export declare function makeViewBoxTransform(viewBoxRect: RectLike, boundingRect: RectLike): {
|
||||
scale: number;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
export declare function parseSVG(xml: string | Document | SVGElement, opt: SVGParserOption): SVGParserResult;
|
||||
export { parseXML };
|
637
frontend/node_modules/zrender/lib/tool/parseSVG.js
generated
vendored
Normal file
637
frontend/node_modules/zrender/lib/tool/parseSVG.js
generated
vendored
Normal file
@ -0,0 +1,637 @@
|
||||
import Group from '../graphic/Group.js';
|
||||
import ZRImage from '../graphic/Image.js';
|
||||
import Circle from '../graphic/shape/Circle.js';
|
||||
import Rect from '../graphic/shape/Rect.js';
|
||||
import Ellipse from '../graphic/shape/Ellipse.js';
|
||||
import Line from '../graphic/shape/Line.js';
|
||||
import Polygon from '../graphic/shape/Polygon.js';
|
||||
import Polyline from '../graphic/shape/Polyline.js';
|
||||
import * as matrix from '../core/matrix.js';
|
||||
import { createFromString } from './path.js';
|
||||
import { defaults, trim, each, map, keys, hasOwn } from '../core/util.js';
|
||||
import LinearGradient from '../graphic/LinearGradient.js';
|
||||
import RadialGradient from '../graphic/RadialGradient.js';
|
||||
import TSpan from '../graphic/TSpan.js';
|
||||
import { parseXML } from './parseXML.js';
|
||||
;
|
||||
var nodeParsers;
|
||||
var INHERITABLE_STYLE_ATTRIBUTES_MAP = {
|
||||
'fill': 'fill',
|
||||
'stroke': 'stroke',
|
||||
'stroke-width': 'lineWidth',
|
||||
'opacity': 'opacity',
|
||||
'fill-opacity': 'fillOpacity',
|
||||
'stroke-opacity': 'strokeOpacity',
|
||||
'stroke-dasharray': 'lineDash',
|
||||
'stroke-dashoffset': 'lineDashOffset',
|
||||
'stroke-linecap': 'lineCap',
|
||||
'stroke-linejoin': 'lineJoin',
|
||||
'stroke-miterlimit': 'miterLimit',
|
||||
'font-family': 'fontFamily',
|
||||
'font-size': 'fontSize',
|
||||
'font-style': 'fontStyle',
|
||||
'font-weight': 'fontWeight',
|
||||
'text-anchor': 'textAlign',
|
||||
'visibility': 'visibility',
|
||||
'display': 'display'
|
||||
};
|
||||
var INHERITABLE_STYLE_ATTRIBUTES_MAP_KEYS = keys(INHERITABLE_STYLE_ATTRIBUTES_MAP);
|
||||
var SELF_STYLE_ATTRIBUTES_MAP = {
|
||||
'alignment-baseline': 'textBaseline',
|
||||
'stop-color': 'stopColor'
|
||||
};
|
||||
var SELF_STYLE_ATTRIBUTES_MAP_KEYS = keys(SELF_STYLE_ATTRIBUTES_MAP);
|
||||
var SVGParser = (function () {
|
||||
function SVGParser() {
|
||||
this._defs = {};
|
||||
this._root = null;
|
||||
}
|
||||
SVGParser.prototype.parse = function (xml, opt) {
|
||||
opt = opt || {};
|
||||
var svg = parseXML(xml);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!svg) {
|
||||
throw new Error('Illegal svg');
|
||||
}
|
||||
}
|
||||
this._defsUsePending = [];
|
||||
var root = new Group();
|
||||
this._root = root;
|
||||
var named = [];
|
||||
var viewBox = svg.getAttribute('viewBox') || '';
|
||||
var width = parseFloat((svg.getAttribute('width') || opt.width));
|
||||
var height = parseFloat((svg.getAttribute('height') || opt.height));
|
||||
isNaN(width) && (width = null);
|
||||
isNaN(height) && (height = null);
|
||||
parseAttributes(svg, root, null, true, false);
|
||||
var child = svg.firstChild;
|
||||
while (child) {
|
||||
this._parseNode(child, root, named, null, false, false);
|
||||
child = child.nextSibling;
|
||||
}
|
||||
applyDefs(this._defs, this._defsUsePending);
|
||||
this._defsUsePending = [];
|
||||
var viewBoxRect;
|
||||
var viewBoxTransform;
|
||||
if (viewBox) {
|
||||
var viewBoxArr = splitNumberSequence(viewBox);
|
||||
if (viewBoxArr.length >= 4) {
|
||||
viewBoxRect = {
|
||||
x: parseFloat((viewBoxArr[0] || 0)),
|
||||
y: parseFloat((viewBoxArr[1] || 0)),
|
||||
width: parseFloat(viewBoxArr[2]),
|
||||
height: parseFloat(viewBoxArr[3])
|
||||
};
|
||||
}
|
||||
}
|
||||
if (viewBoxRect && width != null && height != null) {
|
||||
viewBoxTransform = makeViewBoxTransform(viewBoxRect, { x: 0, y: 0, width: width, height: height });
|
||||
if (!opt.ignoreViewBox) {
|
||||
var elRoot = root;
|
||||
root = new Group();
|
||||
root.add(elRoot);
|
||||
elRoot.scaleX = elRoot.scaleY = viewBoxTransform.scale;
|
||||
elRoot.x = viewBoxTransform.x;
|
||||
elRoot.y = viewBoxTransform.y;
|
||||
}
|
||||
}
|
||||
if (!opt.ignoreRootClip && width != null && height != null) {
|
||||
root.setClipPath(new Rect({
|
||||
shape: { x: 0, y: 0, width: width, height: height }
|
||||
}));
|
||||
}
|
||||
return {
|
||||
root: root,
|
||||
width: width,
|
||||
height: height,
|
||||
viewBoxRect: viewBoxRect,
|
||||
viewBoxTransform: viewBoxTransform,
|
||||
named: named
|
||||
};
|
||||
};
|
||||
SVGParser.prototype._parseNode = function (xmlNode, parentGroup, named, namedFrom, isInDefs, isInText) {
|
||||
var nodeName = xmlNode.nodeName.toLowerCase();
|
||||
var el;
|
||||
var namedFromForSub = namedFrom;
|
||||
if (nodeName === 'defs') {
|
||||
isInDefs = true;
|
||||
}
|
||||
if (nodeName === 'text') {
|
||||
isInText = true;
|
||||
}
|
||||
if (nodeName === 'defs' || nodeName === 'switch') {
|
||||
el = parentGroup;
|
||||
}
|
||||
else {
|
||||
if (!isInDefs) {
|
||||
var parser_1 = nodeParsers[nodeName];
|
||||
if (parser_1 && hasOwn(nodeParsers, nodeName)) {
|
||||
el = parser_1.call(this, xmlNode, parentGroup);
|
||||
var nameAttr = xmlNode.getAttribute('name');
|
||||
if (nameAttr) {
|
||||
var newNamed = {
|
||||
name: nameAttr,
|
||||
namedFrom: null,
|
||||
svgNodeTagLower: nodeName,
|
||||
el: el
|
||||
};
|
||||
named.push(newNamed);
|
||||
if (nodeName === 'g') {
|
||||
namedFromForSub = newNamed;
|
||||
}
|
||||
}
|
||||
else if (namedFrom) {
|
||||
named.push({
|
||||
name: namedFrom.name,
|
||||
namedFrom: namedFrom,
|
||||
svgNodeTagLower: nodeName,
|
||||
el: el
|
||||
});
|
||||
}
|
||||
parentGroup.add(el);
|
||||
}
|
||||
}
|
||||
var parser = paintServerParsers[nodeName];
|
||||
if (parser && hasOwn(paintServerParsers, nodeName)) {
|
||||
var def = parser.call(this, xmlNode);
|
||||
var id = xmlNode.getAttribute('id');
|
||||
if (id) {
|
||||
this._defs[id] = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (el && el.isGroup) {
|
||||
var child = xmlNode.firstChild;
|
||||
while (child) {
|
||||
if (child.nodeType === 1) {
|
||||
this._parseNode(child, el, named, namedFromForSub, isInDefs, isInText);
|
||||
}
|
||||
else if (child.nodeType === 3 && isInText) {
|
||||
this._parseText(child, el);
|
||||
}
|
||||
child = child.nextSibling;
|
||||
}
|
||||
}
|
||||
};
|
||||
SVGParser.prototype._parseText = function (xmlNode, parentGroup) {
|
||||
var text = new TSpan({
|
||||
style: {
|
||||
text: xmlNode.textContent
|
||||
},
|
||||
silent: true,
|
||||
x: this._textX || 0,
|
||||
y: this._textY || 0
|
||||
});
|
||||
inheritStyle(parentGroup, text);
|
||||
parseAttributes(xmlNode, text, this._defsUsePending, false, false);
|
||||
applyTextAlignment(text, parentGroup);
|
||||
var textStyle = text.style;
|
||||
var fontSize = textStyle.fontSize;
|
||||
if (fontSize && fontSize < 9) {
|
||||
textStyle.fontSize = 9;
|
||||
text.scaleX *= fontSize / 9;
|
||||
text.scaleY *= fontSize / 9;
|
||||
}
|
||||
var font = (textStyle.fontSize || textStyle.fontFamily) && [
|
||||
textStyle.fontStyle,
|
||||
textStyle.fontWeight,
|
||||
(textStyle.fontSize || 12) + 'px',
|
||||
textStyle.fontFamily || 'sans-serif'
|
||||
].join(' ');
|
||||
textStyle.font = font;
|
||||
var rect = text.getBoundingRect();
|
||||
this._textX += rect.width;
|
||||
parentGroup.add(text);
|
||||
return text;
|
||||
};
|
||||
SVGParser.internalField = (function () {
|
||||
nodeParsers = {
|
||||
'g': function (xmlNode, parentGroup) {
|
||||
var g = new Group();
|
||||
inheritStyle(parentGroup, g);
|
||||
parseAttributes(xmlNode, g, this._defsUsePending, false, false);
|
||||
return g;
|
||||
},
|
||||
'rect': function (xmlNode, parentGroup) {
|
||||
var rect = new Rect();
|
||||
inheritStyle(parentGroup, rect);
|
||||
parseAttributes(xmlNode, rect, this._defsUsePending, false, false);
|
||||
rect.setShape({
|
||||
x: parseFloat(xmlNode.getAttribute('x') || '0'),
|
||||
y: parseFloat(xmlNode.getAttribute('y') || '0'),
|
||||
width: parseFloat(xmlNode.getAttribute('width') || '0'),
|
||||
height: parseFloat(xmlNode.getAttribute('height') || '0')
|
||||
});
|
||||
rect.silent = true;
|
||||
return rect;
|
||||
},
|
||||
'circle': function (xmlNode, parentGroup) {
|
||||
var circle = new Circle();
|
||||
inheritStyle(parentGroup, circle);
|
||||
parseAttributes(xmlNode, circle, this._defsUsePending, false, false);
|
||||
circle.setShape({
|
||||
cx: parseFloat(xmlNode.getAttribute('cx') || '0'),
|
||||
cy: parseFloat(xmlNode.getAttribute('cy') || '0'),
|
||||
r: parseFloat(xmlNode.getAttribute('r') || '0')
|
||||
});
|
||||
circle.silent = true;
|
||||
return circle;
|
||||
},
|
||||
'line': function (xmlNode, parentGroup) {
|
||||
var line = new Line();
|
||||
inheritStyle(parentGroup, line);
|
||||
parseAttributes(xmlNode, line, this._defsUsePending, false, false);
|
||||
line.setShape({
|
||||
x1: parseFloat(xmlNode.getAttribute('x1') || '0'),
|
||||
y1: parseFloat(xmlNode.getAttribute('y1') || '0'),
|
||||
x2: parseFloat(xmlNode.getAttribute('x2') || '0'),
|
||||
y2: parseFloat(xmlNode.getAttribute('y2') || '0')
|
||||
});
|
||||
line.silent = true;
|
||||
return line;
|
||||
},
|
||||
'ellipse': function (xmlNode, parentGroup) {
|
||||
var ellipse = new Ellipse();
|
||||
inheritStyle(parentGroup, ellipse);
|
||||
parseAttributes(xmlNode, ellipse, this._defsUsePending, false, false);
|
||||
ellipse.setShape({
|
||||
cx: parseFloat(xmlNode.getAttribute('cx') || '0'),
|
||||
cy: parseFloat(xmlNode.getAttribute('cy') || '0'),
|
||||
rx: parseFloat(xmlNode.getAttribute('rx') || '0'),
|
||||
ry: parseFloat(xmlNode.getAttribute('ry') || '0')
|
||||
});
|
||||
ellipse.silent = true;
|
||||
return ellipse;
|
||||
},
|
||||
'polygon': function (xmlNode, parentGroup) {
|
||||
var pointsStr = xmlNode.getAttribute('points');
|
||||
var pointsArr;
|
||||
if (pointsStr) {
|
||||
pointsArr = parsePoints(pointsStr);
|
||||
}
|
||||
var polygon = new Polygon({
|
||||
shape: {
|
||||
points: pointsArr || []
|
||||
},
|
||||
silent: true
|
||||
});
|
||||
inheritStyle(parentGroup, polygon);
|
||||
parseAttributes(xmlNode, polygon, this._defsUsePending, false, false);
|
||||
return polygon;
|
||||
},
|
||||
'polyline': function (xmlNode, parentGroup) {
|
||||
var pointsStr = xmlNode.getAttribute('points');
|
||||
var pointsArr;
|
||||
if (pointsStr) {
|
||||
pointsArr = parsePoints(pointsStr);
|
||||
}
|
||||
var polyline = new Polyline({
|
||||
shape: {
|
||||
points: pointsArr || []
|
||||
},
|
||||
silent: true
|
||||
});
|
||||
inheritStyle(parentGroup, polyline);
|
||||
parseAttributes(xmlNode, polyline, this._defsUsePending, false, false);
|
||||
return polyline;
|
||||
},
|
||||
'image': function (xmlNode, parentGroup) {
|
||||
var img = new ZRImage();
|
||||
inheritStyle(parentGroup, img);
|
||||
parseAttributes(xmlNode, img, this._defsUsePending, false, false);
|
||||
img.setStyle({
|
||||
image: xmlNode.getAttribute('xlink:href') || xmlNode.getAttribute('href'),
|
||||
x: +xmlNode.getAttribute('x'),
|
||||
y: +xmlNode.getAttribute('y'),
|
||||
width: +xmlNode.getAttribute('width'),
|
||||
height: +xmlNode.getAttribute('height')
|
||||
});
|
||||
img.silent = true;
|
||||
return img;
|
||||
},
|
||||
'text': function (xmlNode, parentGroup) {
|
||||
var x = xmlNode.getAttribute('x') || '0';
|
||||
var y = xmlNode.getAttribute('y') || '0';
|
||||
var dx = xmlNode.getAttribute('dx') || '0';
|
||||
var dy = xmlNode.getAttribute('dy') || '0';
|
||||
this._textX = parseFloat(x) + parseFloat(dx);
|
||||
this._textY = parseFloat(y) + parseFloat(dy);
|
||||
var g = new Group();
|
||||
inheritStyle(parentGroup, g);
|
||||
parseAttributes(xmlNode, g, this._defsUsePending, false, true);
|
||||
return g;
|
||||
},
|
||||
'tspan': function (xmlNode, parentGroup) {
|
||||
var x = xmlNode.getAttribute('x');
|
||||
var y = xmlNode.getAttribute('y');
|
||||
if (x != null) {
|
||||
this._textX = parseFloat(x);
|
||||
}
|
||||
if (y != null) {
|
||||
this._textY = parseFloat(y);
|
||||
}
|
||||
var dx = xmlNode.getAttribute('dx') || '0';
|
||||
var dy = xmlNode.getAttribute('dy') || '0';
|
||||
var g = new Group();
|
||||
inheritStyle(parentGroup, g);
|
||||
parseAttributes(xmlNode, g, this._defsUsePending, false, true);
|
||||
this._textX += parseFloat(dx);
|
||||
this._textY += parseFloat(dy);
|
||||
return g;
|
||||
},
|
||||
'path': function (xmlNode, parentGroup) {
|
||||
var d = xmlNode.getAttribute('d') || '';
|
||||
var path = createFromString(d);
|
||||
inheritStyle(parentGroup, path);
|
||||
parseAttributes(xmlNode, path, this._defsUsePending, false, false);
|
||||
path.silent = true;
|
||||
return path;
|
||||
}
|
||||
};
|
||||
})();
|
||||
return SVGParser;
|
||||
}());
|
||||
var paintServerParsers = {
|
||||
'lineargradient': function (xmlNode) {
|
||||
var x1 = parseInt(xmlNode.getAttribute('x1') || '0', 10);
|
||||
var y1 = parseInt(xmlNode.getAttribute('y1') || '0', 10);
|
||||
var x2 = parseInt(xmlNode.getAttribute('x2') || '10', 10);
|
||||
var y2 = parseInt(xmlNode.getAttribute('y2') || '0', 10);
|
||||
var gradient = new LinearGradient(x1, y1, x2, y2);
|
||||
parsePaintServerUnit(xmlNode, gradient);
|
||||
parseGradientColorStops(xmlNode, gradient);
|
||||
return gradient;
|
||||
},
|
||||
'radialgradient': function (xmlNode) {
|
||||
var cx = parseInt(xmlNode.getAttribute('cx') || '0', 10);
|
||||
var cy = parseInt(xmlNode.getAttribute('cy') || '0', 10);
|
||||
var r = parseInt(xmlNode.getAttribute('r') || '0', 10);
|
||||
var gradient = new RadialGradient(cx, cy, r);
|
||||
parsePaintServerUnit(xmlNode, gradient);
|
||||
parseGradientColorStops(xmlNode, gradient);
|
||||
return gradient;
|
||||
}
|
||||
};
|
||||
function parsePaintServerUnit(xmlNode, gradient) {
|
||||
var gradientUnits = xmlNode.getAttribute('gradientUnits');
|
||||
if (gradientUnits === 'userSpaceOnUse') {
|
||||
gradient.global = true;
|
||||
}
|
||||
}
|
||||
function parseGradientColorStops(xmlNode, gradient) {
|
||||
var stop = xmlNode.firstChild;
|
||||
while (stop) {
|
||||
if (stop.nodeType === 1
|
||||
&& stop.nodeName.toLocaleLowerCase() === 'stop') {
|
||||
var offsetStr = stop.getAttribute('offset');
|
||||
var offset = void 0;
|
||||
if (offsetStr && offsetStr.indexOf('%') > 0) {
|
||||
offset = parseInt(offsetStr, 10) / 100;
|
||||
}
|
||||
else if (offsetStr) {
|
||||
offset = parseFloat(offsetStr);
|
||||
}
|
||||
else {
|
||||
offset = 0;
|
||||
}
|
||||
var styleVals = {};
|
||||
parseInlineStyle(stop, styleVals, styleVals);
|
||||
var stopColor = styleVals.stopColor
|
||||
|| stop.getAttribute('stop-color')
|
||||
|| '#000000';
|
||||
gradient.colorStops.push({
|
||||
offset: offset,
|
||||
color: stopColor
|
||||
});
|
||||
}
|
||||
stop = stop.nextSibling;
|
||||
}
|
||||
}
|
||||
function inheritStyle(parent, child) {
|
||||
if (parent && parent.__inheritedStyle) {
|
||||
if (!child.__inheritedStyle) {
|
||||
child.__inheritedStyle = {};
|
||||
}
|
||||
defaults(child.__inheritedStyle, parent.__inheritedStyle);
|
||||
}
|
||||
}
|
||||
function parsePoints(pointsString) {
|
||||
var list = splitNumberSequence(pointsString);
|
||||
var points = [];
|
||||
for (var i = 0; i < list.length; i += 2) {
|
||||
var x = parseFloat(list[i]);
|
||||
var y = parseFloat(list[i + 1]);
|
||||
points.push([x, y]);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
function parseAttributes(xmlNode, el, defsUsePending, onlyInlineStyle, isTextGroup) {
|
||||
var disp = el;
|
||||
var inheritedStyle = disp.__inheritedStyle = disp.__inheritedStyle || {};
|
||||
var selfStyle = {};
|
||||
if (xmlNode.nodeType === 1) {
|
||||
parseTransformAttribute(xmlNode, el);
|
||||
parseInlineStyle(xmlNode, inheritedStyle, selfStyle);
|
||||
if (!onlyInlineStyle) {
|
||||
parseAttributeStyle(xmlNode, inheritedStyle, selfStyle);
|
||||
}
|
||||
}
|
||||
disp.style = disp.style || {};
|
||||
if (inheritedStyle.fill != null) {
|
||||
disp.style.fill = getFillStrokeStyle(disp, 'fill', inheritedStyle.fill, defsUsePending);
|
||||
}
|
||||
if (inheritedStyle.stroke != null) {
|
||||
disp.style.stroke = getFillStrokeStyle(disp, 'stroke', inheritedStyle.stroke, defsUsePending);
|
||||
}
|
||||
each([
|
||||
'lineWidth', 'opacity', 'fillOpacity', 'strokeOpacity', 'miterLimit', 'fontSize'
|
||||
], function (propName) {
|
||||
if (inheritedStyle[propName] != null) {
|
||||
disp.style[propName] = parseFloat(inheritedStyle[propName]);
|
||||
}
|
||||
});
|
||||
each([
|
||||
'lineDashOffset', 'lineCap', 'lineJoin', 'fontWeight', 'fontFamily', 'fontStyle', 'textAlign'
|
||||
], function (propName) {
|
||||
if (inheritedStyle[propName] != null) {
|
||||
disp.style[propName] = inheritedStyle[propName];
|
||||
}
|
||||
});
|
||||
if (isTextGroup) {
|
||||
disp.__selfStyle = selfStyle;
|
||||
}
|
||||
if (inheritedStyle.lineDash) {
|
||||
disp.style.lineDash = map(splitNumberSequence(inheritedStyle.lineDash), function (str) {
|
||||
return parseFloat(str);
|
||||
});
|
||||
}
|
||||
if (inheritedStyle.visibility === 'hidden' || inheritedStyle.visibility === 'collapse') {
|
||||
disp.invisible = true;
|
||||
}
|
||||
if (inheritedStyle.display === 'none') {
|
||||
disp.ignore = true;
|
||||
}
|
||||
}
|
||||
function applyTextAlignment(text, parentGroup) {
|
||||
var parentSelfStyle = parentGroup.__selfStyle;
|
||||
if (parentSelfStyle) {
|
||||
var textBaseline = parentSelfStyle.textBaseline;
|
||||
var zrTextBaseline = textBaseline;
|
||||
if (!textBaseline || textBaseline === 'auto') {
|
||||
zrTextBaseline = 'alphabetic';
|
||||
}
|
||||
else if (textBaseline === 'baseline') {
|
||||
zrTextBaseline = 'alphabetic';
|
||||
}
|
||||
else if (textBaseline === 'before-edge' || textBaseline === 'text-before-edge') {
|
||||
zrTextBaseline = 'top';
|
||||
}
|
||||
else if (textBaseline === 'after-edge' || textBaseline === 'text-after-edge') {
|
||||
zrTextBaseline = 'bottom';
|
||||
}
|
||||
else if (textBaseline === 'central' || textBaseline === 'mathematical') {
|
||||
zrTextBaseline = 'middle';
|
||||
}
|
||||
text.style.textBaseline = zrTextBaseline;
|
||||
}
|
||||
var parentInheritedStyle = parentGroup.__inheritedStyle;
|
||||
if (parentInheritedStyle) {
|
||||
var textAlign = parentInheritedStyle.textAlign;
|
||||
var zrTextAlign = textAlign;
|
||||
if (textAlign) {
|
||||
if (textAlign === 'middle') {
|
||||
zrTextAlign = 'center';
|
||||
}
|
||||
text.style.textAlign = zrTextAlign;
|
||||
}
|
||||
}
|
||||
}
|
||||
var urlRegex = /^url\(\s*#(.*?)\)/;
|
||||
function getFillStrokeStyle(el, method, str, defsUsePending) {
|
||||
var urlMatch = str && str.match(urlRegex);
|
||||
if (urlMatch) {
|
||||
var url = trim(urlMatch[1]);
|
||||
defsUsePending.push([el, method, url]);
|
||||
return;
|
||||
}
|
||||
if (str === 'none') {
|
||||
str = null;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function applyDefs(defs, defsUsePending) {
|
||||
for (var i = 0; i < defsUsePending.length; i++) {
|
||||
var item = defsUsePending[i];
|
||||
item[0].style[item[1]] = defs[item[2]];
|
||||
}
|
||||
}
|
||||
var numberReg = /-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;
|
||||
function splitNumberSequence(rawStr) {
|
||||
return rawStr.match(numberReg) || [];
|
||||
}
|
||||
var transformRegex = /(translate|scale|rotate|skewX|skewY|matrix)\(([\-\s0-9\.eE,]*)\)/g;
|
||||
var DEGREE_TO_ANGLE = Math.PI / 180;
|
||||
function parseTransformAttribute(xmlNode, node) {
|
||||
var transform = xmlNode.getAttribute('transform');
|
||||
if (transform) {
|
||||
transform = transform.replace(/,/g, ' ');
|
||||
var transformOps_1 = [];
|
||||
var mt = null;
|
||||
transform.replace(transformRegex, function (str, type, value) {
|
||||
transformOps_1.push(type, value);
|
||||
return '';
|
||||
});
|
||||
for (var i = transformOps_1.length - 1; i > 0; i -= 2) {
|
||||
var value = transformOps_1[i];
|
||||
var type = transformOps_1[i - 1];
|
||||
var valueArr = splitNumberSequence(value);
|
||||
mt = mt || matrix.create();
|
||||
switch (type) {
|
||||
case 'translate':
|
||||
matrix.translate(mt, mt, [parseFloat(valueArr[0]), parseFloat(valueArr[1] || '0')]);
|
||||
break;
|
||||
case 'scale':
|
||||
matrix.scale(mt, mt, [parseFloat(valueArr[0]), parseFloat(valueArr[1] || valueArr[0])]);
|
||||
break;
|
||||
case 'rotate':
|
||||
matrix.rotate(mt, mt, -parseFloat(valueArr[0]) * DEGREE_TO_ANGLE, [
|
||||
parseFloat(valueArr[1] || '0'),
|
||||
parseFloat(valueArr[2] || '0')
|
||||
]);
|
||||
break;
|
||||
case 'skewX':
|
||||
var sx = Math.tan(parseFloat(valueArr[0]) * DEGREE_TO_ANGLE);
|
||||
matrix.mul(mt, [1, 0, sx, 1, 0, 0], mt);
|
||||
break;
|
||||
case 'skewY':
|
||||
var sy = Math.tan(parseFloat(valueArr[0]) * DEGREE_TO_ANGLE);
|
||||
matrix.mul(mt, [1, sy, 0, 1, 0, 0], mt);
|
||||
break;
|
||||
case 'matrix':
|
||||
mt[0] = parseFloat(valueArr[0]);
|
||||
mt[1] = parseFloat(valueArr[1]);
|
||||
mt[2] = parseFloat(valueArr[2]);
|
||||
mt[3] = parseFloat(valueArr[3]);
|
||||
mt[4] = parseFloat(valueArr[4]);
|
||||
mt[5] = parseFloat(valueArr[5]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
node.setLocalTransform(mt);
|
||||
}
|
||||
}
|
||||
var styleRegex = /([^\s:;]+)\s*:\s*([^:;]+)/g;
|
||||
function parseInlineStyle(xmlNode, inheritableStyleResult, selfStyleResult) {
|
||||
var style = xmlNode.getAttribute('style');
|
||||
if (!style) {
|
||||
return;
|
||||
}
|
||||
styleRegex.lastIndex = 0;
|
||||
var styleRegResult;
|
||||
while ((styleRegResult = styleRegex.exec(style)) != null) {
|
||||
var svgStlAttr = styleRegResult[1];
|
||||
var zrInheritableStlAttr = hasOwn(INHERITABLE_STYLE_ATTRIBUTES_MAP, svgStlAttr)
|
||||
? INHERITABLE_STYLE_ATTRIBUTES_MAP[svgStlAttr]
|
||||
: null;
|
||||
if (zrInheritableStlAttr) {
|
||||
inheritableStyleResult[zrInheritableStlAttr] = styleRegResult[2];
|
||||
}
|
||||
var zrSelfStlAttr = hasOwn(SELF_STYLE_ATTRIBUTES_MAP, svgStlAttr)
|
||||
? SELF_STYLE_ATTRIBUTES_MAP[svgStlAttr]
|
||||
: null;
|
||||
if (zrSelfStlAttr) {
|
||||
selfStyleResult[zrSelfStlAttr] = styleRegResult[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
function parseAttributeStyle(xmlNode, inheritableStyleResult, selfStyleResult) {
|
||||
for (var i = 0; i < INHERITABLE_STYLE_ATTRIBUTES_MAP_KEYS.length; i++) {
|
||||
var svgAttrName = INHERITABLE_STYLE_ATTRIBUTES_MAP_KEYS[i];
|
||||
var attrValue = xmlNode.getAttribute(svgAttrName);
|
||||
if (attrValue != null) {
|
||||
inheritableStyleResult[INHERITABLE_STYLE_ATTRIBUTES_MAP[svgAttrName]] = attrValue;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < SELF_STYLE_ATTRIBUTES_MAP_KEYS.length; i++) {
|
||||
var svgAttrName = SELF_STYLE_ATTRIBUTES_MAP_KEYS[i];
|
||||
var attrValue = xmlNode.getAttribute(svgAttrName);
|
||||
if (attrValue != null) {
|
||||
selfStyleResult[SELF_STYLE_ATTRIBUTES_MAP[svgAttrName]] = attrValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
export function makeViewBoxTransform(viewBoxRect, boundingRect) {
|
||||
var scaleX = boundingRect.width / viewBoxRect.width;
|
||||
var scaleY = boundingRect.height / viewBoxRect.height;
|
||||
var scale = Math.min(scaleX, scaleY);
|
||||
return {
|
||||
scale: scale,
|
||||
x: -(viewBoxRect.x + viewBoxRect.width / 2) * scale + (boundingRect.x + boundingRect.width / 2),
|
||||
y: -(viewBoxRect.y + viewBoxRect.height / 2) * scale + (boundingRect.y + boundingRect.height / 2)
|
||||
};
|
||||
}
|
||||
export function parseSVG(xml, opt) {
|
||||
var parser = new SVGParser();
|
||||
return parser.parse(xml, opt);
|
||||
}
|
||||
export { parseXML };
|
1
frontend/node_modules/zrender/lib/tool/parseXML.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/tool/parseXML.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function parseXML(svg: Document | string | SVGElement): SVGElement;
|
15
frontend/node_modules/zrender/lib/tool/parseXML.js
generated
vendored
Normal file
15
frontend/node_modules/zrender/lib/tool/parseXML.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import { isString } from '../core/util.js';
|
||||
export function parseXML(svg) {
|
||||
if (isString(svg)) {
|
||||
var parser = new DOMParser();
|
||||
svg = parser.parseFromString(svg, 'text/xml');
|
||||
}
|
||||
var svgNode = svg;
|
||||
if (svgNode.nodeType === 9) {
|
||||
svgNode = svgNode.firstChild;
|
||||
}
|
||||
while (svgNode.nodeName.toLowerCase() !== 'svg' || svgNode.nodeType !== 1) {
|
||||
svgNode = svgNode.nextSibling;
|
||||
}
|
||||
return svgNode;
|
||||
}
|
14
frontend/node_modules/zrender/lib/tool/path.d.ts
generated
vendored
Normal file
14
frontend/node_modules/zrender/lib/tool/path.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import Path, { PathProps } from '../graphic/Path';
|
||||
import { MatrixArray } from '../core/matrix';
|
||||
declare type SVGPathOption = Omit<PathProps, 'shape' | 'buildPath'>;
|
||||
declare class SVGPath extends Path {
|
||||
applyTransform(m: MatrixArray): void;
|
||||
}
|
||||
export declare function createFromString(str: string, opts?: SVGPathOption): SVGPath;
|
||||
export declare function extendFromString(str: string, defaultOpts?: SVGPathOption): typeof SVGPath;
|
||||
export declare function mergePath(pathEls: Path[], opts: PathProps): Path<PathProps>;
|
||||
export declare function clonePath(sourcePath: Path, opts?: {
|
||||
bakeTransform?: boolean;
|
||||
toLocal?: boolean;
|
||||
}): Path<PathProps>;
|
||||
export {};
|
372
frontend/node_modules/zrender/lib/tool/path.js
generated
vendored
Normal file
372
frontend/node_modules/zrender/lib/tool/path.js
generated
vendored
Normal file
@ -0,0 +1,372 @@
|
||||
import { __extends } from "tslib";
|
||||
import Path from '../graphic/Path.js';
|
||||
import PathProxy from '../core/PathProxy.js';
|
||||
import transformPath from './transformPath.js';
|
||||
import { extend } from '../core/util.js';
|
||||
var mathSqrt = Math.sqrt;
|
||||
var mathSin = Math.sin;
|
||||
var mathCos = Math.cos;
|
||||
var PI = Math.PI;
|
||||
function vMag(v) {
|
||||
return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
|
||||
}
|
||||
;
|
||||
function vRatio(u, v) {
|
||||
return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
|
||||
}
|
||||
;
|
||||
function vAngle(u, v) {
|
||||
return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
|
||||
* Math.acos(vRatio(u, v));
|
||||
}
|
||||
;
|
||||
function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
|
||||
var psi = psiDeg * (PI / 180.0);
|
||||
var xp = mathCos(psi) * (x1 - x2) / 2.0
|
||||
+ mathSin(psi) * (y1 - y2) / 2.0;
|
||||
var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
|
||||
+ mathCos(psi) * (y1 - y2) / 2.0;
|
||||
var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
|
||||
if (lambda > 1) {
|
||||
rx *= mathSqrt(lambda);
|
||||
ry *= mathSqrt(lambda);
|
||||
}
|
||||
var f = (fa === fs ? -1 : 1)
|
||||
* mathSqrt((((rx * rx) * (ry * ry))
|
||||
- ((rx * rx) * (yp * yp))
|
||||
- ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
|
||||
+ (ry * ry) * (xp * xp))) || 0;
|
||||
var cxp = f * rx * yp / ry;
|
||||
var cyp = f * -ry * xp / rx;
|
||||
var cx = (x1 + x2) / 2.0
|
||||
+ mathCos(psi) * cxp
|
||||
- mathSin(psi) * cyp;
|
||||
var cy = (y1 + y2) / 2.0
|
||||
+ mathSin(psi) * cxp
|
||||
+ mathCos(psi) * cyp;
|
||||
var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
|
||||
var u = [(xp - cxp) / rx, (yp - cyp) / ry];
|
||||
var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
|
||||
var dTheta = vAngle(u, v);
|
||||
if (vRatio(u, v) <= -1) {
|
||||
dTheta = PI;
|
||||
}
|
||||
if (vRatio(u, v) >= 1) {
|
||||
dTheta = 0;
|
||||
}
|
||||
if (dTheta < 0) {
|
||||
var n = Math.round(dTheta / PI * 1e6) / 1e6;
|
||||
dTheta = PI * 2 + (n % 2) * PI;
|
||||
}
|
||||
path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
|
||||
}
|
||||
var commandReg = /([mlvhzcqtsa])([^mlvhzcqtsa]*)/ig;
|
||||
var numberReg = /-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;
|
||||
function createPathProxyFromString(data) {
|
||||
var path = new PathProxy();
|
||||
if (!data) {
|
||||
return path;
|
||||
}
|
||||
var cpx = 0;
|
||||
var cpy = 0;
|
||||
var subpathX = cpx;
|
||||
var subpathY = cpy;
|
||||
var prevCmd;
|
||||
var CMD = PathProxy.CMD;
|
||||
var cmdList = data.match(commandReg);
|
||||
if (!cmdList) {
|
||||
return path;
|
||||
}
|
||||
for (var l = 0; l < cmdList.length; l++) {
|
||||
var cmdText = cmdList[l];
|
||||
var cmdStr = cmdText.charAt(0);
|
||||
var cmd = void 0;
|
||||
var p = cmdText.match(numberReg) || [];
|
||||
var pLen = p.length;
|
||||
for (var i = 0; i < pLen; i++) {
|
||||
p[i] = parseFloat(p[i]);
|
||||
}
|
||||
var off = 0;
|
||||
while (off < pLen) {
|
||||
var ctlPtx = void 0;
|
||||
var ctlPty = void 0;
|
||||
var rx = void 0;
|
||||
var ry = void 0;
|
||||
var psi = void 0;
|
||||
var fa = void 0;
|
||||
var fs = void 0;
|
||||
var x1 = cpx;
|
||||
var y1 = cpy;
|
||||
var len = void 0;
|
||||
var pathData = void 0;
|
||||
switch (cmdStr) {
|
||||
case 'l':
|
||||
cpx += p[off++];
|
||||
cpy += p[off++];
|
||||
cmd = CMD.L;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
break;
|
||||
case 'L':
|
||||
cpx = p[off++];
|
||||
cpy = p[off++];
|
||||
cmd = CMD.L;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
break;
|
||||
case 'm':
|
||||
cpx += p[off++];
|
||||
cpy += p[off++];
|
||||
cmd = CMD.M;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
subpathX = cpx;
|
||||
subpathY = cpy;
|
||||
cmdStr = 'l';
|
||||
break;
|
||||
case 'M':
|
||||
cpx = p[off++];
|
||||
cpy = p[off++];
|
||||
cmd = CMD.M;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
subpathX = cpx;
|
||||
subpathY = cpy;
|
||||
cmdStr = 'L';
|
||||
break;
|
||||
case 'h':
|
||||
cpx += p[off++];
|
||||
cmd = CMD.L;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
break;
|
||||
case 'H':
|
||||
cpx = p[off++];
|
||||
cmd = CMD.L;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
break;
|
||||
case 'v':
|
||||
cpy += p[off++];
|
||||
cmd = CMD.L;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
break;
|
||||
case 'V':
|
||||
cpy = p[off++];
|
||||
cmd = CMD.L;
|
||||
path.addData(cmd, cpx, cpy);
|
||||
break;
|
||||
case 'C':
|
||||
cmd = CMD.C;
|
||||
path.addData(cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]);
|
||||
cpx = p[off - 2];
|
||||
cpy = p[off - 1];
|
||||
break;
|
||||
case 'c':
|
||||
cmd = CMD.C;
|
||||
path.addData(cmd, p[off++] + cpx, p[off++] + cpy, p[off++] + cpx, p[off++] + cpy, p[off++] + cpx, p[off++] + cpy);
|
||||
cpx += p[off - 2];
|
||||
cpy += p[off - 1];
|
||||
break;
|
||||
case 'S':
|
||||
ctlPtx = cpx;
|
||||
ctlPty = cpy;
|
||||
len = path.len();
|
||||
pathData = path.data;
|
||||
if (prevCmd === CMD.C) {
|
||||
ctlPtx += cpx - pathData[len - 4];
|
||||
ctlPty += cpy - pathData[len - 3];
|
||||
}
|
||||
cmd = CMD.C;
|
||||
x1 = p[off++];
|
||||
y1 = p[off++];
|
||||
cpx = p[off++];
|
||||
cpy = p[off++];
|
||||
path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
|
||||
break;
|
||||
case 's':
|
||||
ctlPtx = cpx;
|
||||
ctlPty = cpy;
|
||||
len = path.len();
|
||||
pathData = path.data;
|
||||
if (prevCmd === CMD.C) {
|
||||
ctlPtx += cpx - pathData[len - 4];
|
||||
ctlPty += cpy - pathData[len - 3];
|
||||
}
|
||||
cmd = CMD.C;
|
||||
x1 = cpx + p[off++];
|
||||
y1 = cpy + p[off++];
|
||||
cpx += p[off++];
|
||||
cpy += p[off++];
|
||||
path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
|
||||
break;
|
||||
case 'Q':
|
||||
x1 = p[off++];
|
||||
y1 = p[off++];
|
||||
cpx = p[off++];
|
||||
cpy = p[off++];
|
||||
cmd = CMD.Q;
|
||||
path.addData(cmd, x1, y1, cpx, cpy);
|
||||
break;
|
||||
case 'q':
|
||||
x1 = p[off++] + cpx;
|
||||
y1 = p[off++] + cpy;
|
||||
cpx += p[off++];
|
||||
cpy += p[off++];
|
||||
cmd = CMD.Q;
|
||||
path.addData(cmd, x1, y1, cpx, cpy);
|
||||
break;
|
||||
case 'T':
|
||||
ctlPtx = cpx;
|
||||
ctlPty = cpy;
|
||||
len = path.len();
|
||||
pathData = path.data;
|
||||
if (prevCmd === CMD.Q) {
|
||||
ctlPtx += cpx - pathData[len - 4];
|
||||
ctlPty += cpy - pathData[len - 3];
|
||||
}
|
||||
cpx = p[off++];
|
||||
cpy = p[off++];
|
||||
cmd = CMD.Q;
|
||||
path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
|
||||
break;
|
||||
case 't':
|
||||
ctlPtx = cpx;
|
||||
ctlPty = cpy;
|
||||
len = path.len();
|
||||
pathData = path.data;
|
||||
if (prevCmd === CMD.Q) {
|
||||
ctlPtx += cpx - pathData[len - 4];
|
||||
ctlPty += cpy - pathData[len - 3];
|
||||
}
|
||||
cpx += p[off++];
|
||||
cpy += p[off++];
|
||||
cmd = CMD.Q;
|
||||
path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
|
||||
break;
|
||||
case 'A':
|
||||
rx = p[off++];
|
||||
ry = p[off++];
|
||||
psi = p[off++];
|
||||
fa = p[off++];
|
||||
fs = p[off++];
|
||||
x1 = cpx, y1 = cpy;
|
||||
cpx = p[off++];
|
||||
cpy = p[off++];
|
||||
cmd = CMD.A;
|
||||
processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path);
|
||||
break;
|
||||
case 'a':
|
||||
rx = p[off++];
|
||||
ry = p[off++];
|
||||
psi = p[off++];
|
||||
fa = p[off++];
|
||||
fs = p[off++];
|
||||
x1 = cpx, y1 = cpy;
|
||||
cpx += p[off++];
|
||||
cpy += p[off++];
|
||||
cmd = CMD.A;
|
||||
processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmdStr === 'z' || cmdStr === 'Z') {
|
||||
cmd = CMD.Z;
|
||||
path.addData(cmd);
|
||||
cpx = subpathX;
|
||||
cpy = subpathY;
|
||||
}
|
||||
prevCmd = cmd;
|
||||
}
|
||||
path.toStatic();
|
||||
return path;
|
||||
}
|
||||
var SVGPath = (function (_super) {
|
||||
__extends(SVGPath, _super);
|
||||
function SVGPath() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
SVGPath.prototype.applyTransform = function (m) { };
|
||||
return SVGPath;
|
||||
}(Path));
|
||||
function isPathProxy(path) {
|
||||
return path.setData != null;
|
||||
}
|
||||
function createPathOptions(str, opts) {
|
||||
var pathProxy = createPathProxyFromString(str);
|
||||
var innerOpts = extend({}, opts);
|
||||
innerOpts.buildPath = function (path) {
|
||||
if (isPathProxy(path)) {
|
||||
path.setData(pathProxy.data);
|
||||
var ctx = path.getContext();
|
||||
if (ctx) {
|
||||
path.rebuildPath(ctx, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var ctx = path;
|
||||
pathProxy.rebuildPath(ctx, 1);
|
||||
}
|
||||
};
|
||||
innerOpts.applyTransform = function (m) {
|
||||
transformPath(pathProxy, m);
|
||||
this.dirtyShape();
|
||||
};
|
||||
return innerOpts;
|
||||
}
|
||||
export function createFromString(str, opts) {
|
||||
return new SVGPath(createPathOptions(str, opts));
|
||||
}
|
||||
export function extendFromString(str, defaultOpts) {
|
||||
var innerOpts = createPathOptions(str, defaultOpts);
|
||||
var Sub = (function (_super) {
|
||||
__extends(Sub, _super);
|
||||
function Sub(opts) {
|
||||
var _this = _super.call(this, opts) || this;
|
||||
_this.applyTransform = innerOpts.applyTransform;
|
||||
_this.buildPath = innerOpts.buildPath;
|
||||
return _this;
|
||||
}
|
||||
return Sub;
|
||||
}(SVGPath));
|
||||
return Sub;
|
||||
}
|
||||
export function mergePath(pathEls, opts) {
|
||||
var pathList = [];
|
||||
var len = pathEls.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var pathEl = pathEls[i];
|
||||
pathList.push(pathEl.getUpdatedPathProxy(true));
|
||||
}
|
||||
var pathBundle = new Path(opts);
|
||||
pathBundle.createPathProxy();
|
||||
pathBundle.buildPath = function (path) {
|
||||
if (isPathProxy(path)) {
|
||||
path.appendPath(pathList);
|
||||
var ctx = path.getContext();
|
||||
if (ctx) {
|
||||
path.rebuildPath(ctx, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
return pathBundle;
|
||||
}
|
||||
export function clonePath(sourcePath, opts) {
|
||||
opts = opts || {};
|
||||
var path = new Path();
|
||||
if (sourcePath.shape) {
|
||||
path.setShape(sourcePath.shape);
|
||||
}
|
||||
path.setStyle(sourcePath.style);
|
||||
if (opts.bakeTransform) {
|
||||
transformPath(path.path, sourcePath.getComputedTransform());
|
||||
}
|
||||
else {
|
||||
if (opts.toLocal) {
|
||||
path.setLocalTransform(sourcePath.getComputedTransform());
|
||||
}
|
||||
else {
|
||||
path.copyTransform(sourcePath);
|
||||
}
|
||||
}
|
||||
path.buildPath = sourcePath.buildPath;
|
||||
path.applyTransform = path.applyTransform;
|
||||
path.z = sourcePath.z;
|
||||
path.z2 = sourcePath.z2;
|
||||
path.zlevel = sourcePath.zlevel;
|
||||
return path;
|
||||
}
|
3
frontend/node_modules/zrender/lib/tool/transformPath.d.ts
generated
vendored
Normal file
3
frontend/node_modules/zrender/lib/tool/transformPath.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import PathProxy from '../core/PathProxy';
|
||||
import { MatrixArray } from '../core/matrix';
|
||||
export default function transformPath(path: PathProxy, m: MatrixArray): void;
|
81
frontend/node_modules/zrender/lib/tool/transformPath.js
generated
vendored
Normal file
81
frontend/node_modules/zrender/lib/tool/transformPath.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
import PathProxy from '../core/PathProxy.js';
|
||||
import { applyTransform as v2ApplyTransform } from '../core/vector.js';
|
||||
var CMD = PathProxy.CMD;
|
||||
var points = [[], [], []];
|
||||
var mathSqrt = Math.sqrt;
|
||||
var mathAtan2 = Math.atan2;
|
||||
export default function transformPath(path, m) {
|
||||
if (!m) {
|
||||
return;
|
||||
}
|
||||
var data = path.data;
|
||||
var len = path.len();
|
||||
var cmd;
|
||||
var nPoint;
|
||||
var i;
|
||||
var j;
|
||||
var k;
|
||||
var p;
|
||||
var M = CMD.M;
|
||||
var C = CMD.C;
|
||||
var L = CMD.L;
|
||||
var R = CMD.R;
|
||||
var A = CMD.A;
|
||||
var Q = CMD.Q;
|
||||
for (i = 0, j = 0; i < len;) {
|
||||
cmd = data[i++];
|
||||
j = i;
|
||||
nPoint = 0;
|
||||
switch (cmd) {
|
||||
case M:
|
||||
nPoint = 1;
|
||||
break;
|
||||
case L:
|
||||
nPoint = 1;
|
||||
break;
|
||||
case C:
|
||||
nPoint = 3;
|
||||
break;
|
||||
case Q:
|
||||
nPoint = 2;
|
||||
break;
|
||||
case A:
|
||||
var x = m[4];
|
||||
var y = m[5];
|
||||
var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
|
||||
var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
|
||||
var angle = mathAtan2(-m[1] / sy, m[0] / sx);
|
||||
data[i] *= sx;
|
||||
data[i++] += x;
|
||||
data[i] *= sy;
|
||||
data[i++] += y;
|
||||
data[i++] *= sx;
|
||||
data[i++] *= sy;
|
||||
data[i++] += angle;
|
||||
data[i++] += angle;
|
||||
i += 2;
|
||||
j = i;
|
||||
break;
|
||||
case R:
|
||||
p[0] = data[i++];
|
||||
p[1] = data[i++];
|
||||
v2ApplyTransform(p, p, m);
|
||||
data[j++] = p[0];
|
||||
data[j++] = p[1];
|
||||
p[0] += data[i++];
|
||||
p[1] += data[i++];
|
||||
v2ApplyTransform(p, p, m);
|
||||
data[j++] = p[0];
|
||||
data[j++] = p[1];
|
||||
}
|
||||
for (k = 0; k < nPoint; k++) {
|
||||
var p_1 = points[k];
|
||||
p_1[0] = data[i++];
|
||||
p_1[1] = data[i++];
|
||||
v2ApplyTransform(p_1, p_1, m);
|
||||
data[j++] = p_1[0];
|
||||
data[j++] = p_1[1];
|
||||
}
|
||||
}
|
||||
path.increaseVersion();
|
||||
}
|
Reference in New Issue
Block a user