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