@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,13 +2,17 @@ import { isArray } from "@visactor/vutils";
|
|
|
2
2
|
|
|
3
3
|
import { GradientParser } from "./color-utils";
|
|
4
4
|
|
|
5
|
-
export function
|
|
5
|
+
export function getScaledStrokeWithMatrix(matrix, width, dpr) {
|
|
6
6
|
let strokeWidth = width;
|
|
7
|
-
const {a: a, b: b, c: c, d: d} =
|
|
7
|
+
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);
|
|
8
8
|
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr,
|
|
9
9
|
strokeWidth);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export function getScaledStroke(context, width, dpr) {
|
|
13
|
+
return getScaledStrokeWithMatrix(context.currentMatrix, width, dpr);
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
export function createColor(context, c, params, offsetX = 0, offsetY = 0) {
|
|
13
17
|
var _a, _b, _c, _d;
|
|
14
18
|
if (!c || !0 === c) return "black";
|
|
@@ -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,OAAO,EAAE,OAAO,EAAsC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,UAAU,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,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,IAAI,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,CAAC,CAAC;KACV;IACD,WAAW,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAClE,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAmB,EAAE,KAAa,EAAE,GAAW;IAC7E,OAA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GAAG,CAAC,MAAA,KAAK,CAAC,EAAE,mCAAI,GAAG,CAAC,CACnC,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACzB,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAmB,EAAE,KAAuB,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;;IACnH,MAAM,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAChD,CAAC,GAAG,CAAC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,EACtB,CAAC,GAAG,CAAC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,EACtB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,CACf,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACzB,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,IAAI,UAAU,CAAC;IACf,OAAQ,cAAsB,CAAC,UAAU;QACvC,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/es/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/es/common/polygon.js
CHANGED
|
@@ -7,6 +7,8 @@ export function drawPolygon(path, points, x, y) {
|
|
|
7
7
|
|
|
8
8
|
export function drawRoundedPolygon(path, points, x, y, cornerRadius, closePath = !0) {
|
|
9
9
|
var _a;
|
|
10
|
+
const normalized = normalizePolygonPoints(points, cornerRadius, closePath);
|
|
11
|
+
if (normalized) return void drawRoundedPolygon(path, normalized.points, x, y, normalized.cornerRadius, closePath);
|
|
10
12
|
if (points.length < 3) return void drawPolygon(path, points, x, y);
|
|
11
13
|
let startI = 0, endI = points.length - 1;
|
|
12
14
|
closePath || (startI += 1, endI -= 1, path.moveTo(points[0].x + x, points[0].y + y));
|
|
@@ -38,4 +40,104 @@ function getProportionPoint(point, segment, length, dx, dy) {
|
|
|
38
40
|
y: point.y - dy * factor
|
|
39
41
|
};
|
|
40
42
|
}
|
|
43
|
+
|
|
44
|
+
export function normalizePolygonPoints(points, cornerRadius, closePath = !0) {
|
|
45
|
+
var _a;
|
|
46
|
+
let hasDuplicate = !1;
|
|
47
|
+
for (let i = 1; i < points.length; i++) if (isSamePoint(points[i - 1], points[i])) {
|
|
48
|
+
hasDuplicate = !0;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
if (!hasDuplicate && closePath && points.length > 1 && isSamePoint(points[0], points[points.length - 1]) && (hasDuplicate = !0),
|
|
52
|
+
!hasDuplicate) return null;
|
|
53
|
+
const normalizedPoints = [], normalizedCornerRadius = Array.isArray(cornerRadius) ? [] : null;
|
|
54
|
+
for (let i = 0; i < points.length; i++) normalizedPoints.length && isSamePoint(normalizedPoints[normalizedPoints.length - 1], points[i]) || (normalizedPoints.push(points[i]),
|
|
55
|
+
null == normalizedCornerRadius || normalizedCornerRadius.push(null !== (_a = cornerRadius[i]) && void 0 !== _a ? _a : 0));
|
|
56
|
+
return closePath && normalizedPoints.length > 1 && isSamePoint(normalizedPoints[0], normalizedPoints[normalizedPoints.length - 1]) && (normalizedPoints.pop(),
|
|
57
|
+
null == normalizedCornerRadius || normalizedCornerRadius.pop()), {
|
|
58
|
+
points: normalizedPoints,
|
|
59
|
+
cornerRadius: null != normalizedCornerRadius ? normalizedCornerRadius : cornerRadius
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isSamePoint(a, b) {
|
|
64
|
+
return a.x === b.x && a.y === b.y;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function getPolygonWinding(points) {
|
|
68
|
+
let signedArea = 0;
|
|
69
|
+
for (let i = 0; i < points.length; i++) {
|
|
70
|
+
const current = points[i], next = points[(i + 1) % points.length];
|
|
71
|
+
signedArea += current.x * next.y - next.x * current.y;
|
|
72
|
+
}
|
|
73
|
+
return signedArea > 0 ? 1 : -1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function offsetPolygonPoints(points, distance, closePath = !0) {
|
|
77
|
+
var _a;
|
|
78
|
+
const n = null !== (_a = null == points ? void 0 : points.length) && void 0 !== _a ? _a : 0;
|
|
79
|
+
if (n < 2 || closePath && n < 3 || !distance) return points;
|
|
80
|
+
const sign = getPolygonWinding(points), edgeCount = closePath ? n : n - 1, lines = [];
|
|
81
|
+
for (let i = 0; i < edgeCount; i++) {
|
|
82
|
+
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);
|
|
83
|
+
if (!len) {
|
|
84
|
+
lines.push(null);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const offsetX = sign * dy * distance / len, offsetY = -sign * dx * distance / len;
|
|
88
|
+
lines.push({
|
|
89
|
+
x: cur.x + offsetX,
|
|
90
|
+
y: cur.y + offsetY,
|
|
91
|
+
dx: dx,
|
|
92
|
+
dy: dy,
|
|
93
|
+
len: len,
|
|
94
|
+
offsetX: offsetX,
|
|
95
|
+
offsetY: offsetY
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const prevLines = new Array(n);
|
|
99
|
+
let prevLine = null;
|
|
100
|
+
if (closePath) for (let i = edgeCount - 1; i >= 0; i--) if (lines[i]) {
|
|
101
|
+
prevLine = lines[i];
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
for (let i = 0; i < n; i++) prevLines[i] = prevLine, i < edgeCount && lines[i] && (prevLine = lines[i]);
|
|
105
|
+
const nextLines = new Array(n);
|
|
106
|
+
let nextLine = null;
|
|
107
|
+
if (closePath) for (let count = 0; count < edgeCount; count++) {
|
|
108
|
+
const line = lines[(n - 1 + count) % edgeCount];
|
|
109
|
+
if (line) {
|
|
110
|
+
nextLine = line;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (let i = n - 1; i >= 0; i--) i < edgeCount && lines[i] && (nextLine = lines[i]),
|
|
115
|
+
nextLines[i] = nextLine;
|
|
116
|
+
const offsetPointByLine = (point, line) => ({
|
|
117
|
+
x: point.x + line.offsetX,
|
|
118
|
+
y: point.y + line.offsetY
|
|
119
|
+
}), result = [];
|
|
120
|
+
for (let i = 0; i < n; i++) {
|
|
121
|
+
const prev = prevLines[i], cur = nextLines[i], line = prev || cur;
|
|
122
|
+
if (!line) {
|
|
123
|
+
result.push(points[i]);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!prev || !cur) {
|
|
127
|
+
result.push(offsetPointByLine(points[i], line));
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const denominator = prev.dx * cur.dy - prev.dy * cur.dx;
|
|
131
|
+
if (Math.abs(denominator) <= 1e-12 * prev.len * cur.len) {
|
|
132
|
+
result.push(offsetPointByLine(points[i], cur));
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const t = ((cur.x - prev.x) * cur.dy - (cur.y - prev.y) * cur.dx) / denominator, point = {
|
|
136
|
+
x: prev.x + prev.dx * t,
|
|
137
|
+
y: prev.y + prev.dy * t
|
|
138
|
+
};
|
|
139
|
+
result.push(Number.isFinite(point.x) && Number.isFinite(point.y) ? point : offsetPointByLine(points[i], cur));
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
41
143
|
//# sourceMappingURL=polygon.js.map
|
package/es/common/polygon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/polygon.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,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,C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,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;SAC1F;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC3C;IAED,IAAI,CAAC,SAAS,EAAE;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC7D;AACH,CAAC;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,MAAM,UAAU,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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AAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC/C,SAAS;SACV;QACD,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;QAChF,MAAM,KAAK,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,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","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,32 @@
|
|
|
1
|
+
import { getScaledStrokeWithMatrix } from "../../common/canvas-utils";
|
|
2
|
+
|
|
3
|
+
import { offsetPolygonPoints } from "../../common/polygon";
|
|
4
|
+
|
|
5
|
+
import { boundStroke } from "../tools";
|
|
6
|
+
|
|
7
|
+
const 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
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getPolygonBoundsScale = polygon => getScaledStrokeWithMatrix(getBoundsScaleMatrix(polygon), 1, 1);
|
|
19
|
+
|
|
20
|
+
export 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 = getPolygonBoundsScale(polygon);
|
|
24
|
+
let scaledDistance = distance;
|
|
25
|
+
keepStrokeScale || (scaledDistance *= boundsScale), offsetPolygonPoints(points, scaledDistance, closePath).forEach((point => {
|
|
26
|
+
aabbBounds.add(point.x, point.y);
|
|
27
|
+
}));
|
|
28
|
+
boundStroke(aabbBounds, (shadowBlur * boundsScale + lineWidth * (keepStrokeScale ? 1 : boundsScale)) / 2, "miter" === lineJoin, strokeBoundsBuffer);
|
|
29
|
+
}
|
|
30
|
+
return aabbBounds;
|
|
31
|
+
};
|
|
32
|
+
//# 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,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;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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AAkB,CAAC;QACxC,IAAI,CAAC,eAAe,EAAE;YACpB,cAAc,IAAI,WAAW,CAAC;SAC/B;QACD,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACrE,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,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,WAAW,CAAC,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","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/es/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;
|
package/es/graphic/graphic.js
CHANGED
|
@@ -181,8 +181,9 @@ class GraphicImpl extends Node {
|
|
|
181
181
|
}
|
|
182
182
|
return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
syncSharedStateScopeBindingFromTree(markDirty = !0) {
|
|
185
185
|
var _a;
|
|
186
|
+
const nextScope = this.resolveBoundSharedStateScope();
|
|
186
187
|
return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(),
|
|
187
188
|
!1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0,
|
|
188
189
|
this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
|
|
@@ -190,13 +191,9 @@ class GraphicImpl extends Node {
|
|
|
190
191
|
markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(),
|
|
191
192
|
!0);
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
-
const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
|
|
195
|
-
return this.syncSharedStateScopeBinding(nextScope, markDirty);
|
|
196
|
-
}
|
|
197
|
-
syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
|
|
194
|
+
syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
|
|
198
195
|
var _a, _b;
|
|
199
|
-
return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty
|
|
196
|
+
return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty);
|
|
200
197
|
}
|
|
201
198
|
syncSharedStateActiveRegistrations() {
|
|
202
199
|
var _a;
|
|
@@ -204,7 +201,6 @@ class GraphicImpl extends Node {
|
|
|
204
201
|
if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach((scope => {
|
|
205
202
|
scope.subtreeActiveDescendants.delete(this);
|
|
206
203
|
})), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
|
|
207
|
-
if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
|
|
208
204
|
const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
|
|
209
205
|
null == previousScopes || previousScopes.forEach((scope => {
|
|
210
206
|
nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
|
|
@@ -212,14 +208,6 @@ class GraphicImpl extends Node {
|
|
|
212
208
|
scope.subtreeActiveDescendants.add(this);
|
|
213
209
|
})), this.registeredActiveScopes = nextScopes;
|
|
214
210
|
}
|
|
215
|
-
isSharedStateScopeChainRegistered(previousScopes) {
|
|
216
|
-
let scope = this.boundSharedStateScope, scopeCount = 0;
|
|
217
|
-
for (;scope; ) {
|
|
218
|
-
if (!previousScopes.has(scope)) return !1;
|
|
219
|
-
scopeCount += 1, scope = scope.parentScope;
|
|
220
|
-
}
|
|
221
|
-
return scopeCount === previousScopes.size;
|
|
222
|
-
}
|
|
223
211
|
clearSharedStateActiveRegistrations() {
|
|
224
212
|
const previousScopes = this.registeredActiveScopes;
|
|
225
213
|
previousScopes && (previousScopes.forEach((scope => {
|
|
@@ -230,8 +218,8 @@ class GraphicImpl extends Node {
|
|
|
230
218
|
this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this),
|
|
231
219
|
scheduleStageSharedStateRefresh(this.stage);
|
|
232
220
|
}
|
|
233
|
-
onParentSharedStateTreeChanged(stage, layer
|
|
234
|
-
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(
|
|
221
|
+
onParentSharedStateTreeChanged(stage, layer) {
|
|
222
|
+
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
|
|
235
223
|
}
|
|
236
224
|
refreshSharedStateBeforeRender() {
|
|
237
225
|
var _a;
|
|
@@ -283,20 +271,19 @@ class GraphicImpl extends Node {
|
|
|
283
271
|
})), snapshot) : snapshot;
|
|
284
272
|
}
|
|
285
273
|
buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
|
|
274
|
+
if (!previousResolvedStatePatch) return;
|
|
275
|
+
const snapshot = this.buildStaticAttributeSnapshot(), extraAttrs = {};
|
|
289
276
|
return Object.keys(previousResolvedStatePatch).forEach((key => {
|
|
290
277
|
const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
|
|
291
278
|
if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
|
|
292
279
|
const assignFallbackAttr = value => {
|
|
293
|
-
|
|
280
|
+
extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value);
|
|
294
281
|
};
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
282
|
+
hasTargetAttr ? assignFallbackAttr(targetStateAttrs[key]) : Object.prototype.hasOwnProperty.call(snapshot, key) ? assignFallbackAttr(snapshot[key]) : assignFallbackAttr(void 0);
|
|
283
|
+
})), {
|
|
284
|
+
extraAttrs: extraAttrs,
|
|
285
|
+
stateTransitionTargetAttrs: snapshot
|
|
286
|
+
};
|
|
300
287
|
}
|
|
301
288
|
syncObjectToSnapshot(target, snapshot, excludedKeys) {
|
|
302
289
|
const delta = new Map;
|
|
@@ -874,12 +861,6 @@ class GraphicImpl extends Node {
|
|
|
874
861
|
var _a;
|
|
875
862
|
return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
876
863
|
}
|
|
877
|
-
setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
|
|
878
|
-
var _a;
|
|
879
|
-
this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions,
|
|
880
|
-
this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
|
|
881
|
-
this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
|
|
882
|
-
}
|
|
883
864
|
getStateResolveBaseAttrs() {
|
|
884
865
|
var _a;
|
|
885
866
|
return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
@@ -997,32 +978,38 @@ class GraphicImpl extends Node {
|
|
|
997
978
|
commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
|
|
998
979
|
var _a;
|
|
999
980
|
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, {transition: transition, effectiveStates: effectiveStates, resolvedStateAttrs: resolvedStateAttrs} = this.resolveGraphicStateTransition(states, !0), patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
|
|
1000
|
-
patchChanged
|
|
981
|
+
if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states,
|
|
1001
982
|
this.effectiveStates = [ ...effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
|
|
1002
|
-
this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged
|
|
1003
|
-
|
|
1004
|
-
|
|
983
|
+
this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged)) if (hasAnimation && animateSameStatePatchChange) {
|
|
984
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
985
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
986
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
987
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1005
988
|
type: AttributeUpdateType.STATE
|
|
1006
989
|
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
1007
990
|
type: AttributeUpdateType.STATE
|
|
1008
|
-
}), this.emitStateUpdateEvent()
|
|
991
|
+
}), this.emitStateUpdateEvent();
|
|
1009
992
|
}
|
|
1010
993
|
resolveStateAnimateConfig(animateConfig) {
|
|
1011
994
|
var _a, _b, _c;
|
|
1012
995
|
return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : DefaultStateAnimateConfig;
|
|
1013
996
|
}
|
|
1014
|
-
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
|
|
997
|
+
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs, stateTransitionTargetAttrs) {
|
|
1015
998
|
const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
|
|
1016
999
|
animateConfig: resolvedAnimateConfig,
|
|
1017
1000
|
extraAnimateAttrs: extraAnimateAttrs,
|
|
1018
|
-
|
|
1001
|
+
getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
|
|
1002
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
|
|
1003
|
+
stateTransitionTargetAttrs: stateTransitionTargetAttrs
|
|
1019
1004
|
} : void 0;
|
|
1020
1005
|
if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, transitionOptions);
|
|
1021
1006
|
const plan = this.getStateTransitionOrchestrator().analyzeTransition(attrs, hasAnimation, {
|
|
1022
1007
|
noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
|
|
1023
1008
|
animateConfig: resolvedAnimateConfig,
|
|
1024
1009
|
extraAnimateAttrs: extraAnimateAttrs,
|
|
1025
|
-
|
|
1010
|
+
getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
|
|
1011
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
|
|
1012
|
+
stateTransitionTargetAttrs: stateTransitionTargetAttrs
|
|
1026
1013
|
});
|
|
1027
1014
|
this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
|
|
1028
1015
|
}
|
|
@@ -1049,15 +1036,17 @@ class GraphicImpl extends Node {
|
|
|
1049
1036
|
this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
|
|
1050
1037
|
void this.clearSharedStateActiveRegistrations();
|
|
1051
1038
|
const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
|
|
1052
|
-
transition.changed
|
|
1039
|
+
if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states,
|
|
1053
1040
|
this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
|
|
1054
|
-
this.clearSharedStateActiveRegistrations(), hasAnimation
|
|
1055
|
-
|
|
1056
|
-
|
|
1041
|
+
this.clearSharedStateActiveRegistrations(), hasAnimation) {
|
|
1042
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
1043
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
1044
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
1045
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1057
1046
|
type: AttributeUpdateType.STATE
|
|
1058
1047
|
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
|
|
1059
1048
|
type: AttributeUpdateType.STATE
|
|
1060
|
-
}), this.emitStateUpdateEvent()
|
|
1049
|
+
}), this.emitStateUpdateEvent();
|
|
1061
1050
|
}
|
|
1062
1051
|
removeState(stateName, hasAnimation) {
|
|
1063
1052
|
const transition = this.resolveRemoveStateTransition(stateName);
|
|
@@ -1086,15 +1075,17 @@ class GraphicImpl extends Node {
|
|
|
1086
1075
|
var _a;
|
|
1087
1076
|
if (!states.length) return void this.clearStates(hasAnimation);
|
|
1088
1077
|
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, {transition: transition, effectiveStates: effectiveStates, resolvedStateAttrs: resolvedStateAttrs} = this.resolveGraphicStateTransition(states);
|
|
1089
|
-
|
|
1078
|
+
if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states,
|
|
1090
1079
|
this.effectiveStates = [ ...effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
|
|
1091
|
-
this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation
|
|
1092
|
-
|
|
1093
|
-
|
|
1080
|
+
this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation) {
|
|
1081
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
1082
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
1083
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
1084
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
1094
1085
|
type: AttributeUpdateType.STATE
|
|
1095
1086
|
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
1096
1087
|
type: AttributeUpdateType.STATE
|
|
1097
|
-
}), this.emitStateUpdateEvent()
|
|
1088
|
+
}), this.emitStateUpdateEvent();
|
|
1098
1089
|
}
|
|
1099
1090
|
invalidateResolver() {
|
|
1100
1091
|
var _a, _b;
|
|
@@ -1204,11 +1195,11 @@ class GraphicImpl extends Node {
|
|
|
1204
1195
|
this._globalTransMatrix.translate(scrollX, scrollY);
|
|
1205
1196
|
}
|
|
1206
1197
|
}
|
|
1207
|
-
setStage(stage, layer
|
|
1198
|
+
setStage(stage, layer) {
|
|
1208
1199
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1209
1200
|
const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService, previousStage = this.stage;
|
|
1210
1201
|
if (this.stage !== stage || this.layer !== layer) {
|
|
1211
|
-
if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0
|
|
1202
|
+
if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0),
|
|
1212
1203
|
this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
|
|
1213
1204
|
const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage), nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage), detachedStageAnimates = [];
|
|
1214
1205
|
this.visitTrackedAnimates((a => {
|
|
@@ -1226,7 +1217,7 @@ class GraphicImpl extends Node {
|
|
|
1226
1217
|
}
|
|
1227
1218
|
return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_h = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _h || _h.call(graphicService, this, stage));
|
|
1228
1219
|
}
|
|
1229
|
-
((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0
|
|
1220
|
+
((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0);
|
|
1230
1221
|
}
|
|
1231
1222
|
detachStageForRelease() {
|
|
1232
1223
|
var _a, _b, _c;
|