morphico 0.5.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.
- package/README.md +99 -32
- package/dist/esm/all.js +1 -1
- package/dist/esm/clip.js +8 -6
- package/dist/esm/engine.js +1 -1
- package/dist/esm/face.js +2 -3
- package/dist/esm/geometry.js +1 -1
- package/dist/esm/icon.js +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/morph.js +2 -2
- package/dist/esm/roundness.js +1 -1
- package/dist/esm/sets/battery.js +1 -1
- package/dist/esm/sets/bell.js +1 -1
- package/dist/esm/sets/characters.js +42 -21
- package/dist/esm/sets/check-mark.js +1 -1
- package/dist/esm/sets/checkbox.js +1 -1
- package/dist/esm/sets/chevron.js +1 -1
- package/dist/esm/sets/condensed.js +4 -3
- package/dist/esm/sets/copy.js +1 -1
- package/dist/esm/sets/eye.js +1 -1
- package/dist/esm/sets/faces.js +1 -1
- package/dist/esm/sets/folder.js +1 -1
- package/dist/esm/sets/handwritten.js +4 -3
- package/dist/esm/sets/lock.js +1 -1
- package/dist/esm/sets/lucide.js +1 -1
- package/dist/esm/sets/media.js +1 -1
- package/dist/esm/sets/menu.js +1 -1
- package/dist/esm/sets/mic.js +1 -1
- package/dist/esm/sets/radio.js +1 -1
- package/dist/esm/sets/round.js +4 -3
- package/dist/esm/sets/shapes.js +7 -1
- package/dist/esm/sets/slim.js +4 -3
- package/dist/esm/sets/square.js +4 -3
- package/dist/esm/sets/symbols.js +154 -0
- package/dist/esm/sets/theme.js +1 -1
- package/dist/esm/sets/toggle.js +1 -1
- package/dist/esm/sets/volume.js +1 -1
- package/dist/esm/sets/weather.js +1 -1
- package/dist/esm/sets/wifi.js +1 -1
- package/dist/esm/svg.js +1 -1
- package/dist/esm/text.js +6 -5
- package/dist/esm/types.js +1 -1
- package/dist/morphico.js +236 -46
- package/dist/types/clip.d.ts +5 -8
- package/dist/types/icon.d.ts +2 -2
- package/dist/types/index.d.ts +4 -3
- package/dist/types/morph.d.ts +3 -3
- package/dist/types/sets/characters.d.ts +3 -2
- package/dist/types/sets/shapes.d.ts +4 -1
- package/dist/types/sets/symbols.d.ts +38 -0
- package/dist/types/text.d.ts +3 -9
- package/package.json +1 -1
package/dist/morphico.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! morphico v0.
|
|
1
|
+
/*! morphico v0.6.0 | code: MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE)
|
|
2
2
|
* Icons based on Lucide (https://lucide.dev), some of them from Feather (https://feathericons.com):
|
|
3
3
|
*
|
|
4
4
|
* ISC License
|
|
@@ -581,7 +581,7 @@ const { EMPTY_STATE, DEFAULT_DURATION, shapesOf, hasState, prefersReducedMotion,
|
|
|
581
581
|
const EMPTY_STATE = ' ';
|
|
582
582
|
/** How small a shape gets while it fades into (or out of) the empty state. */
|
|
583
583
|
const EMPTY_SCALE = 0.3;
|
|
584
|
-
const DEFAULT_DURATION =
|
|
584
|
+
const DEFAULT_DURATION = 300;
|
|
585
585
|
// default layouts of every state, computed once per set on first use (nothing runs at import)
|
|
586
586
|
const shapesBySet = new WeakMap();
|
|
587
587
|
const shapesOf = (iconSet) => {
|
|
@@ -684,7 +684,7 @@ return { EMPTY_STATE, DEFAULT_DURATION, shapesOf, hasState, prefersReducedMotion
|
|
|
684
684
|
})();
|
|
685
685
|
|
|
686
686
|
// sets/shapes.ts
|
|
687
|
-
const { lucideShapeOutlines, clipShapes } = (() => {
|
|
687
|
+
const { clipShapeNames, lucideShapeOutlines, clipShapes } = (() => {
|
|
688
688
|
// Shapes for clip(): closed outlines that cut out an element. From Lucide 1.61.0 (ISC, see LICENSE-lucide), imported
|
|
689
689
|
// by `node tools/import-lucide.ts <name>`; tag without its dot, club without its stem. The states are the Lucide outlines made comparable for
|
|
690
690
|
// morphing: clockwise, starting where the outline crosses the vertical middle at the top, scaled evenly to fill the
|
|
@@ -695,6 +695,12 @@ const GRID_CENTER = 12;
|
|
|
695
695
|
const SAMPLES_PER_STROKE = 48;
|
|
696
696
|
/** Enough for the shape that needs the most (puzzle: 24 strokes, its knobs ≈ 40 segments); the rest spreads by length. */
|
|
697
697
|
const SEGMENT_COUNT = 48;
|
|
698
|
+
/** The names of clip()'s shapes (TypeScript checks the outlines below have exactly these). */
|
|
699
|
+
const clipShapeNames = [
|
|
700
|
+
'circle', 'ellipse', 'heart', 'sparkle', 'astroid', 'bookmark', 'shield', 'moon', 'tag', 'square', 'badge', 'triangle',
|
|
701
|
+
'droplet', 'pentagon', 'hexagon', 'octagon', 'squircle', 'star', 'rectangle-horizontal', 'message-circle',
|
|
702
|
+
'message-square', 'cloud', 'puzzle', 'club',
|
|
703
|
+
];
|
|
698
704
|
/** The shapes as Lucide draws them (Lucide coordinates); the set's states are made from these. */
|
|
699
705
|
const lucideShapeOutlines = {
|
|
700
706
|
circle: [arc(12, 12, 10, -90, 270)],
|
|
@@ -1098,7 +1104,7 @@ const shapeSetWithRoundness = (roundness) => {
|
|
|
1098
1104
|
};
|
|
1099
1105
|
/** The shape set of clip(): states `circle`, `ellipse`, `heart` … `puzzle` (see `lucideShapeOutlines`). */
|
|
1100
1106
|
const clipShapes = shapeSetWithRoundness(1);
|
|
1101
|
-
return { lucideShapeOutlines, clipShapes };
|
|
1107
|
+
return { clipShapeNames, lucideShapeOutlines, clipShapes };
|
|
1102
1108
|
})();
|
|
1103
1109
|
|
|
1104
1110
|
// svg.ts
|
|
@@ -1143,6 +1149,8 @@ const { clip } = (() => {
|
|
|
1143
1149
|
// outlined (only a band along its edge shows). Filled → CSS `clip-path: url(#id)`; outlined → `mask: url(#id)`
|
|
1144
1150
|
// (clip-path ignores line width). The <clipPath> / <mask> live in one hidden <svg> per clip.
|
|
1145
1151
|
const GRID_SIZE = 24;
|
|
1152
|
+
/** Default size: this share of the element's shorter side (a square that fits, with room around it). */
|
|
1153
|
+
const DEFAULT_SIZE_SHARE = 0.7;
|
|
1146
1154
|
const GRID_CENTER = 12;
|
|
1147
1155
|
const DEGREE = Math.PI / 180;
|
|
1148
1156
|
/** Masks and their clip regions reach far past the element, so bands and turned shapes are never cut by them. */
|
|
@@ -1171,7 +1179,7 @@ const checkedOutline = (outline) => {
|
|
|
1171
1179
|
};
|
|
1172
1180
|
/** Cuts `element` out by a morphing shape, `init` first. */
|
|
1173
1181
|
const clip = (element, init, options = {}) => {
|
|
1174
|
-
const {
|
|
1182
|
+
const { x = 50, y = 50, size, rotation = 0, roundness = 1, outline = false, inverted = false, ...defaultMorphOptions } = options;
|
|
1175
1183
|
const checkedState = (shapeSet, state) => {
|
|
1176
1184
|
if (!(state in shapeSet.strokes)) {
|
|
1177
1185
|
throw new Error(`morphico: unknown shape "${state}" (known: ${Object.keys(shapeSet.strokes).join(', ')})`);
|
|
@@ -1184,10 +1192,10 @@ const clip = (element, init, options = {}) => {
|
|
|
1184
1192
|
}
|
|
1185
1193
|
/** Where the change goes (or what shows when nothing moves). */
|
|
1186
1194
|
const target = {
|
|
1187
|
-
state: checkedState(
|
|
1195
|
+
state: checkedState(clipShapes, checkedInit(init, 'clip')), set: resolveIconSet(clipShapes, roundness), roundness,
|
|
1188
1196
|
x, y, size, rotation, outline: checkedOutline(outline), inverted,
|
|
1189
1197
|
};
|
|
1190
|
-
const pieceLength = pieceLengthOf(
|
|
1198
|
+
const pieceLength = pieceLengthOf(clipShapes);
|
|
1191
1199
|
let frame = null; // null = resting at the target
|
|
1192
1200
|
let running = null;
|
|
1193
1201
|
let elementWidth = 0, elementHeight = 0;
|
|
@@ -1256,7 +1264,7 @@ const clip = (element, init, options = {}) => {
|
|
|
1256
1264
|
const restingPlacement = () => ({
|
|
1257
1265
|
centerX: lengthToPixels(target.x, elementWidth, 'x'),
|
|
1258
1266
|
centerY: lengthToPixels(target.y, elementHeight, 'y'),
|
|
1259
|
-
side: target.size === undefined ? Math.min(elementWidth, elementHeight) : lengthToPixels(target.size, elementWidth, 'size'),
|
|
1267
|
+
side: target.size === undefined ? DEFAULT_SIZE_SHARE * Math.min(elementWidth, elementHeight) : lengthToPixels(target.size, elementWidth, 'size'),
|
|
1260
1268
|
});
|
|
1261
1269
|
const restingFrame = () => ({ shape: shapesOf(target.set)[target.state], rotation: target.rotation, placement: restingPlacement() });
|
|
1262
1270
|
/** The shape in element pixels: scaled to its square, turned around the square's centre, moved into place. */
|
|
@@ -1313,7 +1321,7 @@ const clip = (element, init, options = {}) => {
|
|
|
1313
1321
|
target.state = checkedState(target.set, changes.state);
|
|
1314
1322
|
if (changes.roundness !== undefined && changes.roundness !== target.roundness) {
|
|
1315
1323
|
target.roundness = changes.roundness;
|
|
1316
|
-
target.set = resolveIconSet(
|
|
1324
|
+
target.set = resolveIconSet(clipShapes, changes.roundness);
|
|
1317
1325
|
}
|
|
1318
1326
|
if (changes.x !== undefined)
|
|
1319
1327
|
target.x = changes.x;
|
|
@@ -1913,7 +1921,6 @@ const BLINK_SHUT = 50;
|
|
|
1913
1921
|
const BLINK_OPENING = 150;
|
|
1914
1922
|
const AUTO_BLINK_MIN_PAUSE = 2500;
|
|
1915
1923
|
const AUTO_BLINK_EXTRA_PAUSE = 3500;
|
|
1916
|
-
const DEFAULT_FACE_DURATION = DEFAULT_DURATION + 100;
|
|
1917
1924
|
/** Expressions whose eyes are already shut: blinking does nothing. */
|
|
1918
1925
|
const EYES_SHUT = ['asleep', 'laughing'];
|
|
1919
1926
|
let faceCount = 0;
|
|
@@ -1965,7 +1972,7 @@ const face = (element, init, options = {}) => {
|
|
|
1965
1972
|
updateLabel();
|
|
1966
1973
|
const fromPieces = shownPieces;
|
|
1967
1974
|
const toPieces = expressions[nextState];
|
|
1968
|
-
const duration = morphOptions.duration ??
|
|
1975
|
+
const duration = morphOptions.duration ?? DEFAULT_DURATION;
|
|
1969
1976
|
if (prefersReducedMotion() || duration <= 0) {
|
|
1970
1977
|
shownPieces = toPieces;
|
|
1971
1978
|
render();
|
|
@@ -2101,8 +2108,9 @@ return { icon };
|
|
|
2101
2108
|
const { text } = (() => {
|
|
2102
2109
|
// Layer 2: a line of characters (clock, counter, date) in narrow cells; changed digits morph.
|
|
2103
2110
|
// Every character reuses the 24×24 icon drawing; only the viewBox is narrowed to its cell.
|
|
2104
|
-
/** Characters `text()` can show: digits, space, `-` `:` `.` `,`
|
|
2105
|
-
|
|
2111
|
+
/** Characters `text()` can show: digits, space, `-` `:` `.` `,` `/`, `+` `%` `$` `€` `£` — all of them morph. Anything
|
|
2112
|
+
* else is removed. */
|
|
2113
|
+
const UNSUPPORTED_CHARACTERS = /[^0-9 :.,\/+%$€£-]/g;
|
|
2106
2114
|
/** Vertical part of the 24×24 grid shown in a cell: y 3…21 holds every digit including its stroke. */
|
|
2107
2115
|
const CELL_TOP = 3;
|
|
2108
2116
|
const CELL_HEIGHT = 18;
|
|
@@ -2163,11 +2171,11 @@ const text = (element, init, options) => {
|
|
|
2163
2171
|
if (sameLayout) {
|
|
2164
2172
|
const morphs = cells.map((cell, index) => cell.morphingPath.morphTo(characters[index], { ...defaultMorphOptions, ...morphOptions }));
|
|
2165
2173
|
const finishedValue = value;
|
|
2166
|
-
change = Promise.all(morphs).then((results) => ({
|
|
2174
|
+
change = Promise.all(morphs).then((results) => ({ state: finishedValue, interrupted: results.some((result) => result.interrupted) }));
|
|
2167
2175
|
}
|
|
2168
2176
|
else {
|
|
2169
2177
|
rebuild(characters);
|
|
2170
|
-
change = Promise.resolve({ value, interrupted: false });
|
|
2178
|
+
change = Promise.resolve({ state: value, interrupted: false });
|
|
2171
2179
|
}
|
|
2172
2180
|
if (onEnd)
|
|
2173
2181
|
change.then(onEnd);
|
|
@@ -2189,7 +2197,7 @@ return { text };
|
|
|
2189
2197
|
// index.ts
|
|
2190
2198
|
// morphico public API.
|
|
2191
2199
|
/** Package version, e.g. "0.1.0" (tools/build.ts replaces 'dev'). */
|
|
2192
|
-
const version = '0.
|
|
2200
|
+
const version = '0.6.0';
|
|
2193
2201
|
|
|
2194
2202
|
// sets/lucide.ts
|
|
2195
2203
|
const { LUCIDE_SCALE, LUCIDE_STROKE_WIDTH, fromLucide, lucideLength, lucideLine, lucideArc, lucideCubic, lucidePoint, LUCIDE_SLASH } = (() => {
|
|
@@ -2308,18 +2316,187 @@ const iconsCheckbox = buildCheckboxIcons(LUCIDE_RADIUS);
|
|
|
2308
2316
|
return { iconsCheckbox };
|
|
2309
2317
|
})();
|
|
2310
2318
|
|
|
2319
|
+
// sets/symbols.ts
|
|
2320
|
+
const { symbolPairLayouts, symbolStrokes } = (() => {
|
|
2321
|
+
// The symbols of the digit sets: `+` `%` `$` `€` `£` (for prices and discounts: `€39.99`, `-20%`). No reference
|
|
2322
|
+
// images: drawn from each set's own box (where its digits stand) and corner style, so they match the digits — round
|
|
2323
|
+
// sets (round, slim, handwritten) get elliptical bowls like their 0, 3 and 8; boxy sets (square, condensed) rounded
|
|
2324
|
+
// corners with the set's radius. Every symbol is at most three pieces: one continuous line each (see characters.ts).
|
|
2325
|
+
/**
|
|
2326
|
+
* How symbol pairs lay out their pieces (first, second, third piece), from the user's ratings (2026-11-03; pairs rated
|
|
2327
|
+
* good use the default and are left out):
|
|
2328
|
+
* - `+` → `€` / `£`: the upright bar bends into the C / the £'s line, the cross bar becomes the bar (tracings swap
|
|
2329
|
+
* which of the two pieces draws which bar).
|
|
2330
|
+
* - `%` → `$` / `€` / `£`: the slash runs from the top right, where S, C and the £'s hook start; the rings are pressed
|
|
2331
|
+
* flat onto the bars (`flatten`, as digits onto `-`); the lower ring, where `$` / `£` have no bar, is erased like a pen
|
|
2332
|
+
* in the first 60 % (`draw`, as the weather's rays) instead of shrinking into a dot.
|
|
2333
|
+
* - `£` ↔ `€`: the £'s base is drawn out to the left first, ending at the right like the C (with `$` it ends at the
|
|
2334
|
+
* left like the S).
|
|
2335
|
+
* - `£` / `+` → `€`: both bars of `€` come out of the one bar of `£` / `+` (the crossbar / the cross bar), which
|
|
2336
|
+
* traces its third piece as a hidden copy of that bar (user: the two lines must merge into one; growing out of the
|
|
2337
|
+
* resting point in the middle showed as a blob, drawing the lower bar in like a pen didn't merge).
|
|
2338
|
+
*/
|
|
2339
|
+
const symbolPairLayouts = [
|
|
2340
|
+
{
|
|
2341
|
+
'+': { '€': { tracing: 'plus-upright' }, '£': { tracing: 'plus-upright' } },
|
|
2342
|
+
'%': { $: { reversed: true }, '€': { reversed: true }, '£': { reversed: true } },
|
|
2343
|
+
'£': { '€': { tracing: 'pound-base-left-first' } },
|
|
2344
|
+
},
|
|
2345
|
+
{
|
|
2346
|
+
'+': { '€': { tracing: 'plus-across' }, '£': { tracing: 'plus-across' } },
|
|
2347
|
+
$: { '%': { flatten: true } },
|
|
2348
|
+
'€': { '%': { flatten: true } },
|
|
2349
|
+
'£': { '%': { flatten: true } },
|
|
2350
|
+
},
|
|
2351
|
+
{
|
|
2352
|
+
'+': { '€': { tracing: 'plus-across' } },
|
|
2353
|
+
$: { '%': { draw: 0.6 } },
|
|
2354
|
+
'€': { '%': { flatten: true } },
|
|
2355
|
+
'£': { '%': { draw: 0.6 }, '€': { tracing: 'pound-crossbar' } },
|
|
2356
|
+
},
|
|
2357
|
+
];
|
|
2358
|
+
const DEGREE = Math.PI / 180;
|
|
2359
|
+
/**
|
|
2360
|
+
* Part of an ellipse as cubics of at most 90° each. Angles in degrees (0 = right, 90 = down: y points down);
|
|
2361
|
+
* `endAngle > startAngle` runs clockwise on screen. Each cubic matches the ellipse at both ends (an exact circle's
|
|
2362
|
+
* quarter handles, stretched).
|
|
2363
|
+
*/
|
|
2364
|
+
const ellipticArc = (centerX, centerY, radiusX, radiusY, startAngle, endAngle) => {
|
|
2365
|
+
const count = Math.max(1, Math.ceil(Math.abs(endAngle - startAngle) / 90 - 1e-9));
|
|
2366
|
+
const step = (endAngle - startAngle) / count;
|
|
2367
|
+
const handle = (4 / 3) * Math.tan((step * DEGREE) / 4);
|
|
2368
|
+
const pointAt = (angle) => [centerX + radiusX * Math.cos(angle * DEGREE), centerY + radiusY * Math.sin(angle * DEGREE)];
|
|
2369
|
+
const directionAt = (angle) => [-radiusX * Math.sin(angle * DEGREE), radiusY * Math.cos(angle * DEGREE)];
|
|
2370
|
+
return Array.from({ length: count }, (_, index) => {
|
|
2371
|
+
const from = startAngle + step * index;
|
|
2372
|
+
const to = from + step;
|
|
2373
|
+
const [startX, startY] = pointAt(from);
|
|
2374
|
+
const [endX, endY] = pointAt(to);
|
|
2375
|
+
const [startDirectionX, startDirectionY] = directionAt(from);
|
|
2376
|
+
const [endDirectionX, endDirectionY] = directionAt(to);
|
|
2377
|
+
return cubic(startX, startY, startX + handle * startDirectionX, startY + handle * startDirectionY, endX - handle * endDirectionX, endY - handle * endDirectionY, endX, endY);
|
|
2378
|
+
});
|
|
2379
|
+
};
|
|
2380
|
+
/** A small closed loop (the rings of `%`): a circle, or a rounded box for boxy sets — clockwise from the top. */
|
|
2381
|
+
const ring = (style, centerX, centerY, radius) => {
|
|
2382
|
+
if (style.corners === 'round')
|
|
2383
|
+
return ellipticArc(centerX, centerY, radius, radius, -90, 270);
|
|
2384
|
+
const corner = Math.min(style.corners, radius);
|
|
2385
|
+
const [left, right, top, bottom] = [centerX - radius, centerX + radius, centerY - radius, centerY + radius];
|
|
2386
|
+
return roundedPolyline([[centerX, top], [right, top], [right, bottom], [left, bottom], [left, top], [centerX, top]], [0, corner, corner, corner, corner, 0]);
|
|
2387
|
+
};
|
|
2388
|
+
/** `+` `%` `$` `€` `£` drawn in a set's style. */
|
|
2389
|
+
const symbolStrokes = (style) => {
|
|
2390
|
+
const { left, right, top, bottom } = style;
|
|
2391
|
+
const width = right - left;
|
|
2392
|
+
const height = bottom - top;
|
|
2393
|
+
const centerX = (left + right) / 2;
|
|
2394
|
+
const middleY = (top + bottom) / 2;
|
|
2395
|
+
const round = style.corners === 'round';
|
|
2396
|
+
/** Corner radius of a boxy set, never more than a box of that size allows. */
|
|
2397
|
+
const cornerFor = (boxWidth, boxHeight) => Math.min(round ? 0 : style.corners, boxWidth / 2, boxHeight / 2);
|
|
2398
|
+
// + : the same bar as `-` (so `-` ↔ `+` only stands one bar up), crossed by an upright one of the same length
|
|
2399
|
+
const plusAcross = line(9.5, 12, 14.5, 12);
|
|
2400
|
+
const plusUpright = line(12, 9.5, 12, 14.5);
|
|
2401
|
+
const plus = [[plusAcross], [plusUpright]];
|
|
2402
|
+
// % : slash from the bottom left to the top right, a ring at the top left and one at the bottom right
|
|
2403
|
+
const ringRadius = Math.min(width * 0.2, height * 0.13);
|
|
2404
|
+
const percent = [
|
|
2405
|
+
[line(left + width * 0.08, bottom, right - width * 0.08, top)],
|
|
2406
|
+
ring(style, left + ringRadius, top + ringRadius + height * 0.04, ringRadius),
|
|
2407
|
+
ring(style, right - ringRadius, bottom - ringRadius - height * 0.04, ringRadius),
|
|
2408
|
+
];
|
|
2409
|
+
// $ : an S as tall as the digits, the bar through it a little longer
|
|
2410
|
+
const sLeft = left + width * 0.06;
|
|
2411
|
+
const sRight = right - width * 0.06;
|
|
2412
|
+
const sWidth = sRight - sLeft;
|
|
2413
|
+
let dollarS;
|
|
2414
|
+
if (round) {
|
|
2415
|
+
const quarterHeight = height / 4;
|
|
2416
|
+
dollarS = [
|
|
2417
|
+
...ellipticArc(centerX, top + quarterHeight, sWidth / 2, quarterHeight, -30, -270),
|
|
2418
|
+
...ellipticArc(centerX, bottom - quarterHeight, sWidth / 2, quarterHeight, 270, 510),
|
|
2419
|
+
];
|
|
2420
|
+
}
|
|
2421
|
+
else {
|
|
2422
|
+
const corner = cornerFor(sWidth, height / 2);
|
|
2423
|
+
const hook = Math.max(corner, height * 0.15);
|
|
2424
|
+
dollarS = roundedPolyline([[sRight, top + hook], [sRight, top], [sLeft, top], [sLeft, middleY], [sRight, middleY], [sRight, bottom], [sLeft, bottom], [sLeft, bottom - hook]], [0, corner, corner, corner, corner, corner, corner, 0]);
|
|
2425
|
+
}
|
|
2426
|
+
const dollar = [dollarS, [line(centerX, top - 1.2, centerX, bottom + 1.2)]];
|
|
2427
|
+
// € : a C opened to the right (moved right a little), two bars sticking out of its left side
|
|
2428
|
+
const cLeft = left + width * 0.14;
|
|
2429
|
+
let euroC;
|
|
2430
|
+
if (round) {
|
|
2431
|
+
const radiusX = (right - cLeft) / 2;
|
|
2432
|
+
euroC = ellipticArc(cLeft + radiusX, middleY, radiusX, height / 2, -48, -312);
|
|
2433
|
+
}
|
|
2434
|
+
else {
|
|
2435
|
+
const corner = cornerFor(right - cLeft, height);
|
|
2436
|
+
euroC = roundedPolyline([[right, top], [cLeft, top], [cLeft, bottom], [right, bottom]], [0, corner, corner, 0]);
|
|
2437
|
+
}
|
|
2438
|
+
const barGap = height * 0.12;
|
|
2439
|
+
const barEnd = centerX + width * 0.12;
|
|
2440
|
+
const euro = [
|
|
2441
|
+
euroC,
|
|
2442
|
+
[line(left - width * 0.06, middleY - barGap, barEnd, middleY - barGap)],
|
|
2443
|
+
[line(left - width * 0.06, middleY + barGap, barEnd, middleY + barGap)],
|
|
2444
|
+
];
|
|
2445
|
+
// £ : a hook at the top right running into the stem, a base line out to both sides (drawn out to the right and back,
|
|
2446
|
+
// the way the S of $ ends, so they morph into each other without twisting; with € the other way round), a crossbar
|
|
2447
|
+
const stemX = left + width * 0.3;
|
|
2448
|
+
const hookRight = right - width * 0.08;
|
|
2449
|
+
const poundLineWithBase = (firstSide, secondSide) => {
|
|
2450
|
+
if (round) {
|
|
2451
|
+
const hookRadius = (hookRight - stemX) / 2;
|
|
2452
|
+
return [
|
|
2453
|
+
...ellipticArc(stemX + hookRadius, top + hookRadius, hookRadius, hookRadius, 20, -180),
|
|
2454
|
+
line(stemX, top + hookRadius, stemX, bottom),
|
|
2455
|
+
line(stemX, bottom, firstSide, bottom),
|
|
2456
|
+
line(firstSide, bottom, secondSide, bottom),
|
|
2457
|
+
];
|
|
2458
|
+
}
|
|
2459
|
+
const corner = cornerFor(hookRight - stemX, height / 2);
|
|
2460
|
+
const hook = Math.max(corner, height * 0.15);
|
|
2461
|
+
return roundedPolyline([[hookRight, top + hook], [hookRight, top], [stemX, top], [stemX, bottom], [firstSide, bottom], [secondSide, bottom]], [0, corner, corner, 0, 0, 0]);
|
|
2462
|
+
};
|
|
2463
|
+
const poundLine = poundLineWithBase(right, left);
|
|
2464
|
+
const poundCrossbar = line(left + width * 0.05, middleY + height * 0.04, stemX + width * 0.32, middleY + height * 0.04);
|
|
2465
|
+
const pound = [poundLine, [poundCrossbar]];
|
|
2466
|
+
return {
|
|
2467
|
+
pieces: { '+': plus, '%': percent, $: dollar, '€': euro, '£': pound },
|
|
2468
|
+
firstPieceTracings: { 'plus-upright': [plusUpright], 'pound-base-left-first': poundLineWithBase(left, right) },
|
|
2469
|
+
secondPieceTracings: { 'plus-across': [plusAcross] },
|
|
2470
|
+
thirdPieceTracings: { 'plus-across': [plusAcross], 'pound-crossbar': [poundCrossbar] },
|
|
2471
|
+
};
|
|
2472
|
+
};
|
|
2473
|
+
return { symbolPairLayouts, symbolStrokes };
|
|
2474
|
+
})();
|
|
2475
|
+
|
|
2311
2476
|
// sets/characters.ts
|
|
2312
2477
|
const { withTextCharacters } = (() => {
|
|
2313
|
-
// The characters every digit set shares besides 0–9: `-` `/` `.` `,` `:` (space = the empty state, see morph.ts)
|
|
2478
|
+
// The characters every digit set shares besides 0–9: `-` `/` `.` `,` `:` (space = the empty state, see morph.ts),
|
|
2479
|
+
// plus the symbols `+` `%` `$` `€` `£` drawn in the set's own style (symbols.ts).
|
|
2314
2480
|
// Each is drawn as one straight line, placed by the set's text layout and stroke width, and morphs to and from
|
|
2315
2481
|
// every digit by flattening (the user's choice 2026-10-27): the digit is pressed flat onto the line.
|
|
2316
|
-
// `:` has two dots, so digit sets get a second
|
|
2317
|
-
// (same strokes and layouts, drawn on top of itself, so
|
|
2482
|
+
// `:` has two dots and the symbols up to three parts, so digit sets get a second and a third piece. The second
|
|
2483
|
+
// repeats the first piece exactly for every state with one part (same strokes and layouts, drawn on top of itself, so
|
|
2484
|
+
// it doesn't show; a digit morphing into `:` splits into the two dots). The third is only `€`'s lower bar and `%`'s
|
|
2485
|
+
// lower ring: every other state rests it as a single point in the middle (never drawn), so it grows out of there
|
|
2486
|
+
// instead of a whole copy shrinking into it. Symbols morph with the default pairing, except the pairs in
|
|
2487
|
+
// `symbolPairLayouts`.
|
|
2318
2488
|
const DIGITS = [...'0123456789'];
|
|
2319
2489
|
/** Half the length of a dot's line, relative to the stroke width: round ends make it a dot 1.1 × the stroke wide. */
|
|
2320
2490
|
const DOT_HALF_LENGTH = 0.05;
|
|
2321
|
-
/**
|
|
2322
|
-
const
|
|
2491
|
+
/** The layouts of a piece plus more pairs (merged per state). */
|
|
2492
|
+
const withMorePairs = (layouts, morePairs) => {
|
|
2493
|
+
const merged = { ...layouts };
|
|
2494
|
+
for (const [state, byOtherState] of Object.entries(morePairs))
|
|
2495
|
+
merged[state] = { ...merged[state], ...byOtherState };
|
|
2496
|
+
return merged;
|
|
2497
|
+
};
|
|
2498
|
+
/** Adds `-` `/` `.` `,` `:` and the symbols (in `symbolStyle`) to a digit set (which needs a text layout) as morphing states. */
|
|
2499
|
+
const withTextCharacters = (iconSet, symbolStyle) => {
|
|
2323
2500
|
const { baselineY, colonDotsY } = iconSet.textLayout;
|
|
2324
2501
|
const dotHalfLength = iconSet.strokeWidth * DOT_HALF_LENGTH;
|
|
2325
2502
|
const dotY = baselineY; // dot centre on the line the digits stand on
|
|
@@ -2331,24 +2508,32 @@ const withTextCharacters = (iconSet) => {
|
|
|
2331
2508
|
',': [line(12.3, dotY, 11, baselineY + 2.2)], // from the dot down to the left
|
|
2332
2509
|
':': [dot(colonDotsY[0])],
|
|
2333
2510
|
};
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2511
|
+
const pairLayouts = withMorePairs(iconSet.pairLayouts, Object.fromEntries(Object.keys(characters).map((character) => [character, Object.fromEntries(DIGITS.map((digit) => [digit, { flatten: true }]))])));
|
|
2512
|
+
const drawings = symbolStrokes(symbolStyle);
|
|
2513
|
+
/** A tracing is only used with breakpoints (geometry.ts shapeForPair): give the symbols' tracings the default ones. */
|
|
2514
|
+
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
|
|
2515
|
+
? { ...layout, breakpoints: defaultBreakpoints(tracings[layout.tracing], iconSet.segmentCount) }
|
|
2516
|
+
: layout]))]));
|
|
2517
|
+
const symbols = Object.entries(drawings.pieces);
|
|
2518
|
+
const strokes = { ...iconSet.strokes, ...characters, ...Object.fromEntries(symbols.map(([symbol, [first]]) => [symbol, first])) };
|
|
2519
|
+
const partsAt = (index) => Object.fromEntries(symbols.flatMap(([symbol, pieces]) => (pieces[index] ? [[symbol, pieces[index]]] : [])));
|
|
2520
|
+
const secondPiece = {
|
|
2521
|
+
strokes: { ...strokes, ':': [dot(colonDotsY[1])], ...partsAt(1) },
|
|
2522
|
+
alternativeStrokes: { ...iconSet.alternativeStrokes, ...drawings.secondPieceTracings },
|
|
2523
|
+
pairLayouts: withMorePairs(pairLayouts, withTracingBreakpoints(symbolPairLayouts[1], drawings.secondPieceTracings)),
|
|
2524
|
+
};
|
|
2525
|
+
// only the symbols' layouts here: the digits' tracings would draw a whole digit in place of the resting point
|
|
2526
|
+
const thirdPiece = {
|
|
2527
|
+
strokes: { ...Object.fromEntries(Object.keys(strokes).map((state) => [state, [line(12, 12, 12, 12)]])), ...partsAt(2) },
|
|
2528
|
+
alternativeStrokes: drawings.thirdPieceTracings,
|
|
2529
|
+
pairLayouts: withTracingBreakpoints(symbolPairLayouts[2], drawings.thirdPieceTracings),
|
|
2340
2530
|
};
|
|
2341
|
-
const pairLayouts = flattenPairs(iconSet.pairLayouts);
|
|
2342
|
-
const strokes = { ...iconSet.strokes, ...characters };
|
|
2343
2531
|
return {
|
|
2344
2532
|
...iconSet,
|
|
2345
2533
|
strokes,
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
alternativeStrokes: iconSet.alternativeStrokes,
|
|
2350
|
-
pairLayouts,
|
|
2351
|
-
}],
|
|
2534
|
+
alternativeStrokes: { ...iconSet.alternativeStrokes, ...drawings.firstPieceTracings },
|
|
2535
|
+
pairLayouts: withMorePairs(pairLayouts, withTracingBreakpoints(symbolPairLayouts[0], drawings.firstPieceTracings)),
|
|
2536
|
+
morePieces: [secondPiece, thirdPiece],
|
|
2352
2537
|
};
|
|
2353
2538
|
};
|
|
2354
2539
|
return { withTextCharacters };
|
|
@@ -2384,7 +2569,8 @@ const HOOK_END_Y = 79;
|
|
|
2384
2569
|
// the 6: hook at the top right, over the top, down the left side, round the bottom, up to the middle bar, back left
|
|
2385
2570
|
const SIX_POINTS = [[47, 94 - HOOK_END_Y], [47, 3], [3, 3], [3, 91], [47, 91], [47, 47], [3, 47]];
|
|
2386
2571
|
const SIX_RADII = [0, OUTER_RADIUS, OUTER_RADIUS, OUTER_RADIUS, OUTER_RADIUS, MIDDLE_RADIUS, 0];
|
|
2387
|
-
// '-' '/' '.' ',' ':'
|
|
2572
|
+
// '-' '/' '.' ',' ':' and the symbols '+' '%' '$' '€' '£' (in this set's box and corners) are added by
|
|
2573
|
+
// withTextCharacters (characters.ts, symbols.ts)
|
|
2388
2574
|
const digitsCondensed = withTextCharacters({
|
|
2389
2575
|
segmentCount: 20,
|
|
2390
2576
|
strokeWidth: 6 / PIXELS_PER_UNIT,
|
|
@@ -2489,7 +2675,7 @@ const digitsCondensed = withTextCharacters({
|
|
|
2489
2675
|
},
|
|
2490
2676
|
spins: { 6: { 9: 180 }, 9: { 6: -180 } },
|
|
2491
2677
|
textLayout: { cellWidth: 8, spacing: 3.5, baselineY: 20, colonDotsY: [8, 16] },
|
|
2492
|
-
});
|
|
2678
|
+
}, { left: 8, right: 16, top: 4, bottom: 20, corners: CORNER_RADIUS / PIXELS_PER_UNIT });
|
|
2493
2679
|
return { digitsCondensed };
|
|
2494
2680
|
})();
|
|
2495
2681
|
|
|
@@ -2579,7 +2765,8 @@ const { digitsHandwritten } = (() => {
|
|
|
2579
2765
|
// the centre line — the marker stroke varies a little, so the pixel match is ~8–17 %).
|
|
2580
2766
|
// - every digit is one stroke of 3–7 free cubic curves; round ends and corners
|
|
2581
2767
|
// - the 4 is drawn out and back over its crossbar end and right stem (one continuous stroke)
|
|
2582
|
-
// '-' '/' '.' ',' ':'
|
|
2768
|
+
// '-' '/' '.' ',' ':' and the symbols '+' '%' '$' '€' '£' (in this set's box and corners) are added by
|
|
2769
|
+
// withTextCharacters (characters.ts, symbols.ts)
|
|
2583
2770
|
const digitsHandwritten = withTextCharacters({
|
|
2584
2771
|
segmentCount: 16,
|
|
2585
2772
|
strokeWidth: 1.04,
|
|
@@ -2701,7 +2888,7 @@ const digitsHandwritten = withTextCharacters({
|
|
|
2701
2888
|
},
|
|
2702
2889
|
spins: {},
|
|
2703
2890
|
textLayout: { cellWidth: 9, spacing: 4, baselineY: 20.2, colonDotsY: [8, 16] },
|
|
2704
|
-
});
|
|
2891
|
+
}, { left: 7.5, right: 16.5, top: 4.2, bottom: 19.8, corners: 'round' });
|
|
2705
2892
|
return { digitsHandwritten };
|
|
2706
2893
|
})();
|
|
2707
2894
|
|
|
@@ -2903,7 +3090,8 @@ const TWO_DIAGONAL_ANGLE = 39.5191;
|
|
|
2903
3090
|
const FIVE_JOIN_ANGLE = 237.2;
|
|
2904
3091
|
/** The 7's foot: on the measured diagonal (16, 4.2 → 7.45, 20.6), pulled in to the base line. */
|
|
2905
3092
|
const SEVEN_FOOT = pointAtY([16, TOP_BAR_Y], [7.45, 20.6], BASE_Y);
|
|
2906
|
-
// '-' '/' '.' ',' ':'
|
|
3093
|
+
// '-' '/' '.' ',' ':' and the symbols '+' '%' '$' '€' '£' (in this set's box and corners) are added by
|
|
3094
|
+
// withTextCharacters (characters.ts, symbols.ts)
|
|
2907
3095
|
const digitsRound = withTextCharacters({
|
|
2908
3096
|
segmentCount: 12,
|
|
2909
3097
|
strokeWidth: STROKE_WIDTH,
|
|
@@ -3109,7 +3297,7 @@ const digitsRound = withTextCharacters({
|
|
|
3109
3297
|
9: { 6: -180, 8: -180 },
|
|
3110
3298
|
},
|
|
3111
3299
|
textLayout: { cellWidth: 10, spacing: 4, baselineY: 19.8, colonDotsY: [7.6, 15.6] },
|
|
3112
|
-
});
|
|
3300
|
+
}, { left: 7, right: 17, top: 4.2, bottom: 19.8, corners: 'round' });
|
|
3113
3301
|
return { digitsRound };
|
|
3114
3302
|
})();
|
|
3115
3303
|
|
|
@@ -3149,7 +3337,8 @@ const SIX = [
|
|
|
3149
3337
|
topArc(SIX_HOOK_ANGLE, -180),
|
|
3150
3338
|
...roundedPolyline([[8, 8], [8, 20], [16, 20], [16, SIX_LOOP_TOP], [8, SIX_LOOP_TOP], [8, SIX_LOOP_TOP + RADIUS]], [0, RADIUS, RADIUS, RADIUS, RADIUS, 0]),
|
|
3151
3339
|
];
|
|
3152
|
-
// '-' '/' '.' ',' ':'
|
|
3340
|
+
// '-' '/' '.' ',' ':' and the symbols '+' '%' '$' '€' '£' (in this set's box and corners) are added by
|
|
3341
|
+
// withTextCharacters (characters.ts, symbols.ts)
|
|
3153
3342
|
const digitsSlim = withTextCharacters({
|
|
3154
3343
|
segmentCount: 16,
|
|
3155
3344
|
strokeWidth: 6 / 5.5,
|
|
@@ -3259,7 +3448,7 @@ const digitsSlim = withTextCharacters({
|
|
|
3259
3448
|
// 9 is exactly 6 turned 180°; 2 → 6 also turns (it is 2 → 9 in the turning frame)
|
|
3260
3449
|
spins: { 2: { 6: 180 }, 6: { 9: 180, 2: -180 }, 9: { 6: -180 } },
|
|
3261
3450
|
textLayout: { cellWidth: 9.5, spacing: 4, baselineY: 20, colonDotsY: [8, 16] },
|
|
3262
|
-
});
|
|
3451
|
+
}, { left: 8, right: 16, top: 4, bottom: 20, corners: 'round' });
|
|
3263
3452
|
return { digitsSlim };
|
|
3264
3453
|
})();
|
|
3265
3454
|
|
|
@@ -3292,7 +3481,8 @@ const EIGHT_RADIUS = 6;
|
|
|
3292
3481
|
// the 6: hook from the top right, round the left side, then the closed bottom loop back to the left side
|
|
3293
3482
|
const SIX_POINTS = [[15, 2], [2, 2], [2, 26], [19, 26], [19, 12], [2, 12]];
|
|
3294
3483
|
const SIX_RADII = [0, SIX_RADIUS, SIX_RADIUS, SIX_RADIUS, SIX_RADIUS, 0];
|
|
3295
|
-
// '-' '/' '.' ',' ':'
|
|
3484
|
+
// '-' '/' '.' ',' ':' and the symbols '+' '%' '$' '€' '£' (in this set's box and corners) are added by
|
|
3485
|
+
// withTextCharacters (characters.ts, symbols.ts)
|
|
3296
3486
|
const digitsSquare = withTextCharacters({
|
|
3297
3487
|
segmentCount: 20,
|
|
3298
3488
|
strokeWidth: STROKE_WIDTH,
|
|
@@ -3410,7 +3600,7 @@ const digitsSquare = withTextCharacters({
|
|
|
3410
3600
|
},
|
|
3411
3601
|
spins: { 6: { 9: 180 }, 9: { 6: -180 } },
|
|
3412
3602
|
textLayout: { cellWidth: 13.5, spacing: 4, baselineY: 20, colonDotsY: [8, 16] },
|
|
3413
|
-
});
|
|
3603
|
+
}, { left: 6.33, right: 17.67, top: 4, bottom: 20, corners: 4 });
|
|
3414
3604
|
return { digitsSquare };
|
|
3415
3605
|
})();
|
|
3416
3606
|
|
|
@@ -4655,5 +4845,5 @@ const iconSets = {
|
|
|
4655
4845
|
return { iconSets };
|
|
4656
4846
|
})();
|
|
4657
4847
|
|
|
4658
|
-
return { clip, easings, face, icon, faceExpressionNames, text, version, iconSets };
|
|
4848
|
+
return { clip, easings, face, icon, faceExpressionNames, clipShapeNames, text, version, iconSets };
|
|
4659
4849
|
})();
|
package/dist/types/clip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MorphOptions, MorphResult } from './morph.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ClipShape } from './sets/shapes.js';
|
|
3
3
|
/** A length: a number = % (of the element's width for x and size, of its height for y), or `'40%'` / `'120px'`. */
|
|
4
4
|
export type Length = number | string;
|
|
5
5
|
/** Only a band along the shape's edge shows. */
|
|
@@ -15,7 +15,7 @@ export interface ClipChanges {
|
|
|
15
15
|
x?: Length;
|
|
16
16
|
/** Centre of the shape, from the element's top edge (default 50 = the middle). */
|
|
17
17
|
y?: Length;
|
|
18
|
-
/** Side of the shape's square (default:
|
|
18
|
+
/** Side of the shape's square (default: 70 % of the element's shorter side). */
|
|
19
19
|
size?: Length;
|
|
20
20
|
/** Turn in degrees, clockwise; absolute (`rotation: 360` ends one full turn from 0). */
|
|
21
21
|
rotation?: number;
|
|
@@ -26,10 +26,7 @@ export interface ClipChanges {
|
|
|
26
26
|
/** `true` = the other way round: the shape (or band) is a hole, the rest of the element shows (not animated). */
|
|
27
27
|
inverted?: boolean;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
30
|
-
/** The shape set (default: the built-in shapes, based on Lucide). */
|
|
31
|
-
set?: IconSet;
|
|
32
|
-
}
|
|
29
|
+
export type ClipOptions = ClipChanges & MorphOptions;
|
|
33
30
|
export interface ClipChangeOptions extends ClipChanges, MorphOptions {
|
|
34
31
|
/** Called when the change ends, with the same result the promise resolves to. */
|
|
35
32
|
onEnd?: (result: MorphResult) => void;
|
|
@@ -41,10 +38,10 @@ export interface Clip {
|
|
|
41
38
|
* change resolves with `interrupted: true`. Without animation when the user prefers reduced motion; `duration: 0`
|
|
42
39
|
* jumps (e.g. while a slider is dragged).
|
|
43
40
|
*/
|
|
44
|
-
to(state:
|
|
41
|
+
to(state: ClipShape, options?: ClipChangeOptions): Promise<MorphResult>;
|
|
45
42
|
to(changes: ClipChangeOptions): Promise<MorphResult>;
|
|
46
43
|
/** Stops, removes the hidden <svg> and gives the element back its own clip-path / mask. */
|
|
47
44
|
destroy(): void;
|
|
48
45
|
}
|
|
49
46
|
/** Cuts `element` out by a morphing shape, `init` first. */
|
|
50
|
-
export declare const clip: (element: HTMLElement | SVGElement, init:
|
|
47
|
+
export declare const clip: (element: HTMLElement | SVGElement, init: ClipShape, options?: ClipOptions) => Clip;
|
package/dist/types/icon.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface IconOptions extends MorphOptions, StyleOptions {
|
|
|
9
9
|
/** CSS width and height of the icon (default `'1em'`: it follows the font size). */
|
|
10
10
|
size?: string;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface IconChangeOptions extends MorphOptions {
|
|
13
13
|
/** Called when the morph ends, with the same result the promise resolves to. */
|
|
14
14
|
onEnd?: (result: MorphResult) => void;
|
|
15
15
|
}
|
|
@@ -18,7 +18,7 @@ export interface Icon {
|
|
|
18
18
|
* Morphs to `state` (`'0'`…`'9'`, `'-'`, or `' '` for empty). The promise resolves when the morph ends;
|
|
19
19
|
* an interrupted morph resolves with `interrupted: true`. Without animation when the user prefers reduced motion.
|
|
20
20
|
*/
|
|
21
|
-
to(state: string, options?:
|
|
21
|
+
to(state: string, options?: IconChangeOptions): Promise<MorphResult>;
|
|
22
22
|
/** Stops any morph and removes the icon from the page. */
|
|
23
23
|
destroy(): void;
|
|
24
24
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,15 +3,16 @@ export { easings } from './engine.js';
|
|
|
3
3
|
export { face } from './face.js';
|
|
4
4
|
export { icon } from './icon.js';
|
|
5
5
|
export { faceExpressionNames } from './sets/faces.js';
|
|
6
|
+
export { clipShapeNames } from './sets/shapes.js';
|
|
6
7
|
export { text } from './text.js';
|
|
7
8
|
export type { Clip, ClipChangeOptions, ClipChanges, ClipOptions, ClipOutline, Length } from './clip.js';
|
|
8
9
|
export type { Easing } from './engine.js';
|
|
9
10
|
export type { Face, FaceChangeOptions, FaceOptions } from './face.js';
|
|
10
|
-
export type {
|
|
11
|
+
export type { Icon, IconChangeOptions, IconOptions } from './icon.js';
|
|
11
12
|
export type { EasingName, MorphOptions, MorphResult } from './morph.js';
|
|
12
13
|
export type { FaceExpression } from './sets/faces.js';
|
|
14
|
+
export type { ClipShape } from './sets/shapes.js';
|
|
13
15
|
export type { StyleOptions } from './svg.js';
|
|
14
|
-
export type { Text, TextChangeOptions, TextOptions
|
|
15
|
-
export type { IconSet, TextLayout } from './types.js';
|
|
16
|
+
export type { Text, TextChangeOptions, TextOptions } from './text.js';
|
|
16
17
|
/** Package version, e.g. "0.1.0" (tools/build.ts replaces 'dev'). */
|
|
17
18
|
export declare const version: string;
|
package/dist/types/morph.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ import type { Easing } from './engine.js';
|
|
|
3
3
|
import type { IconSet, PathNumbers } from './types.js';
|
|
4
4
|
export type EasingName = keyof typeof easings;
|
|
5
5
|
export interface MorphOptions {
|
|
6
|
-
/** Length of a morph in milliseconds (default
|
|
6
|
+
/** Length of a morph in milliseconds (default 300). */
|
|
7
7
|
duration?: number;
|
|
8
8
|
/** An easing name or your own function `(progress) => easedProgress` (default `'easeInOutCubic'`). */
|
|
9
9
|
easing?: EasingName | Easing;
|
|
10
10
|
}
|
|
11
11
|
export interface MorphResult {
|
|
12
|
-
/** The state the morph was heading to. */
|
|
12
|
+
/** The state the morph was heading to (for text(): the text). */
|
|
13
13
|
state: string;
|
|
14
14
|
/** `true` when a newer morph (or `destroy()`) took over before this one finished. */
|
|
15
15
|
interrupted: boolean;
|
|
16
16
|
}
|
|
17
17
|
/** The empty state: nothing is drawn. Shapes grow out of it and shrink into it while fading. */
|
|
18
18
|
export declare const EMPTY_STATE = " ";
|
|
19
|
-
export declare const DEFAULT_DURATION =
|
|
19
|
+
export declare const DEFAULT_DURATION = 300;
|
|
20
20
|
export declare const shapesOf: (iconSet: IconSet) => Record<string, PathNumbers>;
|
|
21
21
|
export declare const hasState: (iconSet: IconSet, state: string) => boolean;
|
|
22
22
|
export declare const prefersReducedMotion: () => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { SymbolStyle } from './symbols.js';
|
|
1
2
|
import type { IconSet, TextLayout } from '../types.js';
|
|
2
|
-
/** Adds `-` `/` `.` `,` `:` to a digit set (which needs a text layout) as morphing states. */
|
|
3
|
+
/** Adds `-` `/` `.` `,` `:` and the symbols (in `symbolStyle`) to a digit set (which needs a text layout) as morphing states. */
|
|
3
4
|
export declare const withTextCharacters: (iconSet: IconSet & {
|
|
4
5
|
textLayout: TextLayout;
|
|
5
|
-
}) => IconSet;
|
|
6
|
+
}, symbolStyle: SymbolStyle) => IconSet;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { IconSet, Stroke } from '../types.js';
|
|
2
|
+
/** The names of clip()'s shapes (TypeScript checks the outlines below have exactly these). */
|
|
3
|
+
export declare const clipShapeNames: readonly ['circle', 'ellipse', 'heart', 'sparkle', 'astroid', 'bookmark', 'shield', 'moon', 'tag', 'square', 'badge', 'triangle', 'droplet', 'pentagon', 'hexagon', 'octagon', 'squircle', 'star', 'rectangle-horizontal', 'message-circle', 'message-square', 'cloud', 'puzzle', 'club'];
|
|
4
|
+
export type ClipShape = typeof clipShapeNames[number];
|
|
2
5
|
/** The shapes as Lucide draws them (Lucide coordinates); the set's states are made from these. */
|
|
3
|
-
export declare const lucideShapeOutlines: Record<
|
|
6
|
+
export declare const lucideShapeOutlines: Record<ClipShape, Stroke[]>;
|
|
4
7
|
/** The shape set of clip(): states `circle`, `ellipse`, `heart` … `puzzle` (see `lucideShapeOutlines`). */
|
|
5
8
|
export declare const clipShapes: IconSet;
|