@widgetic/canvas 0.5.45 → 0.5.47
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/README.md +3 -2
- package/dist/canvas/DomCanvas.svelte +1 -2
- package/dist/canvas/autosaveScheduler.js +37 -89
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +7 -19
- package/dist/canvas/chromeLayout.js +19 -21
- package/dist/canvas/eventScope.js +10 -14
- package/dist/canvas/host/CanvasHost.d.ts +6 -5
- package/dist/canvas/host/CanvasHost.js +1664 -1861
- package/dist/canvas/host/CanvasHostApi.js +4 -19
- package/dist/canvas/host/boardFiles.js +35 -51
- package/dist/canvas/host/browserServices.js +108 -196
- package/dist/canvas/host/conversion.js +82 -170
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +18 -21
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pauseCollector.d.ts +18 -0
- package/dist/canvas/host/pauseCollector.js +45 -0
- package/dist/canvas/host/pictureSaves.js +9 -11
- package/dist/canvas/host/screenRects.js +28 -31
- package/dist/canvas/host/storedPictures.js +149 -243
- package/dist/canvas/host/strokeSnap.js +88 -143
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +6 -7
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +13 -25
- package/dist/canvas/shapes/ShapeLibrary.js +138 -148
- package/dist/canvas/shapes/shapeImageStore.js +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/types.d.ts +7 -1
- package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
- package/dist/canvas/ui/CanvasHint.svelte +10 -9
- package/dist/canvas/ui/SelectionPanel.svelte +14 -12
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +0 -2
- package/dist/canvas/ui/ShapesMenu.svelte +6 -4
- package/dist/canvas/ui/ToolButton.svelte +7 -6
- package/dist/canvas/ui/colorModel.js +21 -32
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +28 -8
- package/dist/canvas/ui/floatingCard.js +48 -28
- package/dist/canvas/ui/floatingLayer.js +5 -6
- package/dist/canvas/ui/keyHints.js +9 -11
- package/dist/canvas/ui/popoverSide.js +2 -3
- package/dist/canvas/ui/selectionTraits.d.ts +8 -4
- package/dist/canvas/ui/selectionTraits.js +44 -58
- package/dist/canvas/view/CanvasStage.svelte +1 -1
- package/dist/canvas/view/SelectionOverlay.svelte +2 -2
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +72 -91
- package/dist/canvas/view/liftedScene.js +24 -36
- package/dist/canvas/view/mountedScene.js +76 -79
- package/dist/components/CanvasBoardPlaceholder.svelte +68 -10
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +10 -2
- package/dist/components/CanvasToolbarPlaceholder.svelte +25 -11
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +6 -0
- package/dist/components/boardLoaderDelay.d.ts +39 -0
- package/dist/components/boardLoaderDelay.js +71 -0
- package/dist/components/input-controls/ColorIC.svelte +1 -1
- package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +42 -10
- package/dist/engine/EngineCore.js +843 -916
- package/dist/engine/codec/canvasDocument.js +192 -155
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +26 -38
- package/dist/engine/core/arrow.js +79 -92
- package/dist/engine/core/arrowBinding.js +98 -116
- package/dist/engine/core/arrowBindingRecords.js +23 -38
- package/dist/engine/core/brush.d.ts +24 -0
- package/dist/engine/core/brush.js +223 -103
- package/dist/engine/core/cameraMove.js +39 -51
- package/dist/engine/core/defaults.js +92 -51
- package/dist/engine/core/freehand.js +147 -163
- package/dist/engine/core/geometry.js +47 -54
- package/dist/engine/core/history.js +38 -55
- package/dist/engine/core/hitTest.js +68 -81
- package/dist/engine/core/matrix.js +18 -20
- package/dist/engine/core/pathData.js +183 -210
- package/dist/engine/core/rotationReset.js +5 -6
- package/dist/engine/core/scene.js +160 -224
- package/dist/engine/core/scribble.js +59 -84
- package/dist/engine/core/shapePaths.js +12 -15
- package/dist/engine/core/shapeTools.d.ts +23 -18
- package/dist/engine/core/shapeTools.js +104 -67
- package/dist/engine/core/snapping.js +65 -117
- package/dist/engine/core/style.d.ts +18 -2
- package/dist/engine/core/style.js +79 -80
- package/dist/engine/core/styleMemory.d.ts +88 -0
- package/dist/engine/core/styleMemory.js +189 -0
- package/dist/engine/core/transform.js +84 -95
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +23 -36
- package/dist/engine/input/PointerController.js +513 -526
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +8 -3
- package/dist/engine/input/gestures.js +378 -346
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.js +42 -41
- package/dist/engine/input/selectionHandles.js +45 -50
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +86 -158
- package/dist/engine/state.js +6 -17
- package/dist/engine/text/layoutText.js +43 -62
- package/dist/engine/text/textMetrics.js +8 -10
- package/dist/engine/widgets.js +101 -137
- package/dist/fonts/interFont.js +30 -83
- package/dist/fonts/workspaceFonts.js +33 -92
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.js +1 -1
- package/dist/i18n/shortcuts.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/poster/boardPlacement.d.ts +4 -1
- package/dist/poster/boardPlacement.js +34 -33
- package/dist/poster/boardPoster.js +58 -83
- package/dist/poster/paintBoardPoster.js +16 -39
- package/dist/poster/posterPictures.js +27 -43
- package/dist/settings/rememberedStyles.d.ts +22 -0
- package/dist/settings/rememberedStyles.js +47 -0
- package/dist/settings/rememberedTool.d.ts +50 -0
- package/dist/settings/rememberedTool.js +68 -0
- package/dist/settings/workspaceToolSettings.d.ts +25 -0
- package/dist/settings/workspaceToolSettings.js +38 -48
- package/dist/tools/components/catalog.js +64 -74
- package/dist/tools/components/grouping.js +6 -28
- package/dist/tools/definitions.js +5 -5
- package/dist/tools/executors.js +137 -169
- package/dist/tools/hostAdapter.js +10 -13
- package/dist/tools/sceneSummary.js +43 -57
- package/dist/tools/sketchIntent.js +13 -21
- package/dist/tools/styleArguments.js +19 -21
- package/dist/tools/types.js +1 -1
- package/package.json +5 -5
|
@@ -10,30 +10,17 @@
|
|
|
10
10
|
* 'strokeRound' – apply round linecap / linejoin (line-only: check, X, +, -)
|
|
11
11
|
* 'pathRegen' – regenerate sub-shape path data with rounded corners (rects & polygons)
|
|
12
12
|
*/
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
-
if (ar || !(i in from)) {
|
|
16
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
-
ar[i] = from[i];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
-
};
|
|
22
13
|
// ── Path-regen helpers ────────────────────────────────────────────────────────
|
|
23
14
|
/** Generate SVG path data for a rounded rectangle. */
|
|
24
15
|
export function roundedRectPath(x, y, w, h, r) {
|
|
25
16
|
r = Math.min(r, w / 2, h / 2);
|
|
26
|
-
|
|
17
|
+
const x2 = x + w, y2 = y + h;
|
|
27
18
|
return [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"L ".concat(x + r, " ").concat(y2),
|
|
34
|
-
"Q ".concat(x, " ").concat(y2, " ").concat(x, " ").concat(y2 - r),
|
|
35
|
-
"L ".concat(x, " ").concat(y + r),
|
|
36
|
-
"Q ".concat(x, " ").concat(y, " ").concat(x + r, " ").concat(y),
|
|
19
|
+
`M ${x + r} ${y}`,
|
|
20
|
+
`L ${x2 - r} ${y}`, `Q ${x2} ${y} ${x2} ${y + r}`,
|
|
21
|
+
`L ${x2} ${y2 - r}`, `Q ${x2} ${y2} ${x2 - r} ${y2}`,
|
|
22
|
+
`L ${x + r} ${y2}`, `Q ${x} ${y2} ${x} ${y2 - r}`,
|
|
23
|
+
`L ${x} ${y + r}`, `Q ${x} ${y} ${x + r} ${y}`,
|
|
37
24
|
'Z',
|
|
38
25
|
].join(' ');
|
|
39
26
|
}
|
|
@@ -44,35 +31,35 @@ export function roundedRectPath(x, y, w, h, r) {
|
|
|
44
31
|
*/
|
|
45
32
|
export function roundedPolygonPath(points, r) {
|
|
46
33
|
if (r <= 0) {
|
|
47
|
-
return (points.map(
|
|
34
|
+
return (points.map((p, i) => `${i === 0 ? 'M' : 'L'} ${p[0]} ${p[1]}`).join(' ') + ' Z');
|
|
48
35
|
}
|
|
49
|
-
|
|
36
|
+
const n = points.length;
|
|
50
37
|
// Cap r to 45% of the shortest edge to stay inside the polygon
|
|
51
|
-
|
|
52
|
-
for (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
minEdge =
|
|
38
|
+
let minEdge = Infinity;
|
|
39
|
+
for (let i = 0; i < n; i++) {
|
|
40
|
+
const a = points[i], b = points[(i + 1) % n];
|
|
41
|
+
const d = Math.sqrt((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2);
|
|
42
|
+
if (d < minEdge)
|
|
43
|
+
minEdge = d;
|
|
57
44
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
const rClamped = Math.min(r, minEdge * 0.45);
|
|
46
|
+
let d = '';
|
|
47
|
+
for (let i = 0; i < n; i++) {
|
|
48
|
+
const prev = points[(i - 1 + n) % n];
|
|
49
|
+
const curr = points[i];
|
|
50
|
+
const next = points[(i + 1) % n];
|
|
64
51
|
// Unit vectors from corner toward its neighbours
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
const pLen = Math.sqrt((prev[0] - curr[0]) ** 2 + (prev[1] - curr[1]) ** 2) || 1;
|
|
53
|
+
const nLen = Math.sqrt((next[0] - curr[0]) ** 2 + (next[1] - curr[1]) ** 2) || 1;
|
|
54
|
+
const pn = [(prev[0] - curr[0]) / pLen, (prev[1] - curr[1]) / pLen];
|
|
55
|
+
const nn = [(next[0] - curr[0]) / nLen, (next[1] - curr[1]) / nLen];
|
|
69
56
|
// Points along each edge, distance rClamped from the corner vertex
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
const p1 = [curr[0] + pn[0] * rClamped, curr[1] + pn[1] * rClamped];
|
|
58
|
+
const p2 = [curr[0] + nn[0] * rClamped, curr[1] + nn[1] * rClamped];
|
|
72
59
|
d += i === 0
|
|
73
|
-
?
|
|
74
|
-
:
|
|
75
|
-
d +=
|
|
60
|
+
? `M ${p1[0].toFixed(2)} ${p1[1].toFixed(2)} `
|
|
61
|
+
: `L ${p1[0].toFixed(2)} ${p1[1].toFixed(2)} `;
|
|
62
|
+
d += `Q ${curr[0]} ${curr[1]} ${p2[0].toFixed(2)} ${p2[1].toFixed(2)} `;
|
|
76
63
|
}
|
|
77
64
|
return d + 'Z';
|
|
78
65
|
}
|
|
@@ -85,21 +72,21 @@ export function generatePathForShape(shape, roundnessPercent) {
|
|
|
85
72
|
// regenData. Each L-command corner and the two C-to-L junctions are rounded individually
|
|
86
73
|
// using Quadratic Bezier arcs so the entire shape looks smooth at high roundness values.
|
|
87
74
|
if (shape.key === 'curved-arrow') {
|
|
88
|
-
|
|
89
|
-
if (
|
|
75
|
+
const t = (roundnessPercent / 100) * 8; // max 8-unit radius at 100%
|
|
76
|
+
if (t < 0.1)
|
|
90
77
|
return null;
|
|
91
78
|
// Round a corner at (cx,cy): px/py is the INCOMING reference point, nx/ny is OUTGOING.
|
|
92
79
|
// For C commands use the adjacent control point as the reference direction.
|
|
93
80
|
// Returns { s: arcStart, e: arcEnd } strings for "…s Q cx cy e…" insertion.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
const rc = (px, py, cx, cy, nx, ny) => {
|
|
82
|
+
const dx1 = px - cx, dy1 = py - cy;
|
|
83
|
+
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1) || 1;
|
|
84
|
+
const dx2 = nx - cx, dy2 = ny - cy;
|
|
85
|
+
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2) || 1;
|
|
86
|
+
const r = Math.min(t, l1 * 0.45, l2 * 0.45);
|
|
100
87
|
return {
|
|
101
|
-
s:
|
|
102
|
-
e:
|
|
88
|
+
s: `${(cx + dx1 / l1 * r).toFixed(1)} ${(cy + dy1 / l1 * r).toFixed(1)}`,
|
|
89
|
+
e: `${(cx + dx2 / l2 * r).toFixed(1)} ${(cy + dy2 / l2 * r).toFixed(1)}`,
|
|
103
90
|
};
|
|
104
91
|
};
|
|
105
92
|
// Corners with reference points for tangent direction:
|
|
@@ -123,23 +110,23 @@ export function generatePathForShape(shape, roundnessPercent) {
|
|
|
123
110
|
// — c0_e scales with t: at t=0 → M=(80,20) = exact original path; at t=8 → M=(85.7,25.7).
|
|
124
111
|
// The Q arc from (80,25) Q(80,20) to c0_e smoothly rounds the top corner with up to 8px
|
|
125
112
|
// effective radius on the outgoing side, while the shape stays correct at any % level.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
113
|
+
const r0 = Math.min(t, 21.2 * 0.45); // cap only by first-L edge length (21.2px × 0.45)
|
|
114
|
+
const c0_s = '80.0 25.0'; // original C endpoint — Z-line start, never moves
|
|
115
|
+
const c0_dirX = 15 / 21.2, c0_dirY = 15 / 21.2; // unit direction (80,20)→(95,35)
|
|
116
|
+
const c0_e = `${(80 + c0_dirX * r0).toFixed(1)} ${(20 + c0_dirY * r0).toFixed(1)}`;
|
|
117
|
+
const c1 = rc(80, 20, 95, 35, 80, 50); // arrowhead tip
|
|
118
|
+
const c2 = rc(95, 35, 80, 50, 80, 40); // outer lower arrowhead wing
|
|
119
|
+
const c3 = rc(80, 50, 80, 40, 50, 40); // inner shoulder (L→C, use C cp1 as direction)
|
|
120
|
+
const c4 = rc(30, 55, 30, 80, 15, 80); // C-to-L junction (C cp2 as incoming direction)
|
|
121
|
+
const c5 = rc(30, 80, 15, 80, 15, 45); // tail end (L→C, use C cp1 as direction)
|
|
135
122
|
return [
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
123
|
+
`M ${c0_e}`, // start at c0 arc end (Z closes back here)
|
|
124
|
+
`L ${c1.s} Q 95 35 ${c1.e}`, // arrowhead tip
|
|
125
|
+
`L ${c2.s} Q 80 50 ${c2.e}`, // outer lower arrowhead wing
|
|
126
|
+
`L ${c3.s} Q 80 40 ${c3.e}`, // inner shoulder
|
|
127
|
+
`C 50 40 30 55 ${c4.s} Q 30 80 ${c4.e}`, // curve body + C→L junction
|
|
128
|
+
`L ${c5.s} Q 15 80 ${c5.e}`, // tail end
|
|
129
|
+
`C 15 45 40 25 ${c0_s} Q 80 20 ${c0_e} Z`, // return C (endpoint unchanged) + M arc
|
|
143
130
|
].join(' ');
|
|
144
131
|
}
|
|
145
132
|
// ── Shield: quadratic-arc rounding of 5 angular corners, bezier bottom preserved ──
|
|
@@ -147,23 +134,22 @@ export function generatePathForShape(shape, roundnessPercent) {
|
|
|
147
134
|
// Corners: P0=(50,5) P1=(90,20) P2=(90,55) P4=(10,55) P5=(10,20)
|
|
148
135
|
// At 0%, returns null so the original pathData is used exactly (no shape change).
|
|
149
136
|
if (shape.key === 'shield') {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (
|
|
137
|
+
const maxT = 10; // max arc radius in path units at 100% roundness
|
|
138
|
+
const t = (roundnessPercent / 100) * maxT;
|
|
139
|
+
if (t < 0.1)
|
|
153
140
|
return null;
|
|
154
141
|
// rc: quadratic bezier arc at (cx,cy), optional tMax clamps radius for corners
|
|
155
142
|
// adjacent to bezier curves to limit distortion of the bezier endpoints.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var r = Math.min(tEff, l1 * 0.45, l2 * 0.45);
|
|
143
|
+
const rc2 = (px, py, cx, cy, nx, ny, tMax = t) => {
|
|
144
|
+
const tEff = Math.min(t, tMax);
|
|
145
|
+
const dx1 = px - cx, dy1 = py - cy;
|
|
146
|
+
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1) || 1;
|
|
147
|
+
const dx2 = nx - cx, dy2 = ny - cy;
|
|
148
|
+
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2) || 1;
|
|
149
|
+
const r = Math.min(tEff, l1 * 0.45, l2 * 0.45);
|
|
164
150
|
return {
|
|
165
|
-
s:
|
|
166
|
-
e:
|
|
151
|
+
s: `${(cx + dx1 / l1 * r).toFixed(1)} ${(cy + dy1 / l1 * r).toFixed(1)}`,
|
|
152
|
+
e: `${(cx + dx2 / l2 * r).toFixed(1)} ${(cy + dy2 / l2 * r).toFixed(1)}`,
|
|
167
153
|
};
|
|
168
154
|
};
|
|
169
155
|
// c0: top point (50,5) — prev is (10,20) via Z-line, next is (90,20)
|
|
@@ -173,59 +159,59 @@ export function generatePathForShape(shape, roundnessPercent) {
|
|
|
173
159
|
// the last cp of C1 (70,90) and the first cp of C2 (30,90)
|
|
174
160
|
// c4: left side base (10,55) — limited tMax=4 to minimize bezier bottom distortion
|
|
175
161
|
// c5: top-left shoulder (10,20) — prev (10,55), next (50,5)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
162
|
+
const c0 = rc2(10, 20, 50, 5, 90, 20);
|
|
163
|
+
const c1 = rc2(50, 5, 90, 20, 90, 55);
|
|
164
|
+
const c2 = rc2(90, 20, 90, 55, 90, 75, 4); // cap arc size near bezier
|
|
165
|
+
const c3 = rc2(70, 90, 50, 95, 30, 90, 6); // bottom point (bezier junction, cap=6)
|
|
166
|
+
const c4 = rc2(10, 75, 10, 55, 10, 20, 4); // cap arc size near bezier
|
|
167
|
+
const c5 = rc2(10, 55, 10, 20, 50, 5);
|
|
182
168
|
// The top corner arc (c0) is placed LAST, just before Z, so the path visits:
|
|
183
169
|
// M(c0.e) → c1 arc → c2 arc → bezier1 (shortened to c3.s) → c3 Q arc →
|
|
184
170
|
// bezier2 (from c3.e, shortened) → c4 arc → c5 arc → c0 arc → Z
|
|
185
171
|
return [
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
172
|
+
`M ${c0.e}`, // start past top-point toward P1
|
|
173
|
+
`L ${c1.s} Q 90 20 ${c1.e}`, // arc at top-right shoulder
|
|
174
|
+
`L ${c2.s} Q 90 55 ${c2.e}`, // arc at right base (limited radius)
|
|
175
|
+
`C 90 75 70 90 ${c3.s}`, // bottom-right bezier, shortened to c3 arc entry
|
|
176
|
+
`Q 50 95 ${c3.e}`, // arc at bottom point
|
|
177
|
+
`C 30 90 10 75 ${c4.s}`, // bottom-left bezier, shortened to c4 arc entry
|
|
178
|
+
`Q 10 55 ${c4.e}`, // arc at left base (limited radius)
|
|
179
|
+
`L ${c5.s} Q 10 20 ${c5.e}`, // arc at top-left shoulder
|
|
180
|
+
`L ${c0.s} Q 50 5 ${c0.e}`, // arc at top point
|
|
181
|
+
`Z`, // zero-distance close back to M (c0.e)
|
|
196
182
|
].join(' ');
|
|
197
183
|
}
|
|
198
184
|
if (shape.cornerRadiusMode !== 'pathRegen' || !shape.regenData)
|
|
199
185
|
return null;
|
|
200
|
-
return shape.regenData.map(
|
|
186
|
+
return shape.regenData.map(sub => {
|
|
201
187
|
if (sub.type === 'fixed')
|
|
202
188
|
return sub.path;
|
|
203
189
|
if (sub.type === 'rect') {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return roundedRectPath(sub.x, sub.y, sub.w, sub.h,
|
|
190
|
+
const maxR = Math.min(sub.w, sub.h) / 2;
|
|
191
|
+
const r = (roundnessPercent / 100) * maxR;
|
|
192
|
+
return roundedRectPath(sub.x, sub.y, sub.w, sub.h, r);
|
|
207
193
|
}
|
|
208
194
|
// polygon
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
for (
|
|
213
|
-
|
|
214
|
-
minEdge = Math.min(minEdge, Math.sqrt(
|
|
195
|
+
const pts = sub.points;
|
|
196
|
+
const n = pts.length;
|
|
197
|
+
let minEdge = Infinity;
|
|
198
|
+
for (let i = 0; i < n; i++) {
|
|
199
|
+
const a = pts[i], b = pts[(i + 1) % n];
|
|
200
|
+
minEdge = Math.min(minEdge, Math.sqrt((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2));
|
|
215
201
|
}
|
|
216
|
-
|
|
217
|
-
|
|
202
|
+
const maxR = minEdge * 0.45;
|
|
203
|
+
const r = (roundnessPercent / 100) * maxR;
|
|
218
204
|
return roundedPolygonPath(pts, r);
|
|
219
205
|
}).join(' ');
|
|
220
206
|
}
|
|
221
207
|
// ── Geometric Shapes (library) ─────────────────────────────────────────────
|
|
222
|
-
|
|
208
|
+
const GEOMETRIC_SHAPES = [
|
|
223
209
|
{
|
|
224
210
|
key: 'hexagon',
|
|
225
211
|
labelKey: 'canvas.shape.hexagon',
|
|
226
212
|
category: 'Geometric Shapes',
|
|
227
213
|
pathData: 'M 50 3 L 93 27 L 93 73 L 50 97 L 7 73 L 7 27 Z',
|
|
228
|
-
iconSvg:
|
|
214
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2 21.5,7 21.5,17 12,22 2.5,17 2.5,7" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
229
215
|
cornerRadiusMode: 'pathRegen',
|
|
230
216
|
regenData: [
|
|
231
217
|
{ type: 'polygon', points: [[50, 3], [93, 27], [93, 73], [50, 97], [7, 73], [7, 27]] },
|
|
@@ -237,7 +223,7 @@ var GEOMETRIC_SHAPES = [
|
|
|
237
223
|
labelKey: 'canvas.shape.pentagon',
|
|
238
224
|
category: 'Geometric Shapes',
|
|
239
225
|
pathData: 'M 50 4 L 95.6 37.2 L 78.2 90.8 L 21.8 90.8 L 4.4 37.2 Z',
|
|
240
|
-
iconSvg:
|
|
226
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2.5 21.5,9.4 17.9,20.6 6.1,20.6 2.5,9.4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
241
227
|
cornerRadiusMode: 'pathRegen',
|
|
242
228
|
regenData: [
|
|
243
229
|
{ type: 'polygon', points: [[50, 4], [95.6, 37.2], [78.2, 90.8], [21.8, 90.8], [4.4, 37.2]] },
|
|
@@ -251,19 +237,19 @@ var GEOMETRIC_SHAPES = [
|
|
|
251
237
|
// Capsule/stadium shape: wide rounded rect with max corner radius (half the height).
|
|
252
238
|
// 160×90 content area, corner radius = 45 (half of 90). Produces semicircle caps like a pill.
|
|
253
239
|
pathData: 'M 50 5 L 110 5 Q 155 5 155 50 L 155 50 Q 155 95 110 95 L 50 95 Q 5 95 5 50 L 5 50 Q 5 5 50 5 Z',
|
|
254
|
-
iconSvg:
|
|
240
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="7" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
255
241
|
cornerRadiusMode: 'none',
|
|
256
242
|
lockAspectRatio: false,
|
|
257
243
|
},
|
|
258
244
|
];
|
|
259
245
|
// ── Media Icons ──────────────────────────────────────────────────────────────
|
|
260
|
-
|
|
246
|
+
const MEDIA_SHAPES = [
|
|
261
247
|
{
|
|
262
248
|
key: 'play',
|
|
263
249
|
labelKey: 'canvas.shape.play',
|
|
264
250
|
category: 'Media Icons',
|
|
265
251
|
pathData: 'M 10 5 L 10 95 L 90 50 Z',
|
|
266
|
-
iconSvg:
|
|
252
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="5,3 5,21 20,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
267
253
|
cornerRadiusMode: 'pathRegen',
|
|
268
254
|
regenData: [
|
|
269
255
|
{ type: 'polygon', points: [[10, 5], [10, 95], [90, 50]] },
|
|
@@ -274,7 +260,7 @@ var MEDIA_SHAPES = [
|
|
|
274
260
|
labelKey: 'canvas.shape.pause',
|
|
275
261
|
category: 'Media Icons',
|
|
276
262
|
pathData: 'M 15 5 L 15 95 L 35 95 L 35 5 Z M 65 5 L 65 95 L 85 95 L 85 5 Z',
|
|
277
|
-
iconSvg:
|
|
263
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="14" y="4" width="4" height="16" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
278
264
|
cornerRadiusMode: 'pathRegen',
|
|
279
265
|
regenData: [
|
|
280
266
|
{ type: 'rect', x: 15, y: 5, w: 20, h: 90 },
|
|
@@ -286,7 +272,7 @@ var MEDIA_SHAPES = [
|
|
|
286
272
|
labelKey: 'canvas.shape.stop',
|
|
287
273
|
category: 'Media Icons',
|
|
288
274
|
pathData: 'M 10 10 L 10 90 L 90 90 L 90 10 Z',
|
|
289
|
-
iconSvg:
|
|
275
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="5" y="5" width="14" height="14" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
290
276
|
cornerRadiusMode: 'pathRegen',
|
|
291
277
|
regenData: [
|
|
292
278
|
{ type: 'rect', x: 10, y: 10, w: 80, h: 80 },
|
|
@@ -297,7 +283,7 @@ var MEDIA_SHAPES = [
|
|
|
297
283
|
labelKey: 'canvas.shape.rewind',
|
|
298
284
|
category: 'Media Icons',
|
|
299
285
|
pathData: 'M 50 5 L 50 95 L 5 50 Z M 95 5 L 95 95 L 50 50 Z',
|
|
300
|
-
iconSvg:
|
|
286
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,3 12,21 3,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><polygon points="21,3 21,21 12,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
301
287
|
cornerRadiusMode: 'pathRegen',
|
|
302
288
|
regenData: [
|
|
303
289
|
{ type: 'polygon', points: [[50, 5], [50, 95], [5, 50]] },
|
|
@@ -309,7 +295,7 @@ var MEDIA_SHAPES = [
|
|
|
309
295
|
labelKey: 'canvas.shape.fastForward',
|
|
310
296
|
category: 'Media Icons',
|
|
311
297
|
pathData: 'M 5 5 L 5 95 L 50 50 Z M 50 5 L 50 95 L 95 50 Z',
|
|
312
|
-
iconSvg:
|
|
298
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="3,3 3,21 12,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><polygon points="12,3 12,21 21,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
313
299
|
cornerRadiusMode: 'pathRegen',
|
|
314
300
|
regenData: [
|
|
315
301
|
{ type: 'polygon', points: [[5, 5], [5, 95], [50, 50]] },
|
|
@@ -322,18 +308,18 @@ var MEDIA_SHAPES = [
|
|
|
322
308
|
category: 'Media Icons',
|
|
323
309
|
// Already a circle — no corner rounding needed
|
|
324
310
|
pathData: 'M 50 5 A 45 45 0 1 1 49.999 5 Z',
|
|
325
|
-
iconSvg:
|
|
311
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><circle cx="12" cy="12" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
326
312
|
cornerRadiusMode: 'none',
|
|
327
313
|
},
|
|
328
314
|
];
|
|
329
315
|
// ── Arrow Shapes ─────────────────────────────────────────────────────────────
|
|
330
|
-
|
|
316
|
+
const ARROW_SHAPES = [
|
|
331
317
|
{
|
|
332
318
|
key: 'arrow-right',
|
|
333
319
|
labelKey: 'canvas.shape.arrowRight',
|
|
334
320
|
category: 'Arrow Shapes',
|
|
335
321
|
pathData: 'M 5 40 L 65 40 L 65 20 L 95 50 L 65 80 L 65 60 L 5 60 Z',
|
|
336
|
-
iconSvg:
|
|
322
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M5 12 H19 M13 6 L19 12 L13 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
337
323
|
cornerRadiusMode: 'pathRegen',
|
|
338
324
|
regenData: [{ type: 'polygon', points: [[5, 40], [65, 40], [65, 20], [95, 50], [65, 80], [65, 60], [5, 60]] }],
|
|
339
325
|
},
|
|
@@ -342,7 +328,7 @@ var ARROW_SHAPES = [
|
|
|
342
328
|
labelKey: 'canvas.shape.arrowLeft',
|
|
343
329
|
category: 'Arrow Shapes',
|
|
344
330
|
pathData: 'M 95 40 L 35 40 L 35 20 L 5 50 L 35 80 L 35 60 L 95 60 Z',
|
|
345
|
-
iconSvg:
|
|
331
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M19 12 H5 M11 6 L5 12 L11 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
346
332
|
cornerRadiusMode: 'pathRegen',
|
|
347
333
|
regenData: [{ type: 'polygon', points: [[95, 40], [35, 40], [35, 20], [5, 50], [35, 80], [35, 60], [95, 60]] }],
|
|
348
334
|
},
|
|
@@ -351,7 +337,7 @@ var ARROW_SHAPES = [
|
|
|
351
337
|
labelKey: 'canvas.shape.arrowUp',
|
|
352
338
|
category: 'Arrow Shapes',
|
|
353
339
|
pathData: 'M 40 95 L 40 35 L 20 35 L 50 5 L 80 35 L 60 35 L 60 95 Z',
|
|
354
|
-
iconSvg:
|
|
340
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 19 V5 M6 11 L12 5 L18 11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
355
341
|
cornerRadiusMode: 'pathRegen',
|
|
356
342
|
regenData: [{ type: 'polygon', points: [[40, 95], [40, 35], [20, 35], [50, 5], [80, 35], [60, 35], [60, 95]] }],
|
|
357
343
|
},
|
|
@@ -360,7 +346,7 @@ var ARROW_SHAPES = [
|
|
|
360
346
|
labelKey: 'canvas.shape.arrowDown',
|
|
361
347
|
category: 'Arrow Shapes',
|
|
362
348
|
pathData: 'M 60 5 L 60 65 L 80 65 L 50 95 L 20 65 L 40 65 L 40 5 Z',
|
|
363
|
-
iconSvg:
|
|
349
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 5 V19 M6 13 L12 19 L18 13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
364
350
|
cornerRadiusMode: 'pathRegen',
|
|
365
351
|
regenData: [{ type: 'polygon', points: [[60, 5], [60, 65], [80, 65], [50, 95], [20, 65], [40, 65], [40, 5]] }],
|
|
366
352
|
},
|
|
@@ -369,7 +355,7 @@ var ARROW_SHAPES = [
|
|
|
369
355
|
labelKey: 'canvas.shape.doubleArrow',
|
|
370
356
|
category: 'Arrow Shapes',
|
|
371
357
|
pathData: 'M 30 20 L 5 50 L 30 80 L 30 62 L 70 62 L 70 80 L 95 50 L 70 20 L 70 38 L 30 38 Z',
|
|
372
|
-
iconSvg:
|
|
358
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M7 12 H17 M5 8 L1 12 L5 16 M19 8 L23 12 L19 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
373
359
|
cornerRadiusMode: 'pathRegen',
|
|
374
360
|
regenData: [{ type: 'polygon', points: [[30, 20], [5, 50], [30, 80], [30, 62], [70, 62], [70, 80], [95, 50], [70, 20], [70, 38], [30, 38]] }],
|
|
375
361
|
},
|
|
@@ -382,20 +368,20 @@ var ARROW_SHAPES = [
|
|
|
382
368
|
// because it clips the bounding box, cutting off arrowhead tips at high roundness.
|
|
383
369
|
// strokeRound was avoided because it only affects the stroke outline, not the fill corners.
|
|
384
370
|
pathData: 'M 80 20 L 95 35 L 80 50 L 80 40 C 50 40 30 55 30 80 L 15 80 C 15 45 40 25 80 25 Z',
|
|
385
|
-
iconSvg:
|
|
371
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M17 4 L21 8 L17 12 M21 8 C15 8 9 11 9 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
386
372
|
cornerRadiusMode: 'pathRegen',
|
|
387
373
|
// regenData is intentionally omitted — generatePathForShape handles this shape directly.
|
|
388
374
|
},
|
|
389
375
|
];
|
|
390
376
|
// ── UI Icons ─────────────────────────────────────────────────────────────────
|
|
391
|
-
|
|
377
|
+
const UI_ICON_SHAPES = [
|
|
392
378
|
{
|
|
393
379
|
key: 'check',
|
|
394
380
|
labelKey: 'canvas.shape.checkMark',
|
|
395
381
|
category: 'UI Icons',
|
|
396
382
|
// Open path — round by setting strokeLineCap/strokeLineJoin
|
|
397
383
|
pathData: 'M 5 55 L 35 85 L 95 15',
|
|
398
|
-
iconSvg:
|
|
384
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M4 13 L9 18 L20 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
399
385
|
cornerRadiusMode: 'strokeRound',
|
|
400
386
|
},
|
|
401
387
|
{
|
|
@@ -403,7 +389,7 @@ var UI_ICON_SHAPES = [
|
|
|
403
389
|
labelKey: 'canvas.shape.cross',
|
|
404
390
|
category: 'UI Icons',
|
|
405
391
|
pathData: 'M 10 10 L 90 90 M 90 10 L 10 90',
|
|
406
|
-
iconSvg:
|
|
392
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M5 5 L19 19 M19 5 L5 19" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
|
|
407
393
|
cornerRadiusMode: 'strokeRound',
|
|
408
394
|
},
|
|
409
395
|
{
|
|
@@ -411,7 +397,7 @@ var UI_ICON_SHAPES = [
|
|
|
411
397
|
labelKey: 'canvas.shape.plus',
|
|
412
398
|
category: 'UI Icons',
|
|
413
399
|
pathData: 'M 50 10 L 50 90 M 10 50 L 90 50',
|
|
414
|
-
iconSvg:
|
|
400
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 5 V19 M5 12 H19" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
|
|
415
401
|
cornerRadiusMode: 'strokeRound',
|
|
416
402
|
},
|
|
417
403
|
{
|
|
@@ -419,7 +405,7 @@ var UI_ICON_SHAPES = [
|
|
|
419
405
|
labelKey: 'canvas.shape.minus',
|
|
420
406
|
category: 'UI Icons',
|
|
421
407
|
pathData: 'M 10 50 L 90 50',
|
|
422
|
-
iconSvg:
|
|
408
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M5 12 H19" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
|
|
423
409
|
cornerRadiusMode: 'strokeRound',
|
|
424
410
|
},
|
|
425
411
|
{
|
|
@@ -428,7 +414,7 @@ var UI_ICON_SHAPES = [
|
|
|
428
414
|
category: 'UI Icons',
|
|
429
415
|
// Outer circle is already curved — no corner rounding
|
|
430
416
|
pathData: 'M 50 5 A 45 45 0 1 1 49.999 5 Z M 50 30 L 50 32 M 50 42 L 50 72',
|
|
431
|
-
iconSvg:
|
|
417
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M12 8 V8.5 M12 11 V16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
|
|
432
418
|
cornerRadiusMode: 'none',
|
|
433
419
|
},
|
|
434
420
|
{
|
|
@@ -437,7 +423,7 @@ var UI_ICON_SHAPES = [
|
|
|
437
423
|
category: 'UI Icons',
|
|
438
424
|
// Outer triangle + inner ! lines (inner lines kept fixed)
|
|
439
425
|
pathData: 'M 50 5 L 95 90 L 5 90 Z M 50 40 L 50 60 M 50 70 L 50 72',
|
|
440
|
-
iconSvg:
|
|
426
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 3 L22 20 H2 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M12 10 V14 M12 17 V17.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
|
|
441
427
|
cornerRadiusMode: 'pathRegen',
|
|
442
428
|
regenData: [
|
|
443
429
|
{ type: 'polygon', points: [[50, 5], [95, 90], [5, 90]] },
|
|
@@ -446,13 +432,13 @@ var UI_ICON_SHAPES = [
|
|
|
446
432
|
},
|
|
447
433
|
];
|
|
448
434
|
// ── Symbol Shapes ─────────────────────────────────────────────────────────────
|
|
449
|
-
|
|
435
|
+
const SYMBOL_SHAPES = [
|
|
450
436
|
{
|
|
451
437
|
key: 'star',
|
|
452
438
|
labelKey: 'canvas.shape.star',
|
|
453
439
|
category: 'Symbol Shapes',
|
|
454
440
|
pathData: 'M 50 5 L 61 35 L 95 35 L 68 57 L 79 91 L 50 70 L 21 91 L 32 57 L 5 35 L 39 35 Z',
|
|
455
|
-
iconSvg:
|
|
441
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
456
442
|
// pathRegen rounds each polygon corner individually (outer tips + inner concave vertices)
|
|
457
443
|
cornerRadiusMode: 'pathRegen',
|
|
458
444
|
regenData: [
|
|
@@ -465,7 +451,7 @@ var SYMBOL_SHAPES = [
|
|
|
465
451
|
category: 'Symbol Shapes',
|
|
466
452
|
// Already curved — no corner rounding
|
|
467
453
|
pathData: 'M 50 85 C 5 55 5 20 25 15 C 35 12 45 17 50 25 C 55 17 65 12 75 15 C 95 20 95 55 50 85 Z',
|
|
468
|
-
iconSvg:
|
|
454
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 21C12 21 3 14 3 8.5A4.5 4.5 0 0 1 12 6.5 4.5 4.5 0 0 1 21 8.5C21 14 12 21 12 21Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
469
455
|
cornerRadiusMode: 'none',
|
|
470
456
|
},
|
|
471
457
|
{
|
|
@@ -473,7 +459,7 @@ var SYMBOL_SHAPES = [
|
|
|
473
459
|
labelKey: 'canvas.shape.speechBubble',
|
|
474
460
|
category: 'Symbol Shapes',
|
|
475
461
|
pathData: 'M 10 10 L 10 65 L 35 65 L 50 90 L 65 65 L 90 65 L 90 10 Z',
|
|
476
|
-
iconSvg:
|
|
462
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M4 4 H20 A2 2 0 0 1 22 6 V15 A2 2 0 0 1 20 17 H9 L4 21 V17 A2 2 0 0 1 2 15 V6 A2 2 0 0 1 4 4 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
477
463
|
// pathRegen rounds box corners; the tail corner also softens slightly
|
|
478
464
|
cornerRadiusMode: 'pathRegen',
|
|
479
465
|
regenData: [
|
|
@@ -487,7 +473,7 @@ var SYMBOL_SHAPES = [
|
|
|
487
473
|
labelKey: 'canvas.shape.rhombus',
|
|
488
474
|
category: 'Symbol Shapes',
|
|
489
475
|
pathData: 'M 50 5 L 95 50 L 50 95 L 5 50 Z',
|
|
490
|
-
iconSvg:
|
|
476
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2 22,12 12,22 2,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
491
477
|
cornerRadiusMode: 'pathRegen',
|
|
492
478
|
regenData: [
|
|
493
479
|
{ type: 'polygon', points: [[50, 5], [95, 50], [50, 95], [5, 50]] },
|
|
@@ -499,7 +485,7 @@ var SYMBOL_SHAPES = [
|
|
|
499
485
|
labelKey: 'canvas.shape.lightning',
|
|
500
486
|
category: 'Symbol Shapes',
|
|
501
487
|
pathData: 'M 55 5 L 20 52 L 45 52 L 38 95 L 80 42 L 55 42 Z',
|
|
502
|
-
iconSvg:
|
|
488
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M13 2 L5 13 H11 L9 22 L19 9 H13 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
503
489
|
cornerRadiusMode: 'pathRegen',
|
|
504
490
|
regenData: [
|
|
505
491
|
{ type: 'polygon', points: [[55, 5], [20, 52], [45, 52], [38, 95], [80, 42], [55, 42]] },
|
|
@@ -511,20 +497,26 @@ var SYMBOL_SHAPES = [
|
|
|
511
497
|
labelKey: 'canvas.shape.shield',
|
|
512
498
|
category: 'Symbol Shapes',
|
|
513
499
|
pathData: 'M 50 5 L 90 20 L 90 55 C 90 75 70 90 50 95 C 30 90 10 75 10 55 L 10 20 Z',
|
|
514
|
-
iconSvg:
|
|
500
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 3 L20 7 V13 C20 17.5 16.5 21 12 22 C7.5 21 4 17.5 4 13 V7 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
515
501
|
cornerRadiusMode: 'pathRegen',
|
|
516
502
|
lockAspectRatio: false,
|
|
517
503
|
},
|
|
518
504
|
];
|
|
519
505
|
/** All library shapes, grouped by category (Geometric first, then Arrows) */
|
|
520
|
-
export
|
|
506
|
+
export const SHAPE_LIBRARY = [
|
|
507
|
+
...GEOMETRIC_SHAPES,
|
|
508
|
+
...ARROW_SHAPES,
|
|
509
|
+
...MEDIA_SHAPES,
|
|
510
|
+
...UI_ICON_SHAPES,
|
|
511
|
+
...SYMBOL_SHAPES,
|
|
512
|
+
];
|
|
521
513
|
/**
|
|
522
514
|
* Keyed shape index: single canonical id→shape lookup, built once at module
|
|
523
515
|
* load. Replaces the repeated `SHAPE_LIBRARY.find(s => s.key === ...)`
|
|
524
516
|
* linear scans across Canvas.svelte. Keys are unique by construction
|
|
525
517
|
* (categories partition the array); a duplicate would be an authoring bug.
|
|
526
518
|
*/
|
|
527
|
-
|
|
519
|
+
const SHAPE_LIBRARY_BY_KEY = new Map(SHAPE_LIBRARY.map(shape => [shape.key, shape]));
|
|
528
520
|
/**
|
|
529
521
|
* Look up a library shape definition by its stable key.
|
|
530
522
|
* Returns undefined for unknown keys (dynamic/legacy shape keys).
|
|
@@ -536,11 +528,9 @@ export function getShapeByKey(key) {
|
|
|
536
528
|
}
|
|
537
529
|
/** Shapes grouped by category for rendering in the UI */
|
|
538
530
|
export function getShapesByCategory() {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
var shape = SHAPE_LIBRARY_1[_i];
|
|
543
|
-
var existing = (_a = map.get(shape.category)) !== null && _a !== void 0 ? _a : [];
|
|
531
|
+
const map = new Map();
|
|
532
|
+
for (const shape of SHAPE_LIBRARY) {
|
|
533
|
+
const existing = map.get(shape.category) ?? [];
|
|
544
534
|
existing.push(shape);
|
|
545
535
|
map.set(shape.category, existing);
|
|
546
536
|
}
|