@visactor/vrender-core 1.1.6-alpha.0 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/common/canvas-utils.d.ts +4 -1
- package/cjs/common/canvas-utils.js +9 -4
- package/cjs/common/canvas-utils.js.map +1 -1
- package/cjs/common/polygon.d.ts +8 -0
- package/cjs/common/polygon.js +107 -3
- package/cjs/common/polygon.js.map +1 -1
- package/cjs/graphic/graphic-service/polygon-outer-border-bounds.d.ts +4 -0
- package/cjs/graphic/graphic-service/polygon-outer-border-bounds.js +36 -0
- package/cjs/graphic/graphic-service/polygon-outer-border-bounds.js.map +1 -0
- package/cjs/graphic/graphic.d.ts +9 -9
- package/cjs/graphic/graphic.js +45 -54
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.d.ts +4 -6
- package/cjs/graphic/group.js +11 -21
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/node-tree.d.ts +1 -2
- package/cjs/graphic/node-tree.js +1 -1
- package/cjs/graphic/node-tree.js.map +1 -1
- package/cjs/graphic/polygon.d.ts +2 -0
- package/cjs/graphic/polygon.js +12 -2
- package/cjs/graphic/polygon.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +1 -2
- package/cjs/graphic/richtext.js +2 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/state/state-transition-orchestrator.d.ts +4 -0
- package/cjs/graphic/state/state-transition-orchestrator.js +11 -5
- package/cjs/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/cjs/graphic/text.js +7 -3
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/interface/graphic.d.ts +1 -1
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/node-tree.d.ts +1 -2
- package/cjs/interface/node-tree.js.map +1 -1
- package/cjs/render/contributions/render/contributions/polygon-contribution-render.d.ts +9 -0
- package/cjs/render/contributions/render/contributions/polygon-contribution-render.js +40 -2
- package/cjs/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +5 -5
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js +1 -1
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/dist/index.es.js +433 -198
- package/es/common/canvas-utils.d.ts +4 -1
- package/es/common/canvas-utils.js +6 -2
- package/es/common/canvas-utils.js.map +1 -1
- package/es/common/polygon.d.ts +8 -0
- package/es/common/polygon.js +102 -0
- package/es/common/polygon.js.map +1 -1
- package/es/graphic/graphic-service/polygon-outer-border-bounds.d.ts +4 -0
- package/es/graphic/graphic-service/polygon-outer-border-bounds.js +32 -0
- package/es/graphic/graphic-service/polygon-outer-border-bounds.js.map +1 -0
- package/es/graphic/graphic.d.ts +9 -9
- package/es/graphic/graphic.js +45 -54
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.d.ts +4 -6
- package/es/graphic/group.js +11 -21
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/node-tree.d.ts +1 -2
- package/es/graphic/node-tree.js +1 -1
- package/es/graphic/node-tree.js.map +1 -1
- package/es/graphic/polygon.d.ts +2 -0
- package/es/graphic/polygon.js +14 -2
- package/es/graphic/polygon.js.map +1 -1
- package/es/graphic/richtext.d.ts +1 -2
- package/es/graphic/richtext.js +2 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/state/state-transition-orchestrator.d.ts +4 -0
- package/es/graphic/state/state-transition-orchestrator.js +11 -5
- package/es/graphic/state/state-transition-orchestrator.js.map +1 -1
- package/es/graphic/text.js +7 -3
- package/es/graphic/text.js.map +1 -1
- package/es/interface/graphic.d.ts +1 -1
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/node-tree.d.ts +1 -2
- package/es/interface/node-tree.js.map +1 -1
- package/es/render/contributions/render/contributions/polygon-contribution-render.d.ts +9 -0
- package/es/render/contributions/render/contributions/polygon-contribution-render.js +40 -0
- package/es/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +5 -5
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js +2 -2
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { IColor } from '../interface/color';
|
|
2
2
|
import type { IContext2d, ITransform } from '../interface';
|
|
3
|
-
import type
|
|
3
|
+
import { type IBoundsLike, type IMatrixLike } from '@visactor/vutils';
|
|
4
|
+
type StrokeScaleMatrix = Pick<IMatrixLike, 'a' | 'b' | 'c' | 'd'>;
|
|
5
|
+
export declare function getScaledStrokeWithMatrix(matrix: StrokeScaleMatrix, width: number, dpr: number): number;
|
|
4
6
|
export declare function getScaledStroke(context: IContext2d, width: number, dpr: number): number;
|
|
5
7
|
export declare function createColor(context: IContext2d, c: string | IColor | Array<string | IColor> | boolean, params: {
|
|
6
8
|
AABBBounds?: IBoundsLike;
|
|
7
9
|
attribute?: Partial<ITransform>;
|
|
8
10
|
}, offsetX?: number, offsetY?: number): string | CanvasGradient;
|
|
11
|
+
export {};
|
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.createColor = exports.getScaledStroke = void 0;
|
|
5
|
+
}), exports.createColor = exports.getScaledStroke = exports.getScaledStrokeWithMatrix = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), color_utils_1 = require("./color-utils");
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function getScaledStrokeWithMatrix(matrix, width, dpr) {
|
|
10
10
|
let strokeWidth = width;
|
|
11
|
-
const {a: a, b: b, c: c, d: d} =
|
|
11
|
+
const {a: a, b: b, c: c, d: d} = matrix, scaleX = Math.sign(a) * Math.sqrt(a * a + b * b), scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
|
|
12
12
|
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr,
|
|
13
13
|
strokeWidth);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function getScaledStroke(context, width, dpr) {
|
|
17
|
+
return getScaledStrokeWithMatrix(context.currentMatrix, width, dpr);
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
function createColor(context, c, params, offsetX = 0, offsetY = 0) {
|
|
17
21
|
var _a, _b, _c, _d;
|
|
18
22
|
if (!c || !0 === c) return "black";
|
|
@@ -58,4 +62,5 @@ function createConicGradient(context, color, x, y, w, h) {
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
//# sourceMappingURL=canvas-utils.js.map
|
|
61
|
-
exports.
|
|
65
|
+
exports.getScaledStrokeWithMatrix = getScaledStrokeWithMatrix, exports.getScaledStroke = getScaledStroke,
|
|
66
|
+
exports.createColor = createColor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/canvas-utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/common/canvas-utils.ts"],"names":[],"mappings":";;;AAEA,6CAA+E;AAC/E,+CAA+C;AAI/C,SAAgB,yBAAyB,CAAC,MAAyB,EAAE,KAAa,EAAE,GAAW;IAC7F,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG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,CAAC,CAAE,cAAsB,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC;QAC9D,CAAC,CAAC,cAAc,CAAC;AACrB,CAAC","file":"canvas-utils.js","sourcesContent":["import type { IColor, IConicalGradient, ILinearGradient, IRadialGradient } from '../interface/color';\nimport type { IContext2d, ITransform } from '../interface';\nimport { isArray, type IBoundsLike, type IMatrixLike } from '@visactor/vutils';\nimport { GradientParser } from './color-utils';\n\ntype StrokeScaleMatrix = Pick<IMatrixLike, 'a' | 'b' | 'c' | 'd'>;\n\nexport function getScaledStrokeWithMatrix(matrix: StrokeScaleMatrix, width: number, dpr: number) {\n let strokeWidth = width;\n const { a, b, c, d } = matrix;\n const scaleX = Math.sign(a) * Math.sqrt(a * a + b * b);\n const scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);\n // 如果没有scaleX和scaleY,那么认为什么都不用绘制\n if (scaleX + scaleY === 0) {\n return 0;\n }\n strokeWidth = (strokeWidth / Math.abs(scaleX + scaleY)) * 2 * dpr;\n return strokeWidth;\n}\n\nexport function getScaledStroke(context: IContext2d, width: number, dpr: number) {\n return getScaledStrokeWithMatrix(context.currentMatrix, width, dpr);\n}\n\nexport function createColor(\n context: IContext2d,\n c: string | IColor | Array<string | IColor> | boolean,\n params: { AABBBounds?: IBoundsLike; attribute?: Partial<ITransform> },\n offsetX: number = 0,\n offsetY: number = 0\n): string | CanvasGradient {\n if (!c || c === true) {\n return 'black';\n }\n let result: string | CanvasGradient | undefined;\n let color: string | IColor;\n if (isArray(c)) {\n for (let i = 0; i < c.length; i++) {\n color = c[i];\n if (color) {\n break;\n }\n }\n } else {\n color = c;\n }\n color = GradientParser.Parse(color);\n if (typeof color === 'string') {\n return color;\n }\n // 如果是渐变色的话,需要根据bounds来计算渐变色的范围\n if (params.AABBBounds && (!params.attribute || params.attribute.scaleX !== 0 || params.attribute.scaleY !== 0)) {\n const bounds = params.AABBBounds;\n let w = bounds.x2 - bounds.x1;\n let h = bounds.y2 - bounds.y1;\n let x = bounds.x1 - offsetX;\n let y = bounds.y1 - offsetY;\n // 检测是否有angle、scale,如果有的话,说明context有transform。\n // 需要获取图元原始的bounds宽高,然后设置xy为0才行\n if (params.attribute) {\n const { scaleX = 1, scaleY = 1, angle = 0 } = params.attribute;\n w /= scaleX;\n h /= scaleY;\n x /= scaleX;\n y /= scaleY;\n if (angle || scaleX !== 1 || scaleY !== 1) {\n // symbol的时候锚点是在中间的,所以bounds不能按0算\n x = (params as any).x1WithoutTransform ?? 0;\n y = (params as any).y1WithoutTransform ?? 0;\n w = (params as any).widthWithoutTransform ?? w;\n h = (params as any).heightWithoutTransform ?? h;\n }\n }\n // TODO 不同scaleCenter有问题\n if (color.gradient === 'linear') {\n result = createLinearGradient(context, color, x, y, w, h);\n } else if (color.gradient === 'conical') {\n result = createConicGradient(context, color, x, y, w, h);\n } else if (color.gradient === 'radial') {\n result = createRadialGradient(context, color, x, y, w, h);\n }\n }\n return result || 'orange';\n}\n\nfunction createLinearGradient(context: IContext2d, color: ILinearGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createLinearGradient(\n x + (color.x0 ?? 0) * w,\n y + (color.y0 ?? 0) * h,\n x + (color.x1 ?? 1) * w,\n y + (color.y1 ?? 0) * h\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n return canvasGradient;\n}\n\nfunction createRadialGradient(context: IContext2d, color: IRadialGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createRadialGradient(\n x + (color.x0 ?? 0.5) * w,\n y + (color.y0 ?? 0.5) * h,\n Math.max(w, h) * (color.r0 ?? 0),\n x + (color.x1 ?? 0.5) * w,\n y + (color.y1 ?? 0.5) * h,\n Math.max(w, h) * (color.r1 ?? 0.5)\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n return canvasGradient;\n}\n\nfunction createConicGradient(context: IContext2d, color: IConicalGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createConicGradient(\n x + (color.x ?? 0) * w,\n y + (color.y ?? 0) * h,\n color.startAngle,\n color.endAngle\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n\n let deltaAngle;\n return (canvasGradient as any).GetPattern\n ? (canvasGradient as any).GetPattern(w + x, h + y, deltaAngle)\n : canvasGradient;\n}\n"]}
|
package/cjs/common/polygon.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { IPointLike } from '@visactor/vutils';
|
|
2
2
|
import type { IPath2D } from '../interface';
|
|
3
|
+
type NormalizedPolygonPoints = {
|
|
4
|
+
points: IPointLike[];
|
|
5
|
+
cornerRadius: number | number[];
|
|
6
|
+
};
|
|
3
7
|
export declare function drawPolygon(path: IPath2D, points: IPointLike[], x: number, y: number): void;
|
|
4
8
|
export declare function drawRoundedPolygon(path: IPath2D, points: IPointLike[], x: number, y: number, cornerRadius: number | number[], closePath?: boolean): void;
|
|
9
|
+
export declare function normalizePolygonPoints(points: IPointLike[], cornerRadius: number | number[], closePath?: boolean): NormalizedPolygonPoints | null;
|
|
10
|
+
export declare function getPolygonWinding(points: IPointLike[]): 1 | -1;
|
|
11
|
+
export declare function offsetPolygonPoints(points: IPointLike[], distance: number, closePath?: boolean): IPointLike[];
|
|
12
|
+
export {};
|
package/cjs/common/polygon.js
CHANGED
|
@@ -9,6 +9,8 @@ function drawPolygon(path, points, x, y) {
|
|
|
9
9
|
|
|
10
10
|
function drawRoundedPolygon(path, points, x, y, cornerRadius, closePath = !0) {
|
|
11
11
|
var _a;
|
|
12
|
+
const normalized = normalizePolygonPoints(points, cornerRadius, closePath);
|
|
13
|
+
if (normalized) return void drawRoundedPolygon(path, normalized.points, x, y, normalized.cornerRadius, closePath);
|
|
12
14
|
if (points.length < 3) return void drawPolygon(path, points, x, y);
|
|
13
15
|
let startI = 0, endI = points.length - 1;
|
|
14
16
|
closePath || (startI += 1, endI -= 1, path.moveTo(points[0].x + x, points[0].y + y));
|
|
@@ -41,8 +43,110 @@ function getProportionPoint(point, segment, length, dx, dy) {
|
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
function normalizePolygonPoints(points, cornerRadius, closePath = !0) {
|
|
47
|
+
var _a;
|
|
48
|
+
let hasDuplicate = !1;
|
|
49
|
+
for (let i = 1; i < points.length; i++) if (isSamePoint(points[i - 1], points[i])) {
|
|
50
|
+
hasDuplicate = !0;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (!hasDuplicate && closePath && points.length > 1 && isSamePoint(points[0], points[points.length - 1]) && (hasDuplicate = !0),
|
|
54
|
+
!hasDuplicate) return null;
|
|
55
|
+
const normalizedPoints = [], normalizedCornerRadius = Array.isArray(cornerRadius) ? [] : null;
|
|
56
|
+
for (let i = 0; i < points.length; i++) normalizedPoints.length && isSamePoint(normalizedPoints[normalizedPoints.length - 1], points[i]) || (normalizedPoints.push(points[i]),
|
|
57
|
+
null == normalizedCornerRadius || normalizedCornerRadius.push(null !== (_a = cornerRadius[i]) && void 0 !== _a ? _a : 0));
|
|
58
|
+
return closePath && normalizedPoints.length > 1 && isSamePoint(normalizedPoints[0], normalizedPoints[normalizedPoints.length - 1]) && (normalizedPoints.pop(),
|
|
59
|
+
null == normalizedCornerRadius || normalizedCornerRadius.pop()), {
|
|
60
|
+
points: normalizedPoints,
|
|
61
|
+
cornerRadius: null != normalizedCornerRadius ? normalizedCornerRadius : cornerRadius
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isSamePoint(a, b) {
|
|
66
|
+
return a.x === b.x && a.y === b.y;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getPolygonWinding(points) {
|
|
70
|
+
let signedArea = 0;
|
|
71
|
+
for (let i = 0; i < points.length; i++) {
|
|
72
|
+
const current = points[i], next = points[(i + 1) % points.length];
|
|
73
|
+
signedArea += current.x * next.y - next.x * current.y;
|
|
74
|
+
}
|
|
75
|
+
return signedArea > 0 ? 1 : -1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function offsetPolygonPoints(points, distance, closePath = !0) {
|
|
79
|
+
var _a;
|
|
80
|
+
const n = null !== (_a = null == points ? void 0 : points.length) && void 0 !== _a ? _a : 0;
|
|
81
|
+
if (n < 2 || closePath && n < 3 || !distance) return points;
|
|
82
|
+
const sign = getPolygonWinding(points), edgeCount = closePath ? n : n - 1, lines = [];
|
|
83
|
+
for (let i = 0; i < edgeCount; i++) {
|
|
84
|
+
const cur = points[i], next = points[(i + 1) % n], dx = next.x - cur.x, dy = next.y - cur.y, len = Math.sqrt(dx * dx + dy * dy);
|
|
85
|
+
if (!len) {
|
|
86
|
+
lines.push(null);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const offsetX = sign * dy * distance / len, offsetY = -sign * dx * distance / len;
|
|
90
|
+
lines.push({
|
|
91
|
+
x: cur.x + offsetX,
|
|
92
|
+
y: cur.y + offsetY,
|
|
93
|
+
dx: dx,
|
|
94
|
+
dy: dy,
|
|
95
|
+
len: len,
|
|
96
|
+
offsetX: offsetX,
|
|
97
|
+
offsetY: offsetY
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const prevLines = new Array(n);
|
|
101
|
+
let prevLine = null;
|
|
102
|
+
if (closePath) for (let i = edgeCount - 1; i >= 0; i--) if (lines[i]) {
|
|
103
|
+
prevLine = lines[i];
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
for (let i = 0; i < n; i++) prevLines[i] = prevLine, i < edgeCount && lines[i] && (prevLine = lines[i]);
|
|
107
|
+
const nextLines = new Array(n);
|
|
108
|
+
let nextLine = null;
|
|
109
|
+
if (closePath) for (let count = 0; count < edgeCount; count++) {
|
|
110
|
+
const line = lines[(n - 1 + count) % edgeCount];
|
|
111
|
+
if (line) {
|
|
112
|
+
nextLine = line;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (let i = n - 1; i >= 0; i--) i < edgeCount && lines[i] && (nextLine = lines[i]),
|
|
117
|
+
nextLines[i] = nextLine;
|
|
118
|
+
const offsetPointByLine = (point, line) => ({
|
|
119
|
+
x: point.x + line.offsetX,
|
|
120
|
+
y: point.y + line.offsetY
|
|
121
|
+
}), result = [];
|
|
122
|
+
for (let i = 0; i < n; i++) {
|
|
123
|
+
const prev = prevLines[i], cur = nextLines[i], line = prev || cur;
|
|
124
|
+
if (!line) {
|
|
125
|
+
result.push(points[i]);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!prev || !cur) {
|
|
129
|
+
result.push(offsetPointByLine(points[i], line));
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const denominator = prev.dx * cur.dy - prev.dy * cur.dx;
|
|
133
|
+
if (Math.abs(denominator) <= 1e-12 * prev.len * cur.len) {
|
|
134
|
+
result.push(offsetPointByLine(points[i], cur));
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const t = ((cur.x - prev.x) * cur.dy - (cur.y - prev.y) * cur.dx) / denominator, point = {
|
|
138
|
+
x: prev.x + prev.dx * t,
|
|
139
|
+
y: prev.y + prev.dy * t
|
|
140
|
+
};
|
|
141
|
+
result.push(Number.isFinite(point.x) && Number.isFinite(point.y) ? point : offsetPointByLine(points[i], cur));
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
45
146
|
Object.defineProperty(exports, "__esModule", {
|
|
46
147
|
value: !0
|
|
47
|
-
}), exports.
|
|
48
|
-
exports.drawRoundedPolygon = drawRoundedPolygon
|
|
148
|
+
}), exports.offsetPolygonPoints = exports.getPolygonWinding = exports.normalizePolygonPoints = exports.drawRoundedPolygon = exports.drawPolygon = void 0,
|
|
149
|
+
exports.drawPolygon = drawPolygon, exports.drawRoundedPolygon = drawRoundedPolygon,
|
|
150
|
+
exports.normalizePolygonPoints = normalizePolygonPoints, exports.getPolygonWinding = getPolygonWinding,
|
|
151
|
+
exports.offsetPolygonPoints = offsetPolygonPoints;
|
|
152
|
+
//# sourceMappingURL=polygon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/polygon.ts"],"names":[],"mappings":";;;AAWA,SAAgB,WAAW,CAAC,IAAa,EAAE,MAAoB,EAAE,CAAS,EAAE,CAAS;IACnF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAC7B,OAAO;KACR;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC/C;AACH,CAAC;AARD,kCAQC;AAKD,SAAgB,kBAAkB,CAChC,IAAa,EACb,MAAoB,EACpB,CAAS,EACT,CAAS,EACT,YAA+B,EAC/B,YAAqB,IAAI;;IAEzB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,OAAO;KACR;IAED,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,CAAC,CAAC;QACZ,IAAI,IAAI,CAAC,CAAC;QACV,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CA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vGD,gDAuGC;AAED,SAAS,SAAS,CAAC,EAAU,EAAE,EAAU;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAiB,EAAE,OAAe,EAAE,MAAc,EAAE,EAAU,EAAE,EAAU;IACpG,MAAM,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAEhC,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM;QACxB,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM;KACzB,CAAC;AACJ,CAAC","file":"polygon.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IPath2D } from '../interface';\n\n/**\n * 绘制闭合的常规多边形\n * TODO polygon 图元的xy属性没有意义\n * @param path\n * @param points\n * @param x\n * @param y\n */\nexport function drawPolygon(path: IPath2D, points: IPointLike[], x: number, y: number) {\n if (!points || !points.length) {\n return;\n }\n path.moveTo(points[0].x + x, points[0].y + y);\n for (let i = 1; i < points.length; i++) {\n path.lineTo(points[i].x + x, points[i].y + y);\n }\n}\n\n/**\n * algorithm detail see: https://stackoverflow.com/a/24780108\n */\nexport function drawRoundedPolygon(\n path: IPath2D,\n points: IPointLike[],\n x: number,\n y: number,\n cornerRadius: number | number[],\n closePath: boolean = true\n) {\n if (points.length < 3) {\n drawPolygon(path, points, x, y);\n return;\n }\n\n let startI = 0;\n let endI = points.length - 1;\n if (!closePath) {\n startI += 1;\n endI -= 1;\n path.moveTo(points[0].x + x, points[0].y + y);\n }\n for (let i = startI; i <= endI; i++) {\n const p1 = points[i === 0 ? endI : (i - 1) % points.length];\n const angularPoint = points[i % points.length];\n const p2 = points[(i + 1) % points.length];\n\n //Vector 1\n const dx1 = angularPoint.x - p1.x;\n const dy1 = angularPoint.y - p1.y;\n\n //Vector 2\n const dx2 = angularPoint.x - p2.x;\n const dy2 = angularPoint.y - p2.y;\n\n //Angle between vector 1 and vector 2 divided by 2\n const angle = (Math.atan2(dy1, dx1) - Math.atan2(dy2, dx2)) / 2;\n\n // The length of segment between angular point and the\n // points of intersection with the circle of a given radius\n const tan = Math.abs(Math.tan(angle));\n\n // get config radius\n let radius = Array.isArray(cornerRadius) ? (cornerRadius[i % points.length] ?? 0) : cornerRadius;\n let segment = radius / tan;\n\n //Check the segment\n const length1 = getLength(dx1, dy1);\n const length2 = getLength(dx2, dy2);\n\n const length = Math.min(length1, length2);\n\n if (segment > length) {\n segment = length;\n radius = length * tan;\n }\n\n // Points of intersection are calculated by the proportion between\n // the coordinates of the vector, length of vector and the length of the segment.\n const p1Cross = getProportionPoint(angularPoint, segment, length1, dx1, dy1);\n const p2Cross = getProportionPoint(angularPoint, segment, length2, dx2, dy2);\n\n // Calculation of the coordinates of the circle\n // center by the addition of angular vectors.\n const dx = angularPoint.x * 2 - p1Cross.x - p2Cross.x;\n const dy = angularPoint.y * 2 - p1Cross.y - p2Cross.y;\n\n const L = getLength(dx, dy);\n const d = getLength(segment, radius);\n\n const circlePoint = getProportionPoint(angularPoint, d, L, dx, dy);\n\n //StartAngle and EndAngle of arc\n let startAngle = Math.atan2(p1Cross.y - circlePoint.y, p1Cross.x - circlePoint.x);\n const endAngle = Math.atan2(p2Cross.y - circlePoint.y, p2Cross.x - circlePoint.x);\n\n //Sweep angle\n let sweepAngle = endAngle - startAngle;\n\n //Some additional checks\n if (sweepAngle < 0) {\n startAngle = endAngle;\n sweepAngle = -sweepAngle;\n }\n\n if (sweepAngle > Math.PI) {\n sweepAngle = sweepAngle - Math.PI;\n }\n\n if (i === 0) {\n path.moveTo(p1Cross.x + x, p1Cross.y + y);\n } else {\n path.lineTo(p1Cross.x + x, p1Cross.y + y);\n }\n\n if (sweepAngle) {\n path.arcTo(angularPoint.x + x, angularPoint.y + y, p2Cross.x + x, p2Cross.y + y, radius);\n }\n\n path.lineTo(p2Cross.x + x, p2Cross.y + y);\n }\n\n if (!closePath) {\n path.lineTo(points[endI + 1].x + x, points[endI + 1].y + y);\n }\n}\n\nfunction getLength(dx: number, dy: number) {\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nfunction getProportionPoint(point: IPointLike, segment: number, length: number, dx: number, dy: number) {\n const factor = segment / length;\n\n return {\n x: point.x - dx * factor,\n y: point.y - dy * factor\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/common/polygon.ts"],"names":[],"mappings":";;;AA0BA,SAAgB,WAAW,CAAC,IAAa,EAAE,MAAoB,EAAE,CAAS,EAAE,CAAS;IACnF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAC7B,OAAO;KACR;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC/C;AACH,CAAC;AARD,kCAQC;AAKD,SAAgB,kBAAkB,CAChC,IAAa,EACb,MAAoB,EACpB,CAAS,EACT,CAAS,EACT,YAA+B,EAC/B,YAAqB,IAAI;;IAEzB,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAC3E,IAAI,UAAU,EAAE;QACd,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QACtF,OAAO;KACR;IAED,IAAI,MAAM,CA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G,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;KAC/G;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA7FD,kDA6FC","file":"polygon.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IPath2D } from '../interface';\n\ntype NormalizedPolygonPoints = {\n points: IPointLike[];\n cornerRadius: number | number[];\n};\n\ntype OffsetLine = {\n x: number;\n y: number;\n dx: number;\n dy: number;\n len: number;\n offsetX: number;\n offsetY: number;\n};\n\n/**\n * 绘制闭合的常规多边形\n * TODO polygon 图元的xy属性没有意义\n * @param path\n * @param points\n * @param x\n * @param y\n */\nexport function drawPolygon(path: IPath2D, points: IPointLike[], x: number, y: number) {\n if (!points || !points.length) {\n return;\n }\n path.moveTo(points[0].x + x, points[0].y + y);\n for (let i = 1; i < points.length; i++) {\n path.lineTo(points[i].x + x, points[i].y + y);\n }\n}\n\n/**\n * algorithm detail see: https://stackoverflow.com/a/24780108\n */\nexport function drawRoundedPolygon(\n path: IPath2D,\n points: IPointLike[],\n x: number,\n y: number,\n cornerRadius: number | number[],\n closePath: boolean = true\n) {\n const normalized = normalizePolygonPoints(points, cornerRadius, closePath);\n if (normalized) {\n drawRoundedPolygon(path, normalized.points, x, y, normalized.cornerRadius, closePath);\n return;\n }\n\n if (points.length < 3) {\n drawPolygon(path, points, x, y);\n return;\n }\n\n let startI = 0;\n let endI = points.length - 1;\n if (!closePath) {\n startI += 1;\n endI -= 1;\n path.moveTo(points[0].x + x, points[0].y + y);\n }\n for (let i = startI; i <= endI; i++) {\n const p1 = points[i === 0 ? endI : (i - 1) % points.length];\n const angularPoint = points[i % points.length];\n const p2 = points[(i + 1) % points.length];\n\n //Vector 1\n const dx1 = angularPoint.x - p1.x;\n const dy1 = angularPoint.y - p1.y;\n\n //Vector 2\n const dx2 = angularPoint.x - p2.x;\n const dy2 = angularPoint.y - p2.y;\n\n //Angle between vector 1 and vector 2 divided by 2\n const angle = (Math.atan2(dy1, dx1) - Math.atan2(dy2, dx2)) / 2;\n\n // The length of segment between angular point and the\n // points of intersection with the circle of a given radius\n const tan = Math.abs(Math.tan(angle));\n\n // get config radius\n let radius = Array.isArray(cornerRadius) ? cornerRadius[i % points.length] ?? 0 : cornerRadius;\n let segment = radius / tan;\n\n //Check the segment\n const length1 = getLength(dx1, dy1);\n const length2 = getLength(dx2, dy2);\n\n const length = Math.min(length1, length2);\n\n if (segment > length) {\n segment = length;\n radius = length * tan;\n }\n\n // Points of intersection are calculated by the proportion between\n // the coordinates of the vector, length of vector and the length of the segment.\n const p1Cross = getProportionPoint(angularPoint, segment, length1, dx1, dy1);\n const p2Cross = getProportionPoint(angularPoint, segment, length2, dx2, dy2);\n\n // Calculation of the coordinates of the circle\n // center by the addition of angular vectors.\n const dx = angularPoint.x * 2 - p1Cross.x - p2Cross.x;\n const dy = angularPoint.y * 2 - p1Cross.y - p2Cross.y;\n\n const L = getLength(dx, dy);\n const d = getLength(segment, radius);\n\n const circlePoint = getProportionPoint(angularPoint, d, L, dx, dy);\n\n //StartAngle and EndAngle of arc\n let startAngle = Math.atan2(p1Cross.y - circlePoint.y, p1Cross.x - circlePoint.x);\n const endAngle = Math.atan2(p2Cross.y - circlePoint.y, p2Cross.x - circlePoint.x);\n\n //Sweep angle\n let sweepAngle = endAngle - startAngle;\n\n //Some additional checks\n if (sweepAngle < 0) {\n startAngle = endAngle;\n sweepAngle = -sweepAngle;\n }\n\n if (sweepAngle > Math.PI) {\n sweepAngle = sweepAngle - Math.PI;\n }\n\n if (i === 0) {\n path.moveTo(p1Cross.x + x, p1Cross.y + y);\n } else {\n path.lineTo(p1Cross.x + x, p1Cross.y + y);\n }\n\n if (sweepAngle) {\n path.arcTo(angularPoint.x + x, angularPoint.y + y, p2Cross.x + x, p2Cross.y + y, radius);\n }\n\n path.lineTo(p2Cross.x + x, p2Cross.y + y);\n }\n\n if (!closePath) {\n path.lineTo(points[endI + 1].x + x, points[endI + 1].y + y);\n }\n}\n\nfunction getLength(dx: number, dy: number) {\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nfunction getProportionPoint(point: IPointLike, segment: number, length: number, dx: number, dy: number) {\n const factor = segment / length;\n\n return {\n x: point.x - dx * factor,\n y: point.y - dy * factor\n };\n}\n\n/**\n * 合并连续重复点,避免圆角计算在零长度边上产生 0 / 0。\n * 仅在确实存在退化边时创建新数组,正常绘制路径不增加额外分配。\n */\nexport function normalizePolygonPoints(\n points: IPointLike[],\n cornerRadius: number | number[],\n closePath: boolean = true\n): NormalizedPolygonPoints | null {\n let hasDuplicate = false;\n\n for (let i = 1; i < points.length; i++) {\n if (isSamePoint(points[i - 1], points[i])) {\n hasDuplicate = true;\n break;\n }\n }\n if (!hasDuplicate && closePath && points.length > 1 && isSamePoint(points[0], points[points.length - 1])) {\n hasDuplicate = true;\n }\n if (!hasDuplicate) {\n return null;\n }\n\n const normalizedPoints: IPointLike[] = [];\n const normalizedCornerRadius: number[] | null = Array.isArray(cornerRadius) ? [] : null;\n for (let i = 0; i < points.length; i++) {\n if (normalizedPoints.length && isSamePoint(normalizedPoints[normalizedPoints.length - 1], points[i])) {\n continue;\n }\n normalizedPoints.push(points[i]);\n normalizedCornerRadius?.push((cornerRadius as number[])[i] ?? 0);\n }\n\n if (\n closePath &&\n normalizedPoints.length > 1 &&\n isSamePoint(normalizedPoints[0], normalizedPoints[normalizedPoints.length - 1])\n ) {\n normalizedPoints.pop();\n normalizedCornerRadius?.pop();\n }\n\n return {\n points: normalizedPoints,\n cornerRadius: normalizedCornerRadius ?? cornerRadius\n };\n}\n\nfunction isSamePoint(a: IPointLike, b: IPointLike) {\n return a.x === b.x && a.y === b.y;\n}\n\nexport function getPolygonWinding(points: IPointLike[]) {\n let signedArea = 0;\n for (let i = 0; i < points.length; i++) {\n const current = points[i];\n const next = points[(i + 1) % points.length];\n signedArea += current.x * next.y - next.x * current.y;\n }\n return signedArea > 0 ? 1 : -1;\n}\n\n/**\n * 把多边形的每条边沿法线平移 distance,再用相邻两条平移后的直线求交点得到等距轮廓。\n * distance 为正表示向外扩(outerBorder),为负表示向内缩(innerBorder)。\n * 退化边会被跳过;相邻边共线(求交无解)时使用平移后的原始点,避免边框凹回原轮廓。\n */\nexport function offsetPolygonPoints(points: IPointLike[], distance: number, closePath: boolean = true): IPointLike[] {\n const n = points?.length ?? 0;\n if (n < 2 || (closePath && n < 3) || !distance) {\n return points;\n }\n\n // 用带符号面积判断顶点绕向,保证 distance > 0 时法线一致朝外\n const sign = getPolygonWinding(points);\n\n // 每条边平移后的直线,用点 + 方向表示;开放路径不创建末点到首点的边\n const edgeCount = closePath ? n : n - 1;\n const lines: (OffsetLine | null)[] = [];\n for (let i = 0; i < edgeCount; i++) {\n const cur = points[i];\n const next = points[(i + 1) % n];\n const dx = next.x - cur.x;\n const dy = next.y - cur.y;\n const len = Math.sqrt(dx * dx + dy * dy);\n if (!len) {\n lines.push(null);\n continue;\n }\n const offsetX = (sign * dy * distance) / len;\n const offsetY = (-sign * dx * distance) / len;\n lines.push({ x: cur.x + offsetX, y: cur.y + offsetY, dx, dy, len, offsetX, offsetY });\n }\n\n // 预先找出每个顶点前后的有效边,避免连续退化边导致逐点回溯成 O(n²)\n const prevLines: (OffsetLine | null)[] = new Array(n);\n let prevLine: OffsetLine | null = null;\n if (closePath) {\n for (let i = edgeCount - 1; i >= 0; i--) {\n if (lines[i]) {\n prevLine = lines[i];\n break;\n }\n }\n }\n for (let i = 0; i < n; i++) {\n prevLines[i] = prevLine;\n if (i < edgeCount && lines[i]) {\n prevLine = lines[i];\n }\n }\n\n const nextLines: (OffsetLine | null)[] = new Array(n);\n let nextLine: OffsetLine | null = null;\n if (closePath) {\n for (let count = 0; count < edgeCount; count++) {\n const line = lines[(n - 1 + count) % edgeCount];\n if (line) {\n nextLine = line;\n break;\n }\n }\n }\n for (let i = n - 1; i >= 0; i--) {\n if (i < edgeCount && lines[i]) {\n nextLine = lines[i];\n }\n nextLines[i] = nextLine;\n }\n\n const offsetPointByLine = (point: IPointLike, line: OffsetLine) => ({\n x: point.x + line.offsetX,\n y: point.y + line.offsetY\n });\n\n const result: IPointLike[] = [];\n for (let i = 0; i < n; i++) {\n const prev = prevLines[i];\n const cur = nextLines[i];\n const line = prev || cur;\n if (!line) {\n result.push(points[i]);\n continue;\n }\n if (!prev || !cur) {\n result.push(offsetPointByLine(points[i], line));\n continue;\n }\n\n const denominator = prev.dx * cur.dy - prev.dy * cur.dx;\n if (Math.abs(denominator) <= 1e-12 * prev.len * cur.len) {\n // 平行边没有唯一交点,沿有效边的法线平移原顶点\n result.push(offsetPointByLine(points[i], cur));\n continue;\n }\n const t = ((cur.x - prev.x) * cur.dy - (cur.y - prev.y) * cur.dx) / denominator;\n const point = { x: prev.x + prev.dx * t, y: prev.y + prev.dy * t };\n result.push(Number.isFinite(point.x) && Number.isFinite(point.y) ? point : offsetPointByLine(points[i], cur));\n }\n return result;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IAABBBounds } from '@visactor/vutils';
|
|
2
|
+
import type { IPolygon, IPolygonGraphicAttribute } from '../../interface';
|
|
3
|
+
export declare const getPolygonBoundsScale: (polygon: IPolygon) => number;
|
|
4
|
+
export declare const updateBoundsOfPolygonOuterBorder: (attribute: IPolygonGraphicAttribute, polygonTheme: Required<IPolygonGraphicAttribute>, aabbBounds: IAABBBounds, polygon: IPolygon) => IAABBBounds;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.updateBoundsOfPolygonOuterBorder = exports.getPolygonBoundsScale = void 0;
|
|
6
|
+
|
|
7
|
+
const canvas_utils_1 = require("../../common/canvas-utils"), polygon_1 = require("../../common/polygon"), tools_1 = require("../tools"), getBoundsScaleMatrix = polygon => {
|
|
8
|
+
var _a;
|
|
9
|
+
const globalMatrix = polygon.globalTransMatrix, viewBoxMatrix = null === (_a = polygon.stage) || void 0 === _a ? void 0 : _a.window.getViewBoxTransform();
|
|
10
|
+
return viewBoxMatrix ? {
|
|
11
|
+
a: viewBoxMatrix.a * globalMatrix.a + viewBoxMatrix.c * globalMatrix.b,
|
|
12
|
+
b: viewBoxMatrix.b * globalMatrix.a + viewBoxMatrix.d * globalMatrix.b,
|
|
13
|
+
c: viewBoxMatrix.a * globalMatrix.c + viewBoxMatrix.c * globalMatrix.d,
|
|
14
|
+
d: viewBoxMatrix.b * globalMatrix.c + viewBoxMatrix.d * globalMatrix.d
|
|
15
|
+
} : globalMatrix;
|
|
16
|
+
}, getPolygonBoundsScale = polygon => (0, canvas_utils_1.getScaledStrokeWithMatrix)(getBoundsScaleMatrix(polygon), 1, 1);
|
|
17
|
+
|
|
18
|
+
exports.getPolygonBoundsScale = getPolygonBoundsScale;
|
|
19
|
+
|
|
20
|
+
const updateBoundsOfPolygonOuterBorder = (attribute, polygonTheme, aabbBounds, polygon) => {
|
|
21
|
+
const {outerBorder: outerBorder, points: points = polygonTheme.points, closePath: closePath = polygonTheme.closePath, shadowBlur: shadowBlur = polygonTheme.shadowBlur, keepStrokeScale: keepStrokeScale = polygonTheme.keepStrokeScale} = attribute;
|
|
22
|
+
if (outerBorder && !1 !== outerBorder.visible) {
|
|
23
|
+
const defaultOuterBorder = polygonTheme.outerBorder, {distance: distance = defaultOuterBorder.distance, lineWidth: lineWidth = defaultOuterBorder.lineWidth, lineJoin: lineJoin = defaultOuterBorder.lineJoin, strokeBoundsBuffer: strokeBoundsBuffer = defaultOuterBorder.strokeBoundsBuffer} = outerBorder, boundsScale = (0,
|
|
24
|
+
exports.getPolygonBoundsScale)(polygon);
|
|
25
|
+
let scaledDistance = distance;
|
|
26
|
+
keepStrokeScale || (scaledDistance *= boundsScale), (0, polygon_1.offsetPolygonPoints)(points, scaledDistance, closePath).forEach((point => {
|
|
27
|
+
aabbBounds.add(point.x, point.y);
|
|
28
|
+
}));
|
|
29
|
+
const scaledLineWidth = lineWidth * (keepStrokeScale ? 1 : boundsScale), scaledShadowBlur = shadowBlur * boundsScale;
|
|
30
|
+
(0, tools_1.boundStroke)(aabbBounds, (scaledShadowBlur + scaledLineWidth) / 2, "miter" === lineJoin, strokeBoundsBuffer);
|
|
31
|
+
}
|
|
32
|
+
return aabbBounds;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.updateBoundsOfPolygonOuterBorder = updateBoundsOfPolygonOuterBorder;
|
|
36
|
+
//# sourceMappingURL=polygon-outer-border-bounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graphic/graphic-service/polygon-outer-border-bounds.ts"],"names":[],"mappings":";;;AACA,4DAAsE;AACtE,kDAA2D;AAE3D,oCAAuC;AAIvC,MAAM,oBAAoB,GAAG,CAAC,OAAiB,EAAqB,EAAE;;IACpE,MAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAC/C,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,KAAK,0CAAE,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAClE,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,YAAY,CAAC;KACrB;IACD,OAAO;QACL,CAAC,EAAE,aAAa,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QACtE,CAAC,EAAE,aAAa,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QACtE,CAAC,EAAE,aAAa,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,GAAG,Y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AAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,MAAM,eAAe,GAAG,SAAS,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACxE,MAAM,gBAAgB,GAAG,UAAU,GAAG,WAAW,CAAC;QAClD,IAAA,mBAAW,EAAC,UAAU,EAAE,CAAC,gBAAgB,GAAG,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,KAAK,OAAO,EAAE,kBAAkB,CAAC,CAAC;KAC7G;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AArCW,QAAA,gCAAgC,oCAqC3C","file":"polygon-outer-border-bounds.js","sourcesContent":["import type { IAABBBounds, IMatrixLike } from '@visactor/vutils';\nimport { getScaledStrokeWithMatrix } from '../../common/canvas-utils';\nimport { offsetPolygonPoints } from '../../common/polygon';\nimport type { IPolygon, IPolygonGraphicAttribute } from '../../interface';\nimport { boundStroke } from '../tools';\n\ntype BoundsScaleMatrix = Pick<IMatrixLike, 'a' | 'b' | 'c' | 'd'>;\n\nconst getBoundsScaleMatrix = (polygon: IPolygon): BoundsScaleMatrix => {\n const globalMatrix = polygon.globalTransMatrix;\n const viewBoxMatrix = polygon.stage?.window.getViewBoxTransform();\n if (!viewBoxMatrix) {\n return globalMatrix;\n }\n return {\n a: viewBoxMatrix.a * globalMatrix.a + viewBoxMatrix.c * globalMatrix.b,\n b: viewBoxMatrix.b * globalMatrix.a + viewBoxMatrix.d * globalMatrix.b,\n c: viewBoxMatrix.a * globalMatrix.c + viewBoxMatrix.c * globalMatrix.d,\n d: viewBoxMatrix.b * globalMatrix.c + viewBoxMatrix.d * globalMatrix.d\n };\n};\n\nexport const getPolygonBoundsScale = (polygon: IPolygon): number =>\n getScaledStrokeWithMatrix(getBoundsScaleMatrix(polygon), 1, 1);\n\nexport const updateBoundsOfPolygonOuterBorder = (\n attribute: IPolygonGraphicAttribute,\n polygonTheme: Required<IPolygonGraphicAttribute>,\n aabbBounds: IAABBBounds,\n polygon: IPolygon\n): IAABBBounds => {\n const {\n outerBorder,\n points = polygonTheme.points,\n closePath = polygonTheme.closePath,\n shadowBlur = polygonTheme.shadowBlur,\n keepStrokeScale = polygonTheme.keepStrokeScale\n } = attribute;\n\n if (outerBorder && outerBorder.visible !== false) {\n const defaultOuterBorder = polygonTheme.outerBorder;\n const {\n distance = defaultOuterBorder.distance,\n lineWidth = defaultOuterBorder.lineWidth,\n lineJoin = defaultOuterBorder.lineJoin,\n strokeBoundsBuffer = defaultOuterBorder.strokeBoundsBuffer\n } = outerBorder;\n\n const boundsScale = getPolygonBoundsScale(polygon);\n let scaledDistance = distance as number;\n if (!keepStrokeScale) {\n scaledDistance *= boundsScale;\n }\n offsetPolygonPoints(points, scaledDistance, closePath).forEach(point => {\n aabbBounds.add(point.x, point.y);\n });\n const scaledLineWidth = lineWidth * (keepStrokeScale ? 1 : boundsScale);\n const scaledShadowBlur = shadowBlur * boundsScale;\n boundStroke(aabbBounds, (scaledShadowBlur + scaledLineWidth) / 2, lineJoin === 'miter', strokeBoundsBuffer);\n }\n\n return aabbBounds;\n};\n"]}
|
package/cjs/graphic/graphic.d.ts
CHANGED
|
@@ -142,14 +142,12 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
|
|
|
142
142
|
getAttributes(): T;
|
|
143
143
|
protected getStateTransitionOrchestrator(): StateTransitionOrchestrator<T>;
|
|
144
144
|
protected resolveBoundSharedStateScope(): SharedStateScope<T> | SharedStateScope<Record<string, any>> | undefined;
|
|
145
|
-
protected
|
|
146
|
-
protected
|
|
147
|
-
protected syncSharedStateScopeBindingOnTreeChange(markDirty?: boolean, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): boolean;
|
|
145
|
+
protected syncSharedStateScopeBindingFromTree(markDirty?: boolean): boolean;
|
|
146
|
+
protected syncSharedStateScopeBindingOnTreeChange(markDirty?: boolean): boolean;
|
|
148
147
|
protected syncSharedStateActiveRegistrations(): void;
|
|
149
|
-
protected isSharedStateScopeChainRegistered(previousScopes: Set<SharedStateScope<T>>): boolean;
|
|
150
148
|
protected clearSharedStateActiveRegistrations(): void;
|
|
151
149
|
protected markSharedStateDirty(): void;
|
|
152
|
-
onParentSharedStateTreeChanged(stage?: IStage, layer?: ILayer
|
|
150
|
+
onParentSharedStateTreeChanged(stage?: IStage, layer?: ILayer): void;
|
|
153
151
|
refreshSharedStateBeforeRender(): void;
|
|
154
152
|
protected getLocalStatesVersion(): number;
|
|
155
153
|
protected resolveEffectiveCompiledDefinitions(): {
|
|
@@ -157,7 +155,10 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
|
|
|
157
155
|
};
|
|
158
156
|
protected recomputeCurrentStatePatch(): void;
|
|
159
157
|
protected buildStaticAttributeSnapshot(): Partial<T>;
|
|
160
|
-
protected buildRemovedStateAnimationAttrs(targetStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>):
|
|
158
|
+
protected buildRemovedStateAnimationAttrs(targetStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>): {
|
|
159
|
+
extraAttrs: Partial<T>;
|
|
160
|
+
stateTransitionTargetAttrs: Partial<T>;
|
|
161
|
+
} | undefined;
|
|
161
162
|
protected syncObjectToSnapshot(target: Record<string, any>, snapshot: Record<string, any>, excludedKeys?: ExcludedAttributeKeys): AttributeDelta;
|
|
162
163
|
protected _syncAttribute(excludedKeys?: ExcludedAttributeKeys): AttributeDelta;
|
|
163
164
|
protected _syncFinalAttributeFromStaticTruth(excludedKeys?: ExcludedAttributeKeys): void;
|
|
@@ -239,7 +240,6 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
|
|
|
239
240
|
}): void;
|
|
240
241
|
hasState(stateName?: string): boolean;
|
|
241
242
|
getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
|
|
242
|
-
setStateDefinitionsWithCompiled(definitions: StateDefinitionsInput<T>, compiledDefinitions: Map<string, CompiledStateDefinition<T>>): void;
|
|
243
243
|
protected getStateResolveBaseAttrs(): Partial<T>;
|
|
244
244
|
protected syncStateResolveContext(stateResolveBaseAttrs?: Partial<T>): Partial<T>;
|
|
245
245
|
protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>): StateEngine<T>;
|
|
@@ -261,7 +261,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
|
|
|
261
261
|
protected sameStatePatches(left?: Partial<T>, right?: Partial<T>): boolean;
|
|
262
262
|
protected commitSameStatePatchRefresh(states: string[], hasAnimation?: boolean, animateSameStatePatchChange?: boolean): void;
|
|
263
263
|
protected resolveStateAnimateConfig(animateConfig?: IAnimateConfig): any;
|
|
264
|
-
applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig, extraAnimateAttrs?: Partial<T>): void;
|
|
264
|
+
applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig, extraAnimateAttrs?: Partial<T>, stateTransitionTargetAttrs?: Partial<T>): void;
|
|
265
265
|
updateNormalAttrs(_stateAttrs: Partial<T>): void;
|
|
266
266
|
protected getStateTransitionDefaultAttribute(key: string, targetAttrs?: Partial<T>): any;
|
|
267
267
|
protected shouldSkipStateTransitionDefaultAttribute(_key: string, _targetAttrs?: Partial<T>): boolean;
|
|
@@ -295,7 +295,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
|
|
|
295
295
|
}, resetScale?: boolean): [number, number];
|
|
296
296
|
protected doUpdateLocalMatrix(): void;
|
|
297
297
|
protected doUpdateGlobalMatrix(): void;
|
|
298
|
-
setStage(stage?: IStage, layer?: ILayer
|
|
298
|
+
setStage(stage?: IStage, layer?: ILayer): void;
|
|
299
299
|
detachStageForRelease(): void;
|
|
300
300
|
setStageToShadowRoot(stage?: IStage, layer?: ILayer): void;
|
|
301
301
|
onAddStep(step: IStep): void;
|