morphico 0.4.0 → 0.6.0

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.
Files changed (77) hide show
  1. package/README.md +147 -63
  2. package/dist/esm/all.js +50 -0
  3. package/dist/esm/clip.js +285 -0
  4. package/dist/esm/engine.js +25 -0
  5. package/dist/esm/face.js +152 -0
  6. package/dist/esm/geometry.js +459 -0
  7. package/dist/esm/icon.js +41 -0
  8. package/dist/esm/index.js +51 -0
  9. package/dist/esm/morph.js +107 -0
  10. package/dist/esm/roundness.js +37 -0
  11. package/dist/esm/sets/battery.js +87 -0
  12. package/dist/esm/sets/bell.js +101 -0
  13. package/dist/esm/sets/characters.js +64 -0
  14. package/dist/esm/sets/check-mark.js +74 -0
  15. package/dist/esm/sets/checkbox.js +91 -0
  16. package/dist/esm/sets/chevron.js +70 -0
  17. package/dist/esm/sets/condensed.js +138 -0
  18. package/dist/esm/sets/copy.js +87 -0
  19. package/dist/esm/sets/eye.js +105 -0
  20. package/dist/esm/sets/faces.js +482 -0
  21. package/dist/esm/sets/folder.js +112 -0
  22. package/dist/esm/sets/handwritten.js +137 -0
  23. package/dist/esm/sets/lock.js +75 -0
  24. package/dist/esm/sets/lucide.js +66 -0
  25. package/dist/esm/sets/media.js +109 -0
  26. package/dist/esm/sets/menu.js +84 -0
  27. package/dist/esm/sets/mic.js +102 -0
  28. package/dist/esm/sets/radio.js +84 -0
  29. package/dist/esm/sets/round.js +245 -0
  30. package/dist/esm/sets/shapes.js +461 -0
  31. package/dist/esm/sets/slim.js +149 -0
  32. package/dist/esm/sets/square.js +150 -0
  33. package/dist/esm/sets/symbols.js +154 -0
  34. package/dist/esm/sets/theme.js +107 -0
  35. package/dist/esm/sets/toggle.js +73 -0
  36. package/dist/esm/sets/volume.js +89 -0
  37. package/dist/esm/sets/weather.js +691 -0
  38. package/dist/esm/sets/wifi.js +68 -0
  39. package/dist/esm/svg.js +31 -0
  40. package/dist/esm/text.js +89 -0
  41. package/dist/esm/types.js +3 -0
  42. package/dist/morphico.js +3991 -3787
  43. package/dist/types/{iconSets.d.ts → all.d.ts} +0 -2
  44. package/dist/types/clip.d.ts +8 -18
  45. package/dist/types/face.d.ts +2 -6
  46. package/dist/types/icon.d.ts +6 -11
  47. package/dist/types/index.d.ts +4 -5
  48. package/dist/types/morph.d.ts +3 -3
  49. package/dist/types/roundness.d.ts +8 -0
  50. package/dist/types/sets/battery.d.ts +1 -1
  51. package/dist/types/sets/bell.d.ts +1 -1
  52. package/dist/types/sets/characters.d.ts +3 -2
  53. package/dist/types/sets/checkbox.d.ts +1 -1
  54. package/dist/types/sets/chevron.d.ts +1 -1
  55. package/dist/types/sets/condensed.d.ts +1 -1
  56. package/dist/types/sets/copy.d.ts +1 -1
  57. package/dist/types/sets/eye.d.ts +1 -1
  58. package/dist/types/sets/folder.d.ts +1 -1
  59. package/dist/types/sets/handwritten.d.ts +1 -1
  60. package/dist/types/sets/lock.d.ts +1 -1
  61. package/dist/types/sets/media.d.ts +1 -1
  62. package/dist/types/sets/menu.d.ts +1 -1
  63. package/dist/types/sets/mic.d.ts +1 -1
  64. package/dist/types/sets/radio.d.ts +1 -1
  65. package/dist/types/sets/round.d.ts +1 -1
  66. package/dist/types/sets/shapes.d.ts +4 -1
  67. package/dist/types/sets/slim.d.ts +1 -1
  68. package/dist/types/sets/square.d.ts +1 -1
  69. package/dist/types/sets/symbols.d.ts +38 -0
  70. package/dist/types/sets/theme.d.ts +1 -1
  71. package/dist/types/sets/toggle.d.ts +1 -1
  72. package/dist/types/sets/volume.d.ts +1 -1
  73. package/dist/types/sets/weather.d.ts +1 -1
  74. package/dist/types/sets/wifi.d.ts +1 -1
  75. package/dist/types/text.d.ts +9 -20
  76. package/package.json +95 -3
  77. package/dist/morphico.mjs +0 -4642
@@ -0,0 +1,37 @@
1
+ /*! morphico v0.6.0 | MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE) */
2
+ const setsByRoundness = new WeakMap();
3
+ /** The set, optionally with sharper corners (`roundness` 0 = sharp … 1 = its own). */
4
+ export const resolveIconSet = (iconSet, roundness) => {
5
+ if (roundness === undefined || roundness >= 1)
6
+ return iconSet; // the own corners are the roundest
7
+ if (!iconSet.withRoundness)
8
+ throw new Error('morphico: this icon set has no adjustable roundness');
9
+ const clamped = Math.max(0, roundness);
10
+ let byRoundness = setsByRoundness.get(iconSet);
11
+ if (!byRoundness)
12
+ setsByRoundness.set(iconSet, byRoundness = new Map());
13
+ let sharper = byRoundness.get(clamped);
14
+ if (!sharper)
15
+ byRoundness.set(clamped, sharper = iconSet.withRoundness(clamped));
16
+ return sharper;
17
+ };
18
+ /** The `set` option checked: a set object (names like `'weather'` were accepted before 0.5.0 — say what to do now). */
19
+ export const checkedIconSet = (set, functionName) => {
20
+ if (typeof set === 'string') {
21
+ const capitalized = `${set.charAt(0).toUpperCase()}${set.slice(1)}`;
22
+ const exportName = ['round', 'square', 'condensed', 'slim', 'handwritten'].includes(set) ? `digits${capitalized}` : `icons${capitalized}`;
23
+ throw new Error(`morphico: ${functionName}() takes the set itself, not its name — import it: import { ${exportName} } from 'morphico/sets/${set}'`);
24
+ }
25
+ if (!set || typeof set !== 'object' || !('strokes' in set)) {
26
+ throw new Error(`morphico: ${functionName}() needs a set, e.g. import { digitsRound } from 'morphico/sets/round'`);
27
+ }
28
+ return set;
29
+ };
30
+ /** The second argument: what is shown first. Before 0.5.0 the options came second (with the first state inside) — say
31
+ * so instead of failing somewhere deeper. */
32
+ export const checkedInit = (init, functionName) => {
33
+ if (typeof init !== 'string') {
34
+ throw new Error(`morphico: ${functionName}(element, init, options) — what it shows first is the second argument (a string), the options come third (since 0.5.0)`);
35
+ }
36
+ return init;
37
+ };
@@ -0,0 +1,87 @@
1
+ /*! morphico v0.6.0 | code: MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE)
2
+ * Icons based on Lucide (https://lucide.dev), some of them from Feather (https://feathericons.com):
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) 2026 Lucide Icons and Contributors
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ * The MIT License (MIT) (for the Lucide icons derived from Feather, listed in LICENSE-lucide)
21
+ *
22
+ * Copyright (c) 2013-present Cole Bemis
23
+ *
24
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
25
+ * of this software and associated documentation files (the "Software"), to deal
26
+ * in the Software without restriction, including without limitation the rights
27
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ * copies of the Software, and to permit persons to whom the Software is
29
+ * furnished to do so, subject to the following conditions:
30
+ *
31
+ * The above copyright notice and this permission notice shall be included in all
32
+ * copies or substantial portions of the Software.
33
+ *
34
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
+ * SOFTWARE.
41
+ */
42
+ import { LUCIDE_STROKE_WIDTH, lucideArc, lucideLine, lucidePoint } from './lucide.js';
43
+ const STATES = ['empty', 'low', 'medium', 'full'];
44
+ const BODY = [
45
+ lucideLine(4, 6, 16, 6),
46
+ lucideArc(16, 8, 2, -90, 0),
47
+ lucideLine(18, 8, 18, 16),
48
+ lucideArc(16, 16, 2, 0, 90),
49
+ lucideLine(16, 18, 4, 18),
50
+ lucideArc(4, 16, 2, 90, 180),
51
+ lucideLine(2, 16, 2, 8),
52
+ lucideArc(4, 8, 2, 180, 270),
53
+ ];
54
+ const TERMINAL = [lucideLine(22, 14, 22, 10)];
55
+ const BAR_X = [6, 10, 14];
56
+ /**
57
+ * When bar `barIndex` is drawn in from `fromLevel` to `toLevel` (more bars): the bars coming in share the morph,
58
+ * each taking 2 / (count + 1) of it, starting half of that after the one before.
59
+ */
60
+ const barDrawn = (barIndex, fromLevel, toLevel) => {
61
+ const count = toLevel - fromLevel;
62
+ const duration = 2 / (count + 1);
63
+ const start = (barIndex - fromLevel) * (duration / 2);
64
+ return { draw: [+start.toFixed(4), +(start + duration).toFixed(4)] };
65
+ };
66
+ const barPiece = (barIndex) => ({
67
+ strokes: Object.fromEntries(STATES.map((state, level) => [state, level > barIndex
68
+ ? [lucideLine(BAR_X[barIndex], 14, BAR_X[barIndex], 10)]
69
+ : lucidePoint(BAR_X[barIndex], 14)])),
70
+ alternativeStrokes: {},
71
+ // on the state without the bar, towards each state with it
72
+ pairLayouts: Object.fromEntries(STATES.slice(0, barIndex + 1).map((state, fromLevel) => [state, Object.fromEntries(STATES.slice(barIndex + 1).map((other, offset) => [other, barDrawn(barIndex, fromLevel, barIndex + 1 + offset)]))])),
73
+ });
74
+ const fixedPiece = (strokes) => ({
75
+ strokes: Object.fromEntries(STATES.map((state) => [state, strokes])),
76
+ alternativeStrokes: {},
77
+ pairLayouts: {},
78
+ });
79
+ export const iconsBattery = {
80
+ segmentCount: 12,
81
+ strokeWidth: LUCIDE_STROKE_WIDTH,
82
+ lineCap: 'round',
83
+ lineJoin: 'round',
84
+ ...fixedPiece(BODY),
85
+ morePieces: [fixedPiece(TERMINAL), ...[0, 1, 2].map(barPiece)],
86
+ spins: {},
87
+ };
@@ -0,0 +1,101 @@
1
+ /*! morphico v0.6.0 | code: MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE)
2
+ * Icons based on Lucide (https://lucide.dev), some of them from Feather (https://feathericons.com):
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) 2026 Lucide Icons and Contributors
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ * The MIT License (MIT) (for the Lucide icons derived from Feather, listed in LICENSE-lucide)
21
+ *
22
+ * Copyright (c) 2013-present Cole Bemis
23
+ *
24
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
25
+ * of this software and associated documentation files (the "Software"), to deal
26
+ * in the Software without restriction, including without limitation the rights
27
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ * copies of the Software, and to permit persons to whom the Software is
29
+ * furnished to do so, subject to the following conditions:
30
+ *
31
+ * The above copyright notice and this permission notice shall be included in all
32
+ * copies or substantial portions of the Software.
33
+ *
34
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
+ * SOFTWARE.
41
+ */
42
+ import { LUCIDE_SLASH, LUCIDE_STROKE_WIDTH, lucideArc, lucideCubic, lucideLine, lucidePoint } from './lucide.js';
43
+ const CLAPPER = [lucideArc(12, 19.9999, 2, 149.9971, 30.0029)];
44
+ /** Where the dome is split in "on": the middle of bell-off's gap on it (196.86° … 236.27°). */
45
+ const DOME_GAP_MIDDLE = (196.8632 + 236.2663) / 2;
46
+ const dome = (startAngle, endAngle) => lucideArc(12, 8, 6, startAngle, endAngle);
47
+ const clapper = { strokes: { on: CLAPPER, off: CLAPPER }, alternativeStrokes: {}, pairLayouts: {} };
48
+ // bottom line (3 segments), left tip (2), left side (4), dome (3) — the same in both states
49
+ const LEFT_LAYOUT = { breakpoints: [0, 0.3333, 0.6667, 1, 1.5, 2, 2.25, 2.5, 2.75, 3, 3.3333, 3.6667, 4] };
50
+ const leftPart = {
51
+ strokes: {
52
+ on: [
53
+ lucideLine(20, 17, 4, 17),
54
+ lucideArc(4.0007, 16, 1, 90.0419, 222.3766),
55
+ lucideCubic(3.262, 15.326, 4.589, 13.956, 6, 12.499, 6, 8),
56
+ dome(180, DOME_GAP_MIDDLE),
57
+ ],
58
+ off: [
59
+ lucideLine(17, 17, 4, 17),
60
+ lucideArc(3.9996, 16, 1, 89.9795, 222.299),
61
+ lucideCubic(3.26, 15.327, 4.59, 13.956, 6, 12.499, 6, 8),
62
+ lucideArc(12, 7.9985, 6, 179.9859, 196.8632),
63
+ ],
64
+ },
65
+ alternativeStrokes: {},
66
+ pairLayouts: { on: { off: LEFT_LAYOUT }, off: { on: LEFT_LAYOUT } },
67
+ };
68
+ // dome (4 segments), right side (6), right tip (2) — off has no tip and only the side's upper part: 2 zero-length
69
+ // segments at its end
70
+ const rightPart = {
71
+ strokes: {
72
+ on: [
73
+ dome(DOME_GAP_MIDDLE, 360),
74
+ lucideCubic(18, 8, 18, 12.499, 19.41, 13.956, 20.74, 15.327),
75
+ lucideArc(20.0004, 16, 1, -42.299, 90.0205),
76
+ ],
77
+ off: [
78
+ lucideArc(12, 7.9998, 6, -123.7337, 0.0022),
79
+ lucideCubic(18, 8, 18, 10.687, 18.77, 12.653, 19.707, 14.05),
80
+ ],
81
+ },
82
+ alternativeStrokes: {},
83
+ pairLayouts: {
84
+ on: { off: { breakpoints: [0, 0.25, 0.5, 0.75, 1, 1.1667, 1.3333, 1.5, 1.6667, 1.8333, 2, 2.5, 3] } },
85
+ off: { on: { breakpoints: [0, 0.25, 0.5, 0.75, 1, 1.1667, 1.3333, 1.5, 1.6667, 1.8333, 2, 2, 2] } },
86
+ },
87
+ };
88
+ const slash = {
89
+ strokes: { on: lucidePoint(2, 2), off: LUCIDE_SLASH },
90
+ alternativeStrokes: {},
91
+ pairLayouts: { on: { off: { draw: true } } },
92
+ };
93
+ export const iconsBell = {
94
+ segmentCount: 12,
95
+ strokeWidth: LUCIDE_STROKE_WIDTH,
96
+ lineCap: 'round',
97
+ lineJoin: 'round',
98
+ ...clapper,
99
+ morePieces: [leftPart, rightPart, slash],
100
+ spins: {},
101
+ };
@@ -0,0 +1,64 @@
1
+ /*! morphico v0.6.0 | MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE) */
2
+ // The characters every digit set shares besides 0–9: `-` `/` `.` `,` `:` (space = the empty state, see morph.ts),
3
+ // plus the symbols `+` `%` `$` `€` `£` drawn in the set's own style (symbols.ts).
4
+ // Each is drawn as one straight line, placed by the set's text layout and stroke width, and morphs to and from
5
+ // every digit by flattening (the user's choice 2026-10-27): the digit is pressed flat onto the line.
6
+ // `:` has two dots and the symbols up to three parts, so digit sets get a second and a third piece. The second
7
+ // repeats the first piece exactly for every state with one part (same strokes and layouts, drawn on top of itself, so
8
+ // it doesn't show; a digit morphing into `:` splits into the two dots). The third is only `€`'s lower bar and `%`'s
9
+ // lower ring: every other state rests it as a single point in the middle (never drawn), so it grows out of there
10
+ // instead of a whole copy shrinking into it. Symbols morph with the default pairing, except the pairs in
11
+ // `symbolPairLayouts`.
12
+ import { defaultBreakpoints, line } from '../geometry.js';
13
+ import { symbolPairLayouts, symbolStrokes } from './symbols.js';
14
+ const DIGITS = [...'0123456789'];
15
+ /** Half the length of a dot's line, relative to the stroke width: round ends make it a dot 1.1 × the stroke wide. */
16
+ const DOT_HALF_LENGTH = 0.05;
17
+ /** The layouts of a piece plus more pairs (merged per state). */
18
+ const withMorePairs = (layouts, morePairs) => {
19
+ const merged = { ...layouts };
20
+ for (const [state, byOtherState] of Object.entries(morePairs))
21
+ merged[state] = { ...merged[state], ...byOtherState };
22
+ return merged;
23
+ };
24
+ /** Adds `-` `/` `.` `,` `:` and the symbols (in `symbolStyle`) to a digit set (which needs a text layout) as morphing states. */
25
+ export const withTextCharacters = (iconSet, symbolStyle) => {
26
+ const { baselineY, colonDotsY } = iconSet.textLayout;
27
+ const dotHalfLength = iconSet.strokeWidth * DOT_HALF_LENGTH;
28
+ const dotY = baselineY; // dot centre on the line the digits stand on
29
+ const dot = (y) => line(12 - dotHalfLength, y, 12 + dotHalfLength, y);
30
+ const characters = {
31
+ '-': [line(9.5, 12, 14.5, 12)],
32
+ '/': [line(9.5, baselineY, 14.5, 24 - baselineY)],
33
+ '.': [dot(dotY)],
34
+ ',': [line(12.3, dotY, 11, baselineY + 2.2)], // from the dot down to the left
35
+ ':': [dot(colonDotsY[0])],
36
+ };
37
+ const pairLayouts = withMorePairs(iconSet.pairLayouts, Object.fromEntries(Object.keys(characters).map((character) => [character, Object.fromEntries(DIGITS.map((digit) => [digit, { flatten: true }]))])));
38
+ const drawings = symbolStrokes(symbolStyle);
39
+ /** A tracing is only used with breakpoints (geometry.ts shapeForPair): give the symbols' tracings the default ones. */
40
+ const withTracingBreakpoints = (layouts, tracings) => Object.fromEntries(Object.entries(layouts).map(([state, byOtherState]) => [state, Object.fromEntries(Object.entries(byOtherState).map(([otherState, layout]) => [otherState, layout.tracing && !layout.breakpoints
41
+ ? { ...layout, breakpoints: defaultBreakpoints(tracings[layout.tracing], iconSet.segmentCount) }
42
+ : layout]))]));
43
+ const symbols = Object.entries(drawings.pieces);
44
+ const strokes = { ...iconSet.strokes, ...characters, ...Object.fromEntries(symbols.map(([symbol, [first]]) => [symbol, first])) };
45
+ const partsAt = (index) => Object.fromEntries(symbols.flatMap(([symbol, pieces]) => (pieces[index] ? [[symbol, pieces[index]]] : [])));
46
+ const secondPiece = {
47
+ strokes: { ...strokes, ':': [dot(colonDotsY[1])], ...partsAt(1) },
48
+ alternativeStrokes: { ...iconSet.alternativeStrokes, ...drawings.secondPieceTracings },
49
+ pairLayouts: withMorePairs(pairLayouts, withTracingBreakpoints(symbolPairLayouts[1], drawings.secondPieceTracings)),
50
+ };
51
+ // only the symbols' layouts here: the digits' tracings would draw a whole digit in place of the resting point
52
+ const thirdPiece = {
53
+ strokes: { ...Object.fromEntries(Object.keys(strokes).map((state) => [state, [line(12, 12, 12, 12)]])), ...partsAt(2) },
54
+ alternativeStrokes: drawings.thirdPieceTracings,
55
+ pairLayouts: withTracingBreakpoints(symbolPairLayouts[2], drawings.thirdPieceTracings),
56
+ };
57
+ return {
58
+ ...iconSet,
59
+ strokes,
60
+ alternativeStrokes: { ...iconSet.alternativeStrokes, ...drawings.firstPieceTracings },
61
+ pairLayouts: withMorePairs(pairLayouts, withTracingBreakpoints(symbolPairLayouts[0], drawings.firstPieceTracings)),
62
+ morePieces: [secondPiece, thirdPiece],
63
+ };
64
+ };
@@ -0,0 +1,74 @@
1
+ /*! morphico v0.6.0 | code: MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE)
2
+ * Icons based on Lucide (https://lucide.dev), some of them from Feather (https://feathericons.com):
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) 2026 Lucide Icons and Contributors
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ * The MIT License (MIT) (for the Lucide icons derived from Feather, listed in LICENSE-lucide)
21
+ *
22
+ * Copyright (c) 2013-present Cole Bemis
23
+ *
24
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
25
+ * of this software and associated documentation files (the "Software"), to deal
26
+ * in the Software without restriction, including without limitation the rights
27
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ * copies of the Software, and to permit persons to whom the Software is
29
+ * furnished to do so, subject to the following conditions:
30
+ *
31
+ * The above copyright notice and this permission notice shall be included in all
32
+ * copies or substantial portions of the Software.
33
+ *
34
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
+ * SOFTWARE.
41
+ */
42
+ // The check mark shared by "checkbox" and "radio" (Lucide 1.61.0 "square-check" / "circle-check" and their "-big"
43
+ // versions draw the same checks; ISC, see LICENSE-lucide). Coordinates are Lucide's, scaled by fromLucide.
44
+ // Drawn left to right, short stroke then long stroke. unchecked has no check: the check is drawn in like a pen
45
+ // writing it — down the short stroke, up the long one (the user's sketch; PairLayout.draw) — and erased back.
46
+ import { line } from '../geometry.js';
47
+ import { fromLucide } from './lucide.js';
48
+ /** A straight line between two Lucide points, moved into our icon box. */
49
+ const lucideLine = (from, to) => line(...fromLucide(from), ...fromLucide(to));
50
+ const CHECK = [lucideLine([8, 12], [10.5, 14.5]), lucideLine([10.5, 14.5], [16, 9])];
51
+ const BIG_CHECK = [lucideLine([9, 11], [12, 14]), lucideLine([12, 14], [22, 4])];
52
+ // every check ↔ check: short stroke 4 segments, long stroke 8 (of 12), so the corners meet
53
+ const CHECK_FOR_CHECK = { breakpoints: [0, 0.25, 0.5, 0.75, 1, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2] };
54
+ const CHECK_STATES = ['unchecked', 'checked', 'checked-big'];
55
+ /**
56
+ * The check piece of a set with the states unchecked, checked, checked-big (12 segments).
57
+ * `hiddenAt`: a Lucide point on the outline at the check's height, where unchecked's check rests at rest
58
+ * (tiny, under the outline's line, so it doesn't show — morphs draw the check instead).
59
+ */
60
+ export const checkMarkPiece = (hiddenAt) => {
61
+ const [x, y] = hiddenAt;
62
+ return {
63
+ strokes: {
64
+ unchecked: [lucideLine([x, y - 0.1], [x, y]), lucideLine([x, y], [x, y + 0.1])],
65
+ checked: CHECK,
66
+ 'checked-big': BIG_CHECK,
67
+ },
68
+ alternativeStrokes: {},
69
+ pairLayouts: {
70
+ ...Object.fromEntries(CHECK_STATES.map((state) => [state, Object.fromEntries(CHECK_STATES.filter((other) => other !== state).map((other) => [other, CHECK_FOR_CHECK]))])),
71
+ unchecked: { checked: { draw: true }, 'checked-big': { draw: true } },
72
+ },
73
+ };
74
+ };
@@ -0,0 +1,91 @@
1
+ /*! morphico v0.6.0 | code: MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE)
2
+ * Icons based on Lucide (https://lucide.dev), some of them from Feather (https://feathericons.com):
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) 2026 Lucide Icons and Contributors
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ * The MIT License (MIT) (for the Lucide icons derived from Feather, listed in LICENSE-lucide)
21
+ *
22
+ * Copyright (c) 2013-present Cole Bemis
23
+ *
24
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
25
+ * of this software and associated documentation files (the "Software"), to deal
26
+ * in the Software without restriction, including without limitation the rights
27
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ * copies of the Software, and to permit persons to whom the Software is
29
+ * furnished to do so, subject to the following conditions:
30
+ *
31
+ * The above copyright notice and this permission notice shall be included in all
32
+ * copies or substantial portions of the Software.
33
+ *
34
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
+ * SOFTWARE.
41
+ */
42
+ // Icon set "checkbox": unchecked, checked, checked-big — Lucide 1.61.0 icons "square", "square-check",
43
+ // "square-check-big" (ISC, see LICENSE-lucide). Coordinates below are Lucide's; fromLucide / lucideLength scale them
44
+ // into our icon box (more margin, like the digits — see lucide.ts). Built from rounded corners, so `roundness` works.
45
+ // Two pieces:
46
+ // piece 1, the box: the same square in unchecked and checked (it doesn't move); checked-big opens its top right
47
+ // corner where the big check leaves the box — both ends of the gap pull back to the gap's edges.
48
+ // piece 2, the check (check-mark.ts, shared with "radio"): drawn in like a pen from unchecked (the user's sketch).
49
+ // (Rejected: a box copy folding into the check — tangled; the check sliding in from the left edge — user: bad.)
50
+ import { line, roundedPolygon } from '../geometry.js';
51
+ import { checkMarkPiece } from './check-mark.js';
52
+ import { fromLucide, LUCIDE_STROKE_WIDTH, lucideLength } from './lucide.js';
53
+ const SQUARE_CORNERS = [[3, 3], [21, 3], [21, 21], [3, 21]].map(fromLucide);
54
+ const LUCIDE_RADIUS = lucideLength(2);
55
+ /** square-check-big's box: the square without its top right corner (gap from 17.344,3 to 21,10.656). */
56
+ const openBox = (square) => {
57
+ const [top, , right, bottomRight, bottom, bottomLeft, left, topLeft] = square;
58
+ return [
59
+ line(...fromLucide([21, 10.656]), ...right.to),
60
+ bottomRight, bottom, bottomLeft, left, topLeft,
61
+ line(...top.from, ...fromLucide([17.344, 3])),
62
+ ];
63
+ };
64
+ // box, checked/unchecked ↔ checked-big: the square laid out so its 12 segments line up with the open box's —
65
+ // top (2: the part that stays, the part in the gap), top right corner (2, in the gap), right side (2: in the gap,
66
+ // the part that stays), bottom right, bottom, bottom left, left (2), top left — started at the corner's second half.
67
+ // The open box gets two zero-length segments at each end of the gap, where the vanishing parts pull back to.
68
+ const SQUARE_FOR_OPEN_BOX = { breakpoints: [0, 0.8817, 1, 1.5, 2, 2.404, 3, 4, 5, 6, 6.5, 7, 8], startSegment: 3 };
69
+ const OPEN_BOX_FOR_SQUARE = { breakpoints: [0, 0, 0, 1, 2, 3, 4, 4.5, 5, 6, 7, 7, 7] };
70
+ /** The check rests (hidden) on the box's left edge. */
71
+ const CHECK_PIECE = checkMarkPiece([3, 12]);
72
+ const buildCheckboxIcons = (radius) => {
73
+ const square = roundedPolygon(SQUARE_CORNERS, radius);
74
+ return {
75
+ segmentCount: 12,
76
+ strokeWidth: LUCIDE_STROKE_WIDTH,
77
+ lineCap: 'round',
78
+ lineJoin: 'round',
79
+ strokes: { unchecked: square, checked: square, 'checked-big': openBox(square) },
80
+ alternativeStrokes: {},
81
+ pairLayouts: {
82
+ unchecked: { 'checked-big': SQUARE_FOR_OPEN_BOX },
83
+ checked: { 'checked-big': SQUARE_FOR_OPEN_BOX },
84
+ 'checked-big': { unchecked: OPEN_BOX_FOR_SQUARE, checked: OPEN_BOX_FOR_SQUARE },
85
+ },
86
+ morePieces: [CHECK_PIECE],
87
+ spins: {},
88
+ withRoundness: (roundness) => buildCheckboxIcons(LUCIDE_RADIUS * roundness),
89
+ };
90
+ };
91
+ export const iconsCheckbox = buildCheckboxIcons(LUCIDE_RADIUS);
@@ -0,0 +1,70 @@
1
+ /*! morphico v0.6.0 | code: MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE)
2
+ * Icons based on Lucide (https://lucide.dev), some of them from Feather (https://feathericons.com):
3
+ *
4
+ * ISC License
5
+ *
6
+ * Copyright (c) 2026 Lucide Icons and Contributors
7
+ *
8
+ * Permission to use, copy, modify, and/or distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ *
20
+ * The MIT License (MIT) (for the Lucide icons derived from Feather, listed in LICENSE-lucide)
21
+ *
22
+ * Copyright (c) 2013-present Cole Bemis
23
+ *
24
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
25
+ * of this software and associated documentation files (the "Software"), to deal
26
+ * in the Software without restriction, including without limitation the rights
27
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ * copies of the Software, and to permit persons to whom the Software is
29
+ * furnished to do so, subject to the following conditions:
30
+ *
31
+ * The above copyright notice and this permission notice shall be included in all
32
+ * copies or substantial portions of the Software.
33
+ *
34
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
+ * SOFTWARE.
41
+ */
42
+ import { LUCIDE_STROKE_WIDTH, lucideLine } from './lucide.js';
43
+ const STATES = ['up', 'right', 'down', 'left'];
44
+ /** chevron-up's corners (right end, tip, left end), turned clockwise by `quarterTurns` × 90° around 12,12. */
45
+ const chevron = (quarterTurns) => {
46
+ const turn = ([x, y]) => {
47
+ let [dx, dy] = [x - 12, y - 12];
48
+ for (let step = 0; step < quarterTurns; step++)
49
+ [dx, dy] = [-dy, dx];
50
+ return [12 + dx, 12 + dy];
51
+ };
52
+ const [rightEnd, tip, leftEnd] = [[18, 15], [12, 9], [6, 15]].map(turn);
53
+ return [lucideLine(...rightEnd, ...tip), lucideLine(...tip, ...leftEnd)];
54
+ };
55
+ /** Degrees from one state to another: the shorter way round (half a turn: clockwise). */
56
+ const turnBetween = (fromIndex, toIndex) => {
57
+ const quarterTurns = (toIndex - fromIndex + 4) % 4;
58
+ return quarterTurns === 3 ? -90 : quarterTurns * 90;
59
+ };
60
+ export const iconsChevron = {
61
+ segmentCount: 2,
62
+ strokeWidth: LUCIDE_STROKE_WIDTH,
63
+ lineCap: 'round',
64
+ lineJoin: 'round',
65
+ strokes: Object.fromEntries(STATES.map((state, index) => [state, chevron(index)])),
66
+ alternativeStrokes: {},
67
+ pairLayouts: {},
68
+ spins: Object.fromEntries(STATES.map((state, fromIndex) => [state, Object.fromEntries(STATES
69
+ .filter((other) => other !== state).map((other) => [other, turnBetween(fromIndex, STATES.indexOf(other))]))])),
70
+ };