morphico 0.3.0 → 0.5.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.
- package/README.md +98 -41
- package/dist/esm/all.js +50 -0
- package/dist/esm/clip.js +283 -0
- package/dist/esm/engine.js +25 -0
- package/dist/esm/face.js +153 -0
- package/dist/esm/geometry.js +459 -0
- package/dist/esm/icon.js +41 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/morph.js +107 -0
- package/dist/esm/roundness.js +37 -0
- package/dist/esm/sets/battery.js +87 -0
- package/dist/esm/sets/bell.js +101 -0
- package/dist/esm/sets/characters.js +43 -0
- package/dist/esm/sets/check-mark.js +74 -0
- package/dist/esm/sets/checkbox.js +91 -0
- package/dist/esm/sets/chevron.js +70 -0
- package/dist/esm/sets/condensed.js +137 -0
- package/dist/esm/sets/copy.js +87 -0
- package/dist/esm/sets/eye.js +105 -0
- package/dist/esm/sets/faces.js +482 -0
- package/dist/esm/sets/folder.js +112 -0
- package/dist/esm/sets/handwritten.js +136 -0
- package/dist/esm/sets/lock.js +75 -0
- package/dist/esm/sets/lucide.js +66 -0
- package/dist/esm/sets/media.js +109 -0
- package/dist/esm/sets/menu.js +84 -0
- package/dist/esm/sets/mic.js +102 -0
- package/dist/esm/sets/radio.js +84 -0
- package/dist/esm/sets/round.js +244 -0
- package/dist/esm/sets/shapes.js +455 -0
- package/dist/esm/sets/slim.js +148 -0
- package/dist/esm/sets/square.js +149 -0
- package/dist/esm/sets/theme.js +107 -0
- package/dist/esm/sets/toggle.js +73 -0
- package/dist/esm/sets/volume.js +89 -0
- package/dist/esm/sets/weather.js +691 -0
- package/dist/esm/sets/wifi.js +68 -0
- package/dist/esm/svg.js +31 -0
- package/dist/esm/text.js +88 -0
- package/dist/esm/types.js +3 -0
- package/dist/morphico.js +4033 -3380
- package/dist/types/{iconSets.d.ts → all.d.ts} +0 -2
- package/dist/types/clip.d.ts +6 -11
- package/dist/types/face.d.ts +27 -0
- package/dist/types/icon.d.ts +4 -9
- package/dist/types/index.d.ts +5 -3
- package/dist/types/roundness.d.ts +8 -0
- package/dist/types/sets/battery.d.ts +1 -1
- package/dist/types/sets/bell.d.ts +1 -1
- package/dist/types/sets/checkbox.d.ts +1 -1
- package/dist/types/sets/chevron.d.ts +1 -1
- package/dist/types/sets/condensed.d.ts +1 -1
- package/dist/types/sets/copy.d.ts +1 -1
- package/dist/types/sets/eye.d.ts +1 -1
- package/dist/types/sets/faces.d.ts +25 -0
- package/dist/types/sets/folder.d.ts +1 -1
- package/dist/types/sets/handwritten.d.ts +1 -1
- package/dist/types/sets/lock.d.ts +1 -1
- package/dist/types/sets/media.d.ts +1 -1
- package/dist/types/sets/menu.d.ts +1 -1
- package/dist/types/sets/mic.d.ts +1 -1
- package/dist/types/sets/radio.d.ts +1 -1
- package/dist/types/sets/round.d.ts +1 -1
- package/dist/types/sets/slim.d.ts +1 -1
- package/dist/types/sets/square.d.ts +1 -1
- package/dist/types/sets/theme.d.ts +1 -1
- package/dist/types/sets/toggle.d.ts +1 -1
- package/dist/types/sets/volume.d.ts +1 -1
- package/dist/types/sets/weather.d.ts +1 -1
- package/dist/types/sets/wifi.d.ts +1 -1
- package/dist/types/text.d.ts +8 -13
- package/package.json +95 -3
- package/dist/morphico.mjs +0 -4003
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*! morphico v0.5.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
|
+
// morphico public API.
|
|
43
|
+
export { clip } from './clip.js';
|
|
44
|
+
export { easings } from './engine.js';
|
|
45
|
+
export { face } from './face.js';
|
|
46
|
+
export { icon } from './icon.js';
|
|
47
|
+
export { faceExpressionNames } from './sets/faces.js';
|
|
48
|
+
export { text } from './text.js';
|
|
49
|
+
/** Package version, e.g. "0.1.0" (tools/build.ts replaces 'dev'). */
|
|
50
|
+
export const version = '0.5.0';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*! morphico v0.5.0 | MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE) */
|
|
2
|
+
// One SVG <path> that morphs between the states of an icon set. Shared by icon() and every text() cell.
|
|
3
|
+
import { animate, easings } from './engine.js';
|
|
4
|
+
import { defaultShapes, drawnPieces, interpolate, pieceLengthOf, rotateAroundCenter, scaleAroundCenter, shapeForPair, toPathData, withDrawnPieces, } from './geometry.js';
|
|
5
|
+
/** The empty state: nothing is drawn. Shapes grow out of it and shrink into it while fading. */
|
|
6
|
+
export const EMPTY_STATE = ' ';
|
|
7
|
+
/** How small a shape gets while it fades into (or out of) the empty state. */
|
|
8
|
+
const EMPTY_SCALE = 0.3;
|
|
9
|
+
export const DEFAULT_DURATION = 400;
|
|
10
|
+
// default layouts of every state, computed once per set on first use (nothing runs at import)
|
|
11
|
+
const shapesBySet = new WeakMap();
|
|
12
|
+
export const shapesOf = (iconSet) => {
|
|
13
|
+
let shapes = shapesBySet.get(iconSet);
|
|
14
|
+
if (!shapes) {
|
|
15
|
+
shapes = defaultShapes(iconSet);
|
|
16
|
+
shapesBySet.set(iconSet, shapes);
|
|
17
|
+
}
|
|
18
|
+
return shapes;
|
|
19
|
+
};
|
|
20
|
+
export const hasState = (iconSet, state) => state === EMPTY_STATE || state in iconSet.strokes;
|
|
21
|
+
export const prefersReducedMotion = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
22
|
+
/** Blends towards the target in the start's frame while turning that frame by spin · progress. */
|
|
23
|
+
const blend = (from, to, progress, spin) => (spin
|
|
24
|
+
? rotateAroundCenter(interpolate(from, rotateAroundCenter(to, -spin), progress), spin * progress)
|
|
25
|
+
: interpolate(from, to, progress));
|
|
26
|
+
export const clampToUnit = (value) => Math.min(Math.max(value, 0), 1);
|
|
27
|
+
export const createMorphingPath = (pathElement, iconSet, initialState) => {
|
|
28
|
+
const shapes = shapesOf(iconSet);
|
|
29
|
+
const pieceLength = pieceLengthOf(iconSet);
|
|
30
|
+
let state = initialState;
|
|
31
|
+
let currentPath = null; // null while empty
|
|
32
|
+
let currentOpacity = 0;
|
|
33
|
+
let running = null;
|
|
34
|
+
const render = (path, opacity) => {
|
|
35
|
+
currentPath = path;
|
|
36
|
+
currentOpacity = path ? clampToUnit(opacity) : 0;
|
|
37
|
+
if (path)
|
|
38
|
+
pathElement.setAttribute('d', toPathData(path, pieceLength));
|
|
39
|
+
else
|
|
40
|
+
pathElement.removeAttribute('d');
|
|
41
|
+
if (currentOpacity < 1)
|
|
42
|
+
pathElement.setAttribute('opacity', String(+currentOpacity.toFixed(3)));
|
|
43
|
+
else
|
|
44
|
+
pathElement.removeAttribute('opacity');
|
|
45
|
+
};
|
|
46
|
+
/** Ends the running morph and resolves everyone waiting for it. */
|
|
47
|
+
const finish = (interrupted) => {
|
|
48
|
+
if (!running)
|
|
49
|
+
return;
|
|
50
|
+
const { stopAnimation, resolvers } = running;
|
|
51
|
+
running = null;
|
|
52
|
+
stopAnimation();
|
|
53
|
+
for (const resolve of resolvers)
|
|
54
|
+
resolve({ state, interrupted });
|
|
55
|
+
};
|
|
56
|
+
render(state === EMPTY_STATE ? null : shapes[state], 1);
|
|
57
|
+
return {
|
|
58
|
+
get state() { return state; },
|
|
59
|
+
morphTo(nextState, { duration = DEFAULT_DURATION, easing = 'easeInOutCubic' } = {}) {
|
|
60
|
+
// asked again for the state it is already heading to: wait for the running morph
|
|
61
|
+
if (running && nextState === state) {
|
|
62
|
+
const { resolvers } = running;
|
|
63
|
+
return new Promise((resolve) => { resolvers.push(resolve); });
|
|
64
|
+
}
|
|
65
|
+
const settled = !running;
|
|
66
|
+
if (settled && nextState === state)
|
|
67
|
+
return Promise.resolve({ state, interrupted: false });
|
|
68
|
+
finish(true);
|
|
69
|
+
const previousState = state;
|
|
70
|
+
state = nextState;
|
|
71
|
+
// settled: both sides use the pair's layouts; interrupted: start from the shape on screen
|
|
72
|
+
const target = nextState === EMPTY_STATE ? null
|
|
73
|
+
: previousState === EMPTY_STATE ? shapes[nextState] : shapeForPair(iconSet, shapes, nextState, previousState);
|
|
74
|
+
const start = !settled ? currentPath
|
|
75
|
+
: previousState === EMPTY_STATE ? null : shapeForPair(iconSet, shapes, previousState, nextState);
|
|
76
|
+
const startOpacity = currentOpacity;
|
|
77
|
+
const endOpacity = target ? 1 : 0;
|
|
78
|
+
if ((!start && !target) || duration <= 0 || prefersReducedMotion()) {
|
|
79
|
+
render(target, endOpacity);
|
|
80
|
+
return Promise.resolve({ state, interrupted: false });
|
|
81
|
+
}
|
|
82
|
+
const from = start ?? scaleAroundCenter(target, EMPTY_SCALE);
|
|
83
|
+
const to = target ?? scaleAroundCenter(start, EMPTY_SCALE);
|
|
84
|
+
const spin = (settled && iconSet.spins[previousState]?.[nextState]) || 0;
|
|
85
|
+
// pieces that appear or go are drawn along their path (only from a settled shape, between two real states)
|
|
86
|
+
const drawn = settled && start && target ? drawnPieces(iconSet, previousState, nextState) : [];
|
|
87
|
+
const ease = typeof easing === 'function' ? easing : easings[easing];
|
|
88
|
+
const startTime = performance.now();
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
const stopAnimation = animate((frameTime) => {
|
|
91
|
+
const progress = clampToUnit((frameTime - startTime) / duration);
|
|
92
|
+
if (progress < 1) {
|
|
93
|
+
const easedProgress = ease(progress);
|
|
94
|
+
const frame = withDrawnPieces(blend(from, to, easedProgress, spin), from, to, easedProgress, pieceLength, drawn);
|
|
95
|
+
render(frame, startOpacity + (endOpacity - startOpacity) * easedProgress);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
render(target, endOpacity);
|
|
99
|
+
finish(false);
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
running = { stopAnimation, resolvers: [resolve] };
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
stop: () => finish(true),
|
|
106
|
+
};
|
|
107
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*! morphico v0.5.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.5.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.5.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,43 @@
|
|
|
1
|
+
/*! morphico v0.5.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
|
+
// Each is drawn as one straight line, placed by the set's text layout and stroke width, and morphs to and from
|
|
4
|
+
// every digit by flattening (the user's choice 2026-10-27): the digit is pressed flat onto the line.
|
|
5
|
+
// `:` has two dots, so digit sets get a second piece: for every other state it repeats the first piece exactly
|
|
6
|
+
// (same strokes and layouts, drawn on top of itself, so it doesn't show).
|
|
7
|
+
import { line } from '../geometry.js';
|
|
8
|
+
const DIGITS = [...'0123456789'];
|
|
9
|
+
/** Half the length of a dot's line, relative to the stroke width: round ends make it a dot 1.1 × the stroke wide. */
|
|
10
|
+
const DOT_HALF_LENGTH = 0.05;
|
|
11
|
+
/** Adds `-` `/` `.` `,` `:` to a digit set (which needs a text layout) as morphing states. */
|
|
12
|
+
export const withTextCharacters = (iconSet) => {
|
|
13
|
+
const { baselineY, colonDotsY } = iconSet.textLayout;
|
|
14
|
+
const dotHalfLength = iconSet.strokeWidth * DOT_HALF_LENGTH;
|
|
15
|
+
const dotY = baselineY; // dot centre on the line the digits stand on
|
|
16
|
+
const dot = (y) => line(12 - dotHalfLength, y, 12 + dotHalfLength, y);
|
|
17
|
+
const characters = {
|
|
18
|
+
'-': [line(9.5, 12, 14.5, 12)],
|
|
19
|
+
'/': [line(9.5, baselineY, 14.5, 24 - baselineY)],
|
|
20
|
+
'.': [dot(dotY)],
|
|
21
|
+
',': [line(12.3, dotY, 11, baselineY + 2.2)], // from the dot down to the left
|
|
22
|
+
':': [dot(colonDotsY[0])],
|
|
23
|
+
};
|
|
24
|
+
const flattenPairs = (layouts) => {
|
|
25
|
+
const merged = { ...layouts };
|
|
26
|
+
for (const character of Object.keys(characters)) {
|
|
27
|
+
merged[character] = { ...merged[character], ...Object.fromEntries(DIGITS.map((digit) => [digit, { flatten: true }])) };
|
|
28
|
+
}
|
|
29
|
+
return merged;
|
|
30
|
+
};
|
|
31
|
+
const pairLayouts = flattenPairs(iconSet.pairLayouts);
|
|
32
|
+
const strokes = { ...iconSet.strokes, ...characters };
|
|
33
|
+
return {
|
|
34
|
+
...iconSet,
|
|
35
|
+
strokes,
|
|
36
|
+
pairLayouts,
|
|
37
|
+
morePieces: [{
|
|
38
|
+
strokes: { ...strokes, ':': [dot(colonDotsY[1])] },
|
|
39
|
+
alternativeStrokes: iconSet.alternativeStrokes,
|
|
40
|
+
pairLayouts,
|
|
41
|
+
}],
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*! morphico v0.5.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.5.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);
|