morphico 0.1.0 → 0.2.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/LICENSE-lucide +43 -0
- package/README.md +41 -6
- package/dist/morphico.js +2020 -98
- package/dist/morphico.mjs +2020 -98
- package/dist/types/geometry.d.ts +59 -4
- package/dist/types/icon.d.ts +4 -1
- package/dist/types/iconSets.d.ts +19 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/sets/battery.d.ts +2 -0
- package/dist/types/sets/bell.d.ts +2 -0
- package/dist/types/sets/characters.d.ts +5 -0
- package/dist/types/sets/check-mark.d.ts +7 -0
- package/dist/types/sets/checkbox.d.ts +2 -0
- package/dist/types/sets/chevron.d.ts +2 -0
- package/dist/types/sets/copy.d.ts +2 -0
- package/dist/types/sets/eye.d.ts +2 -0
- package/dist/types/sets/folder.d.ts +2 -0
- package/dist/types/sets/lock.d.ts +2 -0
- package/dist/types/sets/lucide.d.ts +18 -0
- package/dist/types/sets/media.d.ts +2 -0
- package/dist/types/sets/menu.d.ts +2 -0
- package/dist/types/sets/mic.d.ts +2 -0
- package/dist/types/sets/radio.d.ts +2 -0
- package/dist/types/sets/theme.d.ts +2 -0
- package/dist/types/sets/toggle.d.ts +2 -0
- package/dist/types/sets/volume.d.ts +2 -0
- package/dist/types/sets/weather.d.ts +2 -0
- package/dist/types/sets/wifi.d.ts +2 -0
- package/dist/types/svg.d.ts +22 -2
- package/dist/types/text.d.ts +6 -4
- package/dist/types/types.d.ts +52 -9
- package/package.json +4 -3
package/dist/types/geometry.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { CubicSegment, IconSet, PairLayout, PathNumbers, Point, Stroke } from './types.js';
|
|
1
|
+
import type { CubicSegment, IconSet, PairLayout, PathNumbers, PieceSet, Point, Stroke } from './types.js';
|
|
2
2
|
export declare const line: (fromX: number, fromY: number, toX: number, toY: number) => Stroke;
|
|
3
3
|
/** Angles in degrees. Because y points down, `endAngle > startAngle` draws clockwise on screen. */
|
|
4
4
|
export declare const arc: (centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number) => Stroke;
|
|
5
5
|
export declare const cubic: (startX: number, startY: number, control1X: number, control1Y: number, control2X: number, control2Y: number, endX: number, endY: number) => Stroke;
|
|
6
|
+
/** The same line or arc, drawn in the opposite direction. */
|
|
7
|
+
export declare const reversedStroke: (stroke: Stroke) => Stroke;
|
|
6
8
|
export declare const pointOnCircle: (centerX: number, centerY: number, radius: number, angle: number) => Point;
|
|
7
9
|
/** A full ellipse as four cubic quarters, drawn counter-clockwise on screen, starting at the top. */
|
|
8
10
|
export declare const ellipse: (centerX: number, centerY: number, radiusX: number, radiusY: number) => Stroke[];
|
|
@@ -12,14 +14,25 @@ export declare const ellipse: (centerX: number, centerY: number, radiusX: number
|
|
|
12
14
|
* Straight-through points and reversals (going back along the same line) always stay sharp.
|
|
13
15
|
*/
|
|
14
16
|
export declare const roundedPolyline: (points: Point[], radii: number | number[]) => Stroke[];
|
|
17
|
+
/**
|
|
18
|
+
* A closed polygon with every corner rounded by `radius` (clamped per corner so neighbouring arcs never overlap).
|
|
19
|
+
* Always a line and an arc per corner, whatever the radius, so pair layouts (stroke indices) stay valid; at radius 0
|
|
20
|
+
* the arc shrinks to the corner point, so the corner is really sharp (and `stroke-linejoin` decides how it looks).
|
|
21
|
+
* Starts after the first corner with a line (`startsWithArc`: with the arc of the first corner), clockwise if the
|
|
22
|
+
* corners are listed clockwise on screen.
|
|
23
|
+
*/
|
|
24
|
+
export declare const roundedPolygon: (corners: Point[], radius: number, startsWithArc?: boolean) => Stroke[];
|
|
15
25
|
export declare const segmentCountOf: (path: PathNumbers) => number;
|
|
16
26
|
export declare const toSegments: (path: PathNumbers) => CubicSegment[];
|
|
17
27
|
export declare const fromSegments: (segments: CubicSegment[]) => PathNumbers;
|
|
18
28
|
/** Same picture, different segment order: start a closed loop at another segment and/or draw it backwards. */
|
|
19
29
|
export declare const reorderSegments: (path: PathNumbers, { startSegment, reversed }?: PairLayout) => PathNumbers;
|
|
20
30
|
export declare const interpolate: (from: PathNumbers, to: PathNumbers, progress: number) => PathNumbers;
|
|
21
|
-
/**
|
|
22
|
-
|
|
31
|
+
/**
|
|
32
|
+
* SVG `d` attribute: per piece `M x y` followed by one `C` per segment (`pieceLength`: see pieceLengthOf).
|
|
33
|
+
* Pieces shrunk to a single point are left out.
|
|
34
|
+
*/
|
|
35
|
+
export declare const toPathData: (path: PathNumbers, pieceLength?: number) => string;
|
|
23
36
|
/** Shrinks (factor < 1) or grows the whole shape around the icon center (12, 12). */
|
|
24
37
|
export declare const scaleAroundCenter: (path: PathNumbers, factor: number) => PathNumbers;
|
|
25
38
|
/** Rotates the whole shape around the icon center (12, 12). */
|
|
@@ -34,7 +47,49 @@ export declare const strokePiece: (stroke: Stroke, startProgress: number, endPro
|
|
|
34
47
|
export declare const layoutStrokes: (strokes: Stroke[], breakpoints: number[]) => PathNumbers;
|
|
35
48
|
/** Default breakpoints: segments spread over the strokes by length, arcs get at least one segment per 90°. */
|
|
36
49
|
export declare const defaultBreakpoints: (strokes: Stroke[], segmentCount: number) => number[];
|
|
50
|
+
/** The set itself is the first piece. */
|
|
51
|
+
export declare const piecesOf: (iconSet: IconSet) => PieceSet[];
|
|
52
|
+
/** Path numbers of one piece: start point + 6 per segment. */
|
|
53
|
+
export declare const pieceLengthOf: (iconSet: IconSet) => number;
|
|
54
|
+
/** Splits a shape into the path numbers of its pieces. */
|
|
55
|
+
export declare const splitPieces: (path: PathNumbers, pieceLength: number) => PathNumbers[];
|
|
37
56
|
/** Every state of the set laid out with its default breakpoints. */
|
|
38
57
|
export declare const defaultShapes: (iconSet: IconSet) => Record<string, PathNumbers>;
|
|
39
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* `shape` pressed flat onto the straight line `from` → `to`: every point moves onto the line, keeping its position
|
|
60
|
+
* along the line's direction (the shape's extent along it is stretched to the line's length).
|
|
61
|
+
*/
|
|
62
|
+
export declare const flattenOntoLine: (shape: PathNumbers, from: Point, to: Point) => PathNumbers;
|
|
63
|
+
/** The shape of `state` laid out for morphing to or from `otherState` (each piece by its own pair layout). */
|
|
40
64
|
export declare const shapeForPair: (iconSet: IconSet, shapes: Record<string, PathNumbers>, state: string, otherState: string) => PathNumbers;
|
|
65
|
+
/** The first `fraction` (0…1) of a piece along its length, as if a pen had drawn that far. */
|
|
66
|
+
export declare const trimPiece: (piece: PathNumbers, fraction: number) => PathNumbers;
|
|
67
|
+
/**
|
|
68
|
+
* The x range a morph's wipe edge moves through: the box (x 2…22), or — if a piece slides in — from the box's side
|
|
69
|
+
* to that piece's leading side at rest, so the edge rides at its front and it starts just outside the box.
|
|
70
|
+
*/
|
|
71
|
+
export declare const wipeRange: (slidingPiece: PathNumbers | null, direction: 'left' | 'right') => [number, number];
|
|
72
|
+
/**
|
|
73
|
+
* A piece behind a vertical edge (PairLayout.wipe): at `fraction` 0…1 of the wipe, the edge has moved that far
|
|
74
|
+
* through `edgeRange` in `direction`, and only the part it has passed shows. That part must be one stretch of the
|
|
75
|
+
* path. `slides` (PairLayout.slide): the piece moves with the edge from outside the box; only its part inside shows.
|
|
76
|
+
*/
|
|
77
|
+
export declare const wipePiece: (piece: PathNumbers, fraction: number, direction: 'left' | 'right', edgeRange?: [number, number], slides?: boolean) => PathNumbers;
|
|
78
|
+
/** A piece drawn along its path during a morph: drawn in (it appears) or erased (it goes). */
|
|
79
|
+
export interface DrawnPiece {
|
|
80
|
+
pieceIndex: number;
|
|
81
|
+
drawsIn: boolean;
|
|
82
|
+
/** When the drawing in happens: from `start` to `end` of the morph (0…1); erasing runs it in reverse. */
|
|
83
|
+
start: number;
|
|
84
|
+
end: number;
|
|
85
|
+
/** Revealed behind a moving edge instead of along its path (PairLayout.wipe), moving with it (PairLayout.slide). */
|
|
86
|
+
wipe?: 'left' | 'right';
|
|
87
|
+
slide?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** The pieces drawn (or erased) along their path when morphing `state` → `otherState` (PairLayout.draw). */
|
|
90
|
+
export declare const drawnPieces: (iconSet: IconSet, state: string, otherState: string) => DrawnPiece[];
|
|
91
|
+
/**
|
|
92
|
+
* A frame of a morph `from` → `to` at `progress` with the drawn pieces replaced: drawn in from the start along
|
|
93
|
+
* `to`'s piece, or erased back along `from`'s piece.
|
|
94
|
+
*/
|
|
95
|
+
export declare const withDrawnPieces: (frame: PathNumbers, from: PathNumbers, to: PathNumbers, progress: number, pieceLength: number, drawn: DrawnPiece[]) => PathNumbers;
|
package/dist/types/icon.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { IconSetName } from './iconSets.js';
|
|
2
2
|
import type { MorphOptions, MorphResult } from './morph.js';
|
|
3
|
+
import type { StyleOptions } from './svg.js';
|
|
3
4
|
import type { IconSet } from './types.js';
|
|
4
|
-
export interface IconOptions extends MorphOptions {
|
|
5
|
+
export interface IconOptions extends MorphOptions, StyleOptions {
|
|
5
6
|
/** A built-in set by name (default `'round'`) or a set object. */
|
|
6
7
|
set?: IconSetName | IconSet;
|
|
8
|
+
/** Corner roundness: 0 = sharp … 1 = the icon's own corners (default, also the maximum). Icon sets only. */
|
|
9
|
+
roundness?: number;
|
|
7
10
|
/** The state shown first (default: empty, `' '`). */
|
|
8
11
|
state?: string;
|
|
9
12
|
/** CSS width and height of the icon (default `'1em'`: it follows the font size). */
|
package/dist/types/iconSets.d.ts
CHANGED
|
@@ -5,7 +5,24 @@ export declare const iconSets: {
|
|
|
5
5
|
condensed: IconSet;
|
|
6
6
|
slim: IconSet;
|
|
7
7
|
handwritten: IconSet;
|
|
8
|
+
media: IconSet;
|
|
9
|
+
menu: IconSet;
|
|
10
|
+
checkbox: IconSet;
|
|
11
|
+
radio: IconSet;
|
|
12
|
+
folder: IconSet;
|
|
13
|
+
theme: IconSet;
|
|
14
|
+
weather: IconSet;
|
|
15
|
+
eye: IconSet;
|
|
16
|
+
volume: IconSet;
|
|
17
|
+
toggle: IconSet;
|
|
18
|
+
lock: IconSet;
|
|
19
|
+
bell: IconSet;
|
|
20
|
+
mic: IconSet;
|
|
21
|
+
chevron: IconSet;
|
|
22
|
+
copy: IconSet;
|
|
23
|
+
wifi: IconSet;
|
|
24
|
+
battery: IconSet;
|
|
8
25
|
};
|
|
9
26
|
export type IconSetName = keyof typeof iconSets;
|
|
10
|
-
/** A set given by name or as a set object. */
|
|
11
|
-
export declare const resolveIconSet: (set?: IconSetName | IconSet) => IconSet;
|
|
27
|
+
/** A set given by name or as a set object, optionally with sharper corners (`roundness` 0 = sharp … 1 = own). */
|
|
28
|
+
export declare const resolveIconSet: (set?: IconSetName | IconSet, roundness?: number) => IconSet;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { Easing } from './engine.js';
|
|
|
6
6
|
export type { ChangeOptions, Icon, IconOptions } from './icon.js';
|
|
7
7
|
export type { IconSetName } from './iconSets.js';
|
|
8
8
|
export type { EasingName, MorphOptions, MorphResult } from './morph.js';
|
|
9
|
+
export type { StyleOptions } from './svg.js';
|
|
9
10
|
export type { SetOptions, Text, TextOptions, TextResult } from './text.js';
|
|
10
11
|
export type { IconSet, TextLayout } from './types.js';
|
|
11
12
|
/** Package version, e.g. "0.1.0" (tools/build.ts replaces 'dev'). */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PieceSet, Point } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The check piece of a set with the states unchecked, checked, checked-big (12 segments).
|
|
4
|
+
* `hiddenAt`: a Lucide point on the outline at the check's height, where unchecked's check rests at rest
|
|
5
|
+
* (tiny, under the outline's line, so it doesn't show — morphs draw the check instead).
|
|
6
|
+
*/
|
|
7
|
+
export declare const checkMarkPiece: (hiddenAt: Point) => PieceSet;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Point, Stroke } from '../types.js';
|
|
2
|
+
export declare const LUCIDE_SCALE: number;
|
|
3
|
+
/** Lucide's 2-unit line, scaled with the icon. */
|
|
4
|
+
export declare const LUCIDE_STROKE_WIDTH: number;
|
|
5
|
+
/** A point (or corner) of a Lucide icon moved into our icon box. */
|
|
6
|
+
export declare const fromLucide: ([x, y]: Point) => Point;
|
|
7
|
+
/** A length of a Lucide icon (e.g. a corner radius) in our icon box. */
|
|
8
|
+
export declare const lucideLength: (length: number) => number;
|
|
9
|
+
/** A straight line between two Lucide points. */
|
|
10
|
+
export declare const lucideLine: (fromX: number, fromY: number, toX: number, toY: number) => Stroke;
|
|
11
|
+
/** A circular arc in Lucide coordinates (angles in degrees, `endAngle > startAngle` = clockwise on screen). */
|
|
12
|
+
export declare const lucideArc: (centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number) => Stroke;
|
|
13
|
+
/** A cubic Bézier curve in Lucide coordinates. */
|
|
14
|
+
export declare const lucideCubic: (...coordinates: [number, number, number, number, number, number, number, number]) => Stroke;
|
|
15
|
+
/** A missing piece at rest: a single point, never drawn (see toPathData). */
|
|
16
|
+
export declare const lucidePoint: (x: number, y: number) => Stroke[];
|
|
17
|
+
/** The diagonal slash of Lucide's "-off" icons, from the top left. */
|
|
18
|
+
export declare const LUCIDE_SLASH: Stroke[];
|
package/dist/types/svg.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import type { IconSet } from './types.js';
|
|
2
|
+
/** How the lines are drawn. Every option defaults to the set's own look. */
|
|
3
|
+
export interface StyleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Line width. A number is in grid units (an icon is 24 × 24; Lucide-based sets use 16/18 · 2 ≈ 1.78) and scales with the icon;
|
|
6
|
+
* a CSS length (`'2px'`, `'0.1rem'`, `'0.08em'`) stays that wide whatever the icon's size.
|
|
7
|
+
*/
|
|
8
|
+
strokeWidth?: number | string;
|
|
9
|
+
/** Line ends: `'round'`, `'butt'` (flat, ends exactly at the line's end) or `'square'` (flat, half a width longer). */
|
|
10
|
+
lineCap?: IconSet['lineCap'];
|
|
11
|
+
/** Corners where lines meet: `'round'`, `'miter'` (sharp) or `'bevel'` (cut off). */
|
|
12
|
+
lineJoin?: IconSet['lineJoin'];
|
|
13
|
+
/** `true` fills closed shapes with the CSS `color` too; a CSS color fills them with that color. */
|
|
14
|
+
fill?: boolean | string;
|
|
15
|
+
}
|
|
16
|
+
/** A CSS length as stroke width: drawn at that width on screen instead of scaling with the icon. */
|
|
17
|
+
export declare const hasFixedStrokeWidth: (style: StyleOptions) => style is StyleOptions & {
|
|
18
|
+
strokeWidth: string;
|
|
19
|
+
};
|
|
2
20
|
export declare const createSvgElement: <TagName extends keyof SVGElementTagNameMap>(tagName: TagName, attributes?: Record<string, string | number>) => SVGElementTagNameMap[TagName];
|
|
3
|
-
/** An <svg> drawn in the set's stroke style,
|
|
4
|
-
export declare const createIconSvg: (iconSet: IconSet, viewBox: string) => SVGSVGElement;
|
|
21
|
+
/** An <svg> drawn in the set's stroke style (or the given style), colored by the CSS `color` (currentColor). */
|
|
22
|
+
export declare const createIconSvg: (iconSet: IconSet, viewBox: string, style?: StyleOptions) => SVGSVGElement;
|
|
23
|
+
/** A stroked child element (path, circle); with a fixed (CSS length) stroke width its line doesn't scale. */
|
|
24
|
+
export declare const createStrokedElement: <TagName extends 'path' | 'circle'>(tagName: TagName, style: StyleOptions, attributes?: Record<string, string | number>) => SVGElementTagNameMap[TagName];
|
package/dist/types/text.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { IconSetName } from './iconSets.js';
|
|
2
2
|
import type { MorphOptions } from './morph.js';
|
|
3
|
+
import type { StyleOptions } from './svg.js';
|
|
3
4
|
import type { IconSet } from './types.js';
|
|
4
|
-
export interface TextOptions extends MorphOptions {
|
|
5
|
+
export interface TextOptions extends MorphOptions, StyleOptions {
|
|
5
6
|
/** A built-in set by name (default `'round'`) or a set object. */
|
|
6
7
|
set?: IconSetName | IconSet;
|
|
7
8
|
/** The text shown first (default: empty). */
|
|
@@ -27,9 +28,10 @@ export interface Text {
|
|
|
27
28
|
/** The text shown, or being morphed to (after unsupported characters were removed). */
|
|
28
29
|
readonly value: string;
|
|
29
30
|
/**
|
|
30
|
-
* Shows `value`. Unsupported characters are removed first. If the length and
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* Shows `value`. Unsupported characters are removed first. If the length and every cell's width stay the same,
|
|
32
|
+
* the changed characters morph; otherwise the line is rebuilt without animation. Cells: digits, space and `-` are
|
|
33
|
+
* one width, `:` `.` `,` half of it, `/` 0.7 of it — so `5` ↔ `-` or `.` ↔ `,` morph, `5` ↔ `:` rebuilds.
|
|
34
|
+
* Pad with spaces (e.g. `String(count).padStart(3, ' ')`) to keep counters morphing.
|
|
33
35
|
*/
|
|
34
36
|
set(value: string, options?: SetOptions): Promise<TextResult>;
|
|
35
37
|
/** Stops all morphs and removes the line from the page. */
|
package/dist/types/types.d.ts
CHANGED
|
@@ -47,6 +47,34 @@ export interface PairLayout {
|
|
|
47
47
|
tracing?: string;
|
|
48
48
|
/** Rotate by this many degrees around the icon center (only for shapes that look the same turned). */
|
|
49
49
|
rotation?: number;
|
|
50
|
+
/**
|
|
51
|
+
* For states drawn as one straight line (`-`, `/`, a dot): lay the line out as the other state pressed flat onto
|
|
52
|
+
* it (every point keeps its position along the line), so the morph flattens the other shape onto the line.
|
|
53
|
+
* The other side keeps its own layout for this pair. Overrides every option above.
|
|
54
|
+
*/
|
|
55
|
+
flatten?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The piece is not there in this state: during the morph the other state's piece is drawn along its own path,
|
|
58
|
+
* like a pen writing it (erased back the same way in reverse). Overrides every option above.
|
|
59
|
+
* A number (0…1) is the share of the morph the drawing takes: erasing happens at its start, drawing in at its end.
|
|
60
|
+
* `[start, end]` (0…1): drawing in happens between these points of the morph (e.g. to stagger several pieces);
|
|
61
|
+
* erasing runs the same in reverse (between `1 - end` and `1 - start`).
|
|
62
|
+
*/
|
|
63
|
+
draw?: boolean | number | [start: number, end: number];
|
|
64
|
+
/**
|
|
65
|
+
* Like `draw`, but the piece is revealed behind a vertical edge moving across the icon box (x 2…22) in this
|
|
66
|
+
* direction instead of along its path (hidden the same way in reverse). Every wiped piece of a morph uses the same
|
|
67
|
+
* edge, so a cloud can cover a sun as it moves in. Timing from `draw` if given (else the whole morph).
|
|
68
|
+
* The piece's visible part must be one stretch of its path: lay it out to start where the edge reaches it last.
|
|
69
|
+
*/
|
|
70
|
+
wipe?: 'left' | 'right';
|
|
71
|
+
/**
|
|
72
|
+
* With `wipe`: the piece moves in with the edge instead of standing still — it slides in from just outside the
|
|
73
|
+
* box's side (x 2 or 22; the part outside the box is not shown), its leading side riding at the edge, so it covers
|
|
74
|
+
* what the edge wipes away (a cloud crawling over the sun). Other sliding pieces of the morph move along with the
|
|
75
|
+
* first one (rain with its cloud).
|
|
76
|
+
*/
|
|
77
|
+
slide?: boolean;
|
|
50
78
|
}
|
|
51
79
|
/** How a set's characters sit in the narrow cells of `text()`. Numbers are in grid units (digits are 16 high). */
|
|
52
80
|
export interface TextLayout {
|
|
@@ -59,21 +87,36 @@ export interface TextLayout {
|
|
|
59
87
|
/** y of the two dots of `:` (the centres of the 8's loops). */
|
|
60
88
|
colonDotsY: [top: number, bottom: number];
|
|
61
89
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
segmentCount: number;
|
|
65
|
-
strokeWidth: number;
|
|
66
|
-
/** SVG `stroke-linecap`: flat (`butt`) or rounded line ends. */
|
|
67
|
-
lineCap: 'butt' | 'round' | 'square';
|
|
68
|
-
/** SVG `stroke-linejoin`: sharp (`miter`) or rounded corners. */
|
|
69
|
-
lineJoin: 'miter' | 'round' | 'bevel';
|
|
90
|
+
/** One piece of every state: a continuous line per state, plus the tuning of its morphs. */
|
|
91
|
+
export interface PieceSet {
|
|
70
92
|
/** The strokes of each state, as one continuous line in drawing order. */
|
|
71
93
|
strokes: Record<string, Stroke[]>;
|
|
72
94
|
/** Alternative tracings: the same picture (with round joins) drawn in a different order. */
|
|
73
95
|
alternativeStrokes: Record<string, Stroke[]>;
|
|
74
96
|
/** `pairLayouts[state][otherState]`: how to lay out `state` when morphing to or from `otherState`. */
|
|
75
97
|
pairLayouts: Record<string, Record<string, PairLayout>>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A family of states that morph into each other. The set itself is the first piece of every state;
|
|
101
|
+
* `morePieces` adds further pieces for icons drawn in several parts (e.g. pause = two bars).
|
|
102
|
+
*/
|
|
103
|
+
export interface IconSet extends PieceSet {
|
|
104
|
+
/** Cubic segments per piece. The state that needs the most segments decides it. */
|
|
105
|
+
segmentCount: number;
|
|
106
|
+
strokeWidth: number;
|
|
107
|
+
/** SVG `stroke-linecap`: flat (`butt`) or rounded line ends. */
|
|
108
|
+
lineCap: 'butt' | 'round' | 'square';
|
|
109
|
+
/** SVG `stroke-linejoin`: sharp (`miter`) or rounded corners. */
|
|
110
|
+
lineJoin: 'miter' | 'round' | 'bevel';
|
|
111
|
+
/**
|
|
112
|
+
* Further pieces, drawn together with the first one. Every state needs strokes in every piece:
|
|
113
|
+
* a state made of fewer parts repeats one of them (drawn on top of itself, so it doesn't show).
|
|
114
|
+
*/
|
|
115
|
+
morePieces?: PieceSet[];
|
|
76
116
|
/** `spins[fromState][toState]`: degrees to rotate around the icon center while morphing. */
|
|
77
117
|
spins: Record<string, Record<string, number>>;
|
|
78
|
-
|
|
118
|
+
/** Only sets that `text()` can use (digits). */
|
|
119
|
+
textLayout?: TextLayout;
|
|
120
|
+
/** Sets built from rounded corners: the same set with every corner radius times `roundness` (0 = sharp, 1 = own). */
|
|
121
|
+
withRoundness?: (roundness: number) => IconSet;
|
|
79
122
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "morphico",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Morphing line-art icons: smooth SVG path transitions between digits and other states. No dependencies.",
|
|
5
|
-
"license": "MIT",
|
|
5
|
+
"license": "MIT AND ISC",
|
|
6
6
|
"author": "Raycho Ivanov",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"jsdelivr": "./dist/morphico.js",
|
|
25
25
|
"unpkg": "./dist/morphico.js",
|
|
26
26
|
"files": [
|
|
27
|
-
"dist"
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE-lucide"
|
|
28
29
|
],
|
|
29
30
|
"sideEffects": false,
|
|
30
31
|
"scripts": {
|