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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PairLayout, Stroke } from '../types.js';
|
|
2
|
+
/** Where a set's digits stand (middle of the line) and how its corners look. */
|
|
3
|
+
export interface SymbolStyle {
|
|
4
|
+
left: number;
|
|
5
|
+
right: number;
|
|
6
|
+
top: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
/** `'round'` = elliptical bowls; a number = rounded corners with that radius. */
|
|
9
|
+
corners: 'round' | number;
|
|
10
|
+
}
|
|
11
|
+
/** The pieces of one symbol: piece 1, and the optional pieces 2 and 3 (left out = a copy of piece 1, invisible). */
|
|
12
|
+
export type SymbolPieces = [Stroke[], Stroke[]?, Stroke[]?];
|
|
13
|
+
/** The symbols of a set, plus alternative tracings (the same look drawn in another order) used by some pairs. */
|
|
14
|
+
export interface SymbolDrawings {
|
|
15
|
+
pieces: Record<string, SymbolPieces>;
|
|
16
|
+
firstPieceTracings: Record<string, Stroke[]>;
|
|
17
|
+
secondPieceTracings: Record<string, Stroke[]>;
|
|
18
|
+
thirdPieceTracings: Record<string, Stroke[]>;
|
|
19
|
+
}
|
|
20
|
+
type PairLayouts = Record<string, Record<string, PairLayout>>;
|
|
21
|
+
/**
|
|
22
|
+
* How symbol pairs lay out their pieces (first, second, third piece), from the user's ratings (2026-11-03; pairs rated
|
|
23
|
+
* good use the default and are left out):
|
|
24
|
+
* - `+` → `€` / `£`: the upright bar bends into the C / the £'s line, the cross bar becomes the bar (tracings swap
|
|
25
|
+
* which of the two pieces draws which bar).
|
|
26
|
+
* - `%` → `$` / `€` / `£`: the slash runs from the top right, where S, C and the £'s hook start; the rings are pressed
|
|
27
|
+
* flat onto the bars (`flatten`, as digits onto `-`); the lower ring, where `$` / `£` have no bar, is erased like a pen
|
|
28
|
+
* in the first 60 % (`draw`, as the weather's rays) instead of shrinking into a dot.
|
|
29
|
+
* - `£` ↔ `€`: the £'s base is drawn out to the left first, ending at the right like the C (with `$` it ends at the
|
|
30
|
+
* left like the S).
|
|
31
|
+
* - `£` / `+` → `€`: both bars of `€` come out of the one bar of `£` / `+` (the crossbar / the cross bar), which
|
|
32
|
+
* traces its third piece as a hidden copy of that bar (user: the two lines must merge into one; growing out of the
|
|
33
|
+
* resting point in the middle showed as a blob, drawing the lower bar in like a pen didn't merge).
|
|
34
|
+
*/
|
|
35
|
+
export declare const symbolPairLayouts: [PairLayouts, PairLayouts, PairLayouts];
|
|
36
|
+
/** `+` `%` `$` `€` `£` drawn in a set's style. */
|
|
37
|
+
export declare const symbolStrokes: (style: SymbolStyle) => SymbolDrawings;
|
|
38
|
+
export {};
|
package/dist/types/text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MorphOptions } from './morph.js';
|
|
1
|
+
import type { MorphOptions, MorphResult } from './morph.js';
|
|
2
2
|
import type { StyleOptions } from './svg.js';
|
|
3
3
|
import type { IconSet } from './types.js';
|
|
4
4
|
export interface TextOptions extends MorphOptions, StyleOptions {
|
|
@@ -11,15 +11,9 @@ export interface TextOptions extends MorphOptions, StyleOptions {
|
|
|
11
11
|
/** Gap between cells in grid units (default: the set's own). The CSS variable `--morphico-spacing` overrides it. */
|
|
12
12
|
spacing?: number;
|
|
13
13
|
}
|
|
14
|
-
export interface TextResult {
|
|
15
|
-
/** The text the change was heading to. */
|
|
16
|
-
value: string;
|
|
17
|
-
/** `true` when a newer `to()` (or `destroy()`) took over before every digit finished. */
|
|
18
|
-
interrupted: boolean;
|
|
19
|
-
}
|
|
20
14
|
export interface TextChangeOptions extends MorphOptions {
|
|
21
15
|
/** Called when every changed digit has finished, with the same result the promise resolves to. */
|
|
22
|
-
onEnd?: (result:
|
|
16
|
+
onEnd?: (result: MorphResult) => void;
|
|
23
17
|
}
|
|
24
18
|
export interface Text {
|
|
25
19
|
/**
|
|
@@ -28,7 +22,7 @@ export interface Text {
|
|
|
28
22
|
* one width, `:` `.` `,` half of it, `/` 0.7 of it — so `5` ↔ `-` or `.` ↔ `,` morph, `5` ↔ `:` rebuilds.
|
|
29
23
|
* Pad with spaces (e.g. `String(count).padStart(3, ' ')`) to keep counters morphing.
|
|
30
24
|
*/
|
|
31
|
-
to(value: string, options?: TextChangeOptions): Promise<
|
|
25
|
+
to(value: string, options?: TextChangeOptions): Promise<MorphResult>;
|
|
32
26
|
/** Stops all morphs and removes the line from the page. */
|
|
33
27
|
destroy(): void;
|
|
34
28
|
}
|
package/package.json
CHANGED