逐步完成前后端服务器
This commit is contained in:
1
frontend/node_modules/zrender/lib/contain/arc.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/contain/arc.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function containStroke(cx: number, cy: number, r: number, startAngle: number, endAngle: number, anticlockwise: boolean, lineWidth: number, x: number, y: number): boolean;
|
35
frontend/node_modules/zrender/lib/contain/arc.js
generated
vendored
Normal file
35
frontend/node_modules/zrender/lib/contain/arc.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
import { normalizeRadian } from './util.js';
|
||||
var PI2 = Math.PI * 2;
|
||||
export function containStroke(cx, cy, r, startAngle, endAngle, anticlockwise, lineWidth, x, y) {
|
||||
if (lineWidth === 0) {
|
||||
return false;
|
||||
}
|
||||
var _l = lineWidth;
|
||||
x -= cx;
|
||||
y -= cy;
|
||||
var d = Math.sqrt(x * x + y * y);
|
||||
if ((d - _l > r) || (d + _l < r)) {
|
||||
return false;
|
||||
}
|
||||
if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
|
||||
return true;
|
||||
}
|
||||
if (anticlockwise) {
|
||||
var tmp = startAngle;
|
||||
startAngle = normalizeRadian(endAngle);
|
||||
endAngle = normalizeRadian(tmp);
|
||||
}
|
||||
else {
|
||||
startAngle = normalizeRadian(startAngle);
|
||||
endAngle = normalizeRadian(endAngle);
|
||||
}
|
||||
if (startAngle > endAngle) {
|
||||
endAngle += PI2;
|
||||
}
|
||||
var angle = Math.atan2(y, x);
|
||||
if (angle < 0) {
|
||||
angle += PI2;
|
||||
}
|
||||
return (angle >= startAngle && angle <= endAngle)
|
||||
|| (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
|
||||
}
|
1
frontend/node_modules/zrender/lib/contain/cubic.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/contain/cubic.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function containStroke(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, lineWidth: number, x: number, y: number): boolean;
|
15
frontend/node_modules/zrender/lib/contain/cubic.js
generated
vendored
Normal file
15
frontend/node_modules/zrender/lib/contain/cubic.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import * as curve from '../core/curve.js';
|
||||
export function containStroke(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
|
||||
if (lineWidth === 0) {
|
||||
return false;
|
||||
}
|
||||
var _l = lineWidth;
|
||||
if ((y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
|
||||
|| (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
|
||||
|| (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
|
||||
|| (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)) {
|
||||
return false;
|
||||
}
|
||||
var d = curve.cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, null);
|
||||
return d <= _l / 2;
|
||||
}
|
1
frontend/node_modules/zrender/lib/contain/line.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/contain/line.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function containStroke(x0: number, y0: number, x1: number, y1: number, lineWidth: number, x: number, y: number): boolean;
|
24
frontend/node_modules/zrender/lib/contain/line.js
generated
vendored
Normal file
24
frontend/node_modules/zrender/lib/contain/line.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
export function containStroke(x0, y0, x1, y1, lineWidth, x, y) {
|
||||
if (lineWidth === 0) {
|
||||
return false;
|
||||
}
|
||||
var _l = lineWidth;
|
||||
var _a = 0;
|
||||
var _b = x0;
|
||||
if ((y > y0 + _l && y > y1 + _l)
|
||||
|| (y < y0 - _l && y < y1 - _l)
|
||||
|| (x > x0 + _l && x > x1 + _l)
|
||||
|| (x < x0 - _l && x < x1 - _l)) {
|
||||
return false;
|
||||
}
|
||||
if (x0 !== x1) {
|
||||
_a = (y0 - y1) / (x0 - x1);
|
||||
_b = (x0 * y1 - x1 * y0) / (x0 - x1);
|
||||
}
|
||||
else {
|
||||
return Math.abs(x - x0) <= _l / 2;
|
||||
}
|
||||
var tmp = _a * x - y + _b;
|
||||
var _s = tmp * tmp / (_a * _a + 1);
|
||||
return _s <= _l / 2 * _l / 2;
|
||||
}
|
3
frontend/node_modules/zrender/lib/contain/path.d.ts
generated
vendored
Normal file
3
frontend/node_modules/zrender/lib/contain/path.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import PathProxy from '../core/PathProxy';
|
||||
export declare function contain(pathProxy: PathProxy, x: number, y: number): boolean;
|
||||
export declare function containStroke(pathProxy: PathProxy, lineWidth: number, x: number, y: number): boolean;
|
307
frontend/node_modules/zrender/lib/contain/path.js
generated
vendored
Normal file
307
frontend/node_modules/zrender/lib/contain/path.js
generated
vendored
Normal file
@ -0,0 +1,307 @@
|
||||
import PathProxy from '../core/PathProxy.js';
|
||||
import * as line from './line.js';
|
||||
import * as cubic from './cubic.js';
|
||||
import * as quadratic from './quadratic.js';
|
||||
import * as arc from './arc.js';
|
||||
import * as curve from '../core/curve.js';
|
||||
import windingLine from './windingLine.js';
|
||||
var CMD = PathProxy.CMD;
|
||||
var PI2 = Math.PI * 2;
|
||||
var EPSILON = 1e-4;
|
||||
function isAroundEqual(a, b) {
|
||||
return Math.abs(a - b) < EPSILON;
|
||||
}
|
||||
var roots = [-1, -1, -1];
|
||||
var extrema = [-1, -1];
|
||||
function swapExtrema() {
|
||||
var tmp = extrema[0];
|
||||
extrema[0] = extrema[1];
|
||||
extrema[1] = tmp;
|
||||
}
|
||||
function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
|
||||
if ((y > y0 && y > y1 && y > y2 && y > y3)
|
||||
|| (y < y0 && y < y1 && y < y2 && y < y3)) {
|
||||
return 0;
|
||||
}
|
||||
var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
|
||||
if (nRoots === 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
var w = 0;
|
||||
var nExtrema = -1;
|
||||
var y0_ = void 0;
|
||||
var y1_ = void 0;
|
||||
for (var i = 0; i < nRoots; i++) {
|
||||
var t = roots[i];
|
||||
var unit = (t === 0 || t === 1) ? 0.5 : 1;
|
||||
var x_ = curve.cubicAt(x0, x1, x2, x3, t);
|
||||
if (x_ < x) {
|
||||
continue;
|
||||
}
|
||||
if (nExtrema < 0) {
|
||||
nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
|
||||
if (extrema[1] < extrema[0] && nExtrema > 1) {
|
||||
swapExtrema();
|
||||
}
|
||||
y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
|
||||
if (nExtrema > 1) {
|
||||
y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
|
||||
}
|
||||
}
|
||||
if (nExtrema === 2) {
|
||||
if (t < extrema[0]) {
|
||||
w += y0_ < y0 ? unit : -unit;
|
||||
}
|
||||
else if (t < extrema[1]) {
|
||||
w += y1_ < y0_ ? unit : -unit;
|
||||
}
|
||||
else {
|
||||
w += y3 < y1_ ? unit : -unit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (t < extrema[0]) {
|
||||
w += y0_ < y0 ? unit : -unit;
|
||||
}
|
||||
else {
|
||||
w += y3 < y0_ ? unit : -unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return w;
|
||||
}
|
||||
}
|
||||
function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
|
||||
if ((y > y0 && y > y1 && y > y2)
|
||||
|| (y < y0 && y < y1 && y < y2)) {
|
||||
return 0;
|
||||
}
|
||||
var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
|
||||
if (nRoots === 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
var t = curve.quadraticExtremum(y0, y1, y2);
|
||||
if (t >= 0 && t <= 1) {
|
||||
var w = 0;
|
||||
var y_ = curve.quadraticAt(y0, y1, y2, t);
|
||||
for (var i = 0; i < nRoots; i++) {
|
||||
var unit = (roots[i] === 0 || roots[i] === 1) ? 0.5 : 1;
|
||||
var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
|
||||
if (x_ < x) {
|
||||
continue;
|
||||
}
|
||||
if (roots[i] < t) {
|
||||
w += y_ < y0 ? unit : -unit;
|
||||
}
|
||||
else {
|
||||
w += y2 < y_ ? unit : -unit;
|
||||
}
|
||||
}
|
||||
return w;
|
||||
}
|
||||
else {
|
||||
var unit = (roots[0] === 0 || roots[0] === 1) ? 0.5 : 1;
|
||||
var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
|
||||
if (x_ < x) {
|
||||
return 0;
|
||||
}
|
||||
return y2 < y0 ? unit : -unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
function windingArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y) {
|
||||
y -= cy;
|
||||
if (y > r || y < -r) {
|
||||
return 0;
|
||||
}
|
||||
var tmp = Math.sqrt(r * r - y * y);
|
||||
roots[0] = -tmp;
|
||||
roots[1] = tmp;
|
||||
var dTheta = Math.abs(startAngle - endAngle);
|
||||
if (dTheta < 1e-4) {
|
||||
return 0;
|
||||
}
|
||||
if (dTheta >= PI2 - 1e-4) {
|
||||
startAngle = 0;
|
||||
endAngle = PI2;
|
||||
var dir = anticlockwise ? 1 : -1;
|
||||
if (x >= roots[0] + cx && x <= roots[1] + cx) {
|
||||
return dir;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (startAngle > endAngle) {
|
||||
var tmp_1 = startAngle;
|
||||
startAngle = endAngle;
|
||||
endAngle = tmp_1;
|
||||
}
|
||||
if (startAngle < 0) {
|
||||
startAngle += PI2;
|
||||
endAngle += PI2;
|
||||
}
|
||||
var w = 0;
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var x_ = roots[i];
|
||||
if (x_ + cx > x) {
|
||||
var angle = Math.atan2(y, x_);
|
||||
var dir = anticlockwise ? 1 : -1;
|
||||
if (angle < 0) {
|
||||
angle = PI2 + angle;
|
||||
}
|
||||
if ((angle >= startAngle && angle <= endAngle)
|
||||
|| (angle + PI2 >= startAngle && angle + PI2 <= endAngle)) {
|
||||
if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
|
||||
dir = -dir;
|
||||
}
|
||||
w += dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return w;
|
||||
}
|
||||
function containPath(path, lineWidth, isStroke, x, y) {
|
||||
var data = path.data;
|
||||
var len = path.len();
|
||||
var w = 0;
|
||||
var xi = 0;
|
||||
var yi = 0;
|
||||
var x0 = 0;
|
||||
var y0 = 0;
|
||||
var x1;
|
||||
var y1;
|
||||
for (var i = 0; i < len;) {
|
||||
var cmd = data[i++];
|
||||
var isFirst = i === 1;
|
||||
if (cmd === CMD.M && i > 1) {
|
||||
if (!isStroke) {
|
||||
w += windingLine(xi, yi, x0, y0, x, y);
|
||||
}
|
||||
}
|
||||
if (isFirst) {
|
||||
xi = data[i];
|
||||
yi = data[i + 1];
|
||||
x0 = xi;
|
||||
y0 = yi;
|
||||
}
|
||||
switch (cmd) {
|
||||
case CMD.M:
|
||||
x0 = data[i++];
|
||||
y0 = data[i++];
|
||||
xi = x0;
|
||||
yi = y0;
|
||||
break;
|
||||
case CMD.L:
|
||||
if (isStroke) {
|
||||
if (line.containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
|
||||
}
|
||||
xi = data[i++];
|
||||
yi = data[i++];
|
||||
break;
|
||||
case CMD.C:
|
||||
if (isStroke) {
|
||||
if (cubic.containStroke(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], lineWidth, x, y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
w += windingCubic(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], x, y) || 0;
|
||||
}
|
||||
xi = data[i++];
|
||||
yi = data[i++];
|
||||
break;
|
||||
case CMD.Q:
|
||||
if (isStroke) {
|
||||
if (quadratic.containStroke(xi, yi, data[i++], data[i++], data[i], data[i + 1], lineWidth, x, y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
w += windingQuadratic(xi, yi, data[i++], data[i++], data[i], data[i + 1], x, y) || 0;
|
||||
}
|
||||
xi = data[i++];
|
||||
yi = data[i++];
|
||||
break;
|
||||
case CMD.A:
|
||||
var cx = data[i++];
|
||||
var cy = data[i++];
|
||||
var rx = data[i++];
|
||||
var ry = data[i++];
|
||||
var theta = data[i++];
|
||||
var dTheta = data[i++];
|
||||
i += 1;
|
||||
var anticlockwise = !!(1 - data[i++]);
|
||||
x1 = Math.cos(theta) * rx + cx;
|
||||
y1 = Math.sin(theta) * ry + cy;
|
||||
if (!isFirst) {
|
||||
w += windingLine(xi, yi, x1, y1, x, y);
|
||||
}
|
||||
else {
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
}
|
||||
var _x = (x - cx) * ry / rx + cx;
|
||||
if (isStroke) {
|
||||
if (arc.containStroke(cx, cy, ry, theta, theta + dTheta, anticlockwise, lineWidth, _x, y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
w += windingArc(cx, cy, ry, theta, theta + dTheta, anticlockwise, _x, y);
|
||||
}
|
||||
xi = Math.cos(theta + dTheta) * rx + cx;
|
||||
yi = Math.sin(theta + dTheta) * ry + cy;
|
||||
break;
|
||||
case CMD.R:
|
||||
x0 = xi = data[i++];
|
||||
y0 = yi = data[i++];
|
||||
var width = data[i++];
|
||||
var height = data[i++];
|
||||
x1 = x0 + width;
|
||||
y1 = y0 + height;
|
||||
if (isStroke) {
|
||||
if (line.containStroke(x0, y0, x1, y0, lineWidth, x, y)
|
||||
|| line.containStroke(x1, y0, x1, y1, lineWidth, x, y)
|
||||
|| line.containStroke(x1, y1, x0, y1, lineWidth, x, y)
|
||||
|| line.containStroke(x0, y1, x0, y0, lineWidth, x, y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
w += windingLine(x1, y0, x1, y1, x, y);
|
||||
w += windingLine(x0, y1, x0, y0, x, y);
|
||||
}
|
||||
break;
|
||||
case CMD.Z:
|
||||
if (isStroke) {
|
||||
if (line.containStroke(xi, yi, x0, y0, lineWidth, x, y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
w += windingLine(xi, yi, x0, y0, x, y);
|
||||
}
|
||||
xi = x0;
|
||||
yi = y0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isStroke && !isAroundEqual(yi, y0)) {
|
||||
w += windingLine(xi, yi, x0, y0, x, y) || 0;
|
||||
}
|
||||
return w !== 0;
|
||||
}
|
||||
export function contain(pathProxy, x, y) {
|
||||
return containPath(pathProxy, 0, false, x, y);
|
||||
}
|
||||
export function containStroke(pathProxy, lineWidth, x, y) {
|
||||
return containPath(pathProxy, lineWidth, true, x, y);
|
||||
}
|
2
frontend/node_modules/zrender/lib/contain/polygon.d.ts
generated
vendored
Normal file
2
frontend/node_modules/zrender/lib/contain/polygon.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { VectorArray } from '../core/vector';
|
||||
export declare function contain(points: VectorArray[], x: number, y: number): boolean;
|
22
frontend/node_modules/zrender/lib/contain/polygon.js
generated
vendored
Normal file
22
frontend/node_modules/zrender/lib/contain/polygon.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import windingLine from './windingLine.js';
|
||||
var EPSILON = 1e-8;
|
||||
function isAroundEqual(a, b) {
|
||||
return Math.abs(a - b) < EPSILON;
|
||||
}
|
||||
export function contain(points, x, y) {
|
||||
var w = 0;
|
||||
var p = points[0];
|
||||
if (!p) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 1; i < points.length; i++) {
|
||||
var p2 = points[i];
|
||||
w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
|
||||
p = p2;
|
||||
}
|
||||
var p0 = points[0];
|
||||
if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
|
||||
w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
|
||||
}
|
||||
return w !== 0;
|
||||
}
|
1
frontend/node_modules/zrender/lib/contain/quadratic.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/contain/quadratic.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function containStroke(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, x: number, y: number): boolean;
|
15
frontend/node_modules/zrender/lib/contain/quadratic.js
generated
vendored
Normal file
15
frontend/node_modules/zrender/lib/contain/quadratic.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import { quadraticProjectPoint } from '../core/curve.js';
|
||||
export function containStroke(x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
|
||||
if (lineWidth === 0) {
|
||||
return false;
|
||||
}
|
||||
var _l = lineWidth;
|
||||
if ((y > y0 + _l && y > y1 + _l && y > y2 + _l)
|
||||
|| (y < y0 - _l && y < y1 - _l && y < y2 - _l)
|
||||
|| (x > x0 + _l && x > x1 + _l && x > x2 + _l)
|
||||
|| (x < x0 - _l && x < x1 - _l && x < x2 - _l)) {
|
||||
return false;
|
||||
}
|
||||
var d = quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, null);
|
||||
return d <= _l / 2;
|
||||
}
|
23
frontend/node_modules/zrender/lib/contain/text.d.ts
generated
vendored
Normal file
23
frontend/node_modules/zrender/lib/contain/text.d.ts
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import BoundingRect, { RectLike } from '../core/BoundingRect';
|
||||
import { TextAlign, TextVerticalAlign, BuiltinTextPosition } from '../core/types';
|
||||
export declare function getWidth(text: string, font: string): number;
|
||||
export declare function innerGetBoundingRect(text: string, font: string, textAlign?: TextAlign, textBaseline?: TextVerticalAlign): BoundingRect;
|
||||
export declare function getBoundingRect(text: string, font: string, textAlign?: TextAlign, textBaseline?: TextVerticalAlign): BoundingRect;
|
||||
export declare function adjustTextX(x: number, width: number, textAlign: TextAlign): number;
|
||||
export declare function adjustTextY(y: number, height: number, verticalAlign: TextVerticalAlign): number;
|
||||
export declare function getLineHeight(font?: string): number;
|
||||
export declare function measureText(text: string, font?: string): {
|
||||
width: number;
|
||||
};
|
||||
export declare function parsePercent(value: number | string, maxValue: number): number;
|
||||
export interface TextPositionCalculationResult {
|
||||
x: number;
|
||||
y: number;
|
||||
align: TextAlign;
|
||||
verticalAlign: TextVerticalAlign;
|
||||
}
|
||||
export declare function calculateTextPosition(out: TextPositionCalculationResult, opts: {
|
||||
position?: BuiltinTextPosition | (number | string)[];
|
||||
distance?: number;
|
||||
global?: boolean;
|
||||
}, rect: RectLike): TextPositionCalculationResult;
|
170
frontend/node_modules/zrender/lib/contain/text.js
generated
vendored
Normal file
170
frontend/node_modules/zrender/lib/contain/text.js
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
import BoundingRect from '../core/BoundingRect.js';
|
||||
import LRU from '../core/LRU.js';
|
||||
import { DEFAULT_FONT, platformApi } from '../core/platform.js';
|
||||
var textWidthCache = {};
|
||||
export function getWidth(text, font) {
|
||||
font = font || DEFAULT_FONT;
|
||||
var cacheOfFont = textWidthCache[font];
|
||||
if (!cacheOfFont) {
|
||||
cacheOfFont = textWidthCache[font] = new LRU(500);
|
||||
}
|
||||
var width = cacheOfFont.get(text);
|
||||
if (width == null) {
|
||||
width = platformApi.measureText(text, font).width;
|
||||
cacheOfFont.put(text, width);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
export function innerGetBoundingRect(text, font, textAlign, textBaseline) {
|
||||
var width = getWidth(text, font);
|
||||
var height = getLineHeight(font);
|
||||
var x = adjustTextX(0, width, textAlign);
|
||||
var y = adjustTextY(0, height, textBaseline);
|
||||
var rect = new BoundingRect(x, y, width, height);
|
||||
return rect;
|
||||
}
|
||||
export function getBoundingRect(text, font, textAlign, textBaseline) {
|
||||
var textLines = ((text || '') + '').split('\n');
|
||||
var len = textLines.length;
|
||||
if (len === 1) {
|
||||
return innerGetBoundingRect(textLines[0], font, textAlign, textBaseline);
|
||||
}
|
||||
else {
|
||||
var uniondRect = new BoundingRect(0, 0, 0, 0);
|
||||
for (var i = 0; i < textLines.length; i++) {
|
||||
var rect = innerGetBoundingRect(textLines[i], font, textAlign, textBaseline);
|
||||
i === 0 ? uniondRect.copy(rect) : uniondRect.union(rect);
|
||||
}
|
||||
return uniondRect;
|
||||
}
|
||||
}
|
||||
export function adjustTextX(x, width, textAlign) {
|
||||
if (textAlign === 'right') {
|
||||
x -= width;
|
||||
}
|
||||
else if (textAlign === 'center') {
|
||||
x -= width / 2;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
export function adjustTextY(y, height, verticalAlign) {
|
||||
if (verticalAlign === 'middle') {
|
||||
y -= height / 2;
|
||||
}
|
||||
else if (verticalAlign === 'bottom') {
|
||||
y -= height;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
export function getLineHeight(font) {
|
||||
return getWidth('国', font);
|
||||
}
|
||||
export function measureText(text, font) {
|
||||
return platformApi.measureText(text, font);
|
||||
}
|
||||
export function parsePercent(value, maxValue) {
|
||||
if (typeof value === 'string') {
|
||||
if (value.lastIndexOf('%') >= 0) {
|
||||
return parseFloat(value) / 100 * maxValue;
|
||||
}
|
||||
return parseFloat(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
export function calculateTextPosition(out, opts, rect) {
|
||||
var textPosition = opts.position || 'inside';
|
||||
var distance = opts.distance != null ? opts.distance : 5;
|
||||
var height = rect.height;
|
||||
var width = rect.width;
|
||||
var halfHeight = height / 2;
|
||||
var x = rect.x;
|
||||
var y = rect.y;
|
||||
var textAlign = 'left';
|
||||
var textVerticalAlign = 'top';
|
||||
if (textPosition instanceof Array) {
|
||||
x += parsePercent(textPosition[0], rect.width);
|
||||
y += parsePercent(textPosition[1], rect.height);
|
||||
textAlign = null;
|
||||
textVerticalAlign = null;
|
||||
}
|
||||
else {
|
||||
switch (textPosition) {
|
||||
case 'left':
|
||||
x -= distance;
|
||||
y += halfHeight;
|
||||
textAlign = 'right';
|
||||
textVerticalAlign = 'middle';
|
||||
break;
|
||||
case 'right':
|
||||
x += distance + width;
|
||||
y += halfHeight;
|
||||
textVerticalAlign = 'middle';
|
||||
break;
|
||||
case 'top':
|
||||
x += width / 2;
|
||||
y -= distance;
|
||||
textAlign = 'center';
|
||||
textVerticalAlign = 'bottom';
|
||||
break;
|
||||
case 'bottom':
|
||||
x += width / 2;
|
||||
y += height + distance;
|
||||
textAlign = 'center';
|
||||
break;
|
||||
case 'inside':
|
||||
x += width / 2;
|
||||
y += halfHeight;
|
||||
textAlign = 'center';
|
||||
textVerticalAlign = 'middle';
|
||||
break;
|
||||
case 'insideLeft':
|
||||
x += distance;
|
||||
y += halfHeight;
|
||||
textVerticalAlign = 'middle';
|
||||
break;
|
||||
case 'insideRight':
|
||||
x += width - distance;
|
||||
y += halfHeight;
|
||||
textAlign = 'right';
|
||||
textVerticalAlign = 'middle';
|
||||
break;
|
||||
case 'insideTop':
|
||||
x += width / 2;
|
||||
y += distance;
|
||||
textAlign = 'center';
|
||||
break;
|
||||
case 'insideBottom':
|
||||
x += width / 2;
|
||||
y += height - distance;
|
||||
textAlign = 'center';
|
||||
textVerticalAlign = 'bottom';
|
||||
break;
|
||||
case 'insideTopLeft':
|
||||
x += distance;
|
||||
y += distance;
|
||||
break;
|
||||
case 'insideTopRight':
|
||||
x += width - distance;
|
||||
y += distance;
|
||||
textAlign = 'right';
|
||||
break;
|
||||
case 'insideBottomLeft':
|
||||
x += distance;
|
||||
y += height - distance;
|
||||
textVerticalAlign = 'bottom';
|
||||
break;
|
||||
case 'insideBottomRight':
|
||||
x += width - distance;
|
||||
y += height - distance;
|
||||
textAlign = 'right';
|
||||
textVerticalAlign = 'bottom';
|
||||
break;
|
||||
}
|
||||
}
|
||||
out = out || {};
|
||||
out.x = x;
|
||||
out.y = y;
|
||||
out.align = textAlign;
|
||||
out.verticalAlign = textVerticalAlign;
|
||||
return out;
|
||||
}
|
1
frontend/node_modules/zrender/lib/contain/util.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/contain/util.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function normalizeRadian(angle: number): number;
|
8
frontend/node_modules/zrender/lib/contain/util.js
generated
vendored
Normal file
8
frontend/node_modules/zrender/lib/contain/util.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var PI2 = Math.PI * 2;
|
||||
export function normalizeRadian(angle) {
|
||||
angle %= PI2;
|
||||
if (angle < 0) {
|
||||
angle += PI2;
|
||||
}
|
||||
return angle;
|
||||
}
|
1
frontend/node_modules/zrender/lib/contain/windingLine.d.ts
generated
vendored
Normal file
1
frontend/node_modules/zrender/lib/contain/windingLine.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default function windingLine(x0: number, y0: number, x1: number, y1: number, x: number, y: number): number;
|
15
frontend/node_modules/zrender/lib/contain/windingLine.js
generated
vendored
Normal file
15
frontend/node_modules/zrender/lib/contain/windingLine.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
export default function windingLine(x0, y0, x1, y1, x, y) {
|
||||
if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
|
||||
return 0;
|
||||
}
|
||||
if (y1 === y0) {
|
||||
return 0;
|
||||
}
|
||||
var t = (y - y0) / (y1 - y0);
|
||||
var dir = y1 < y0 ? 1 : -1;
|
||||
if (t === 1 || t === 0) {
|
||||
dir = y1 < y0 ? 0.5 : -0.5;
|
||||
}
|
||||
var x_ = t * (x1 - x0) + x0;
|
||||
return x_ === x ? Infinity : x_ > x ? dir : 0;
|
||||
}
|
Reference in New Issue
Block a user