morphico 0.0.0-stage → 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Raycho Ivanov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # morphico
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Morphing line-art icons for the web: digits (and later other icon states) that smoothly change from one to another by interpolating SVG path data. No runtime dependencies.
4
+
5
+ > **Status:** early development. The API is not available yet. Version 0.0.x only tests the release pipeline.
6
+
7
+ ## Development
8
+
9
+ Written in TypeScript. Requires Node 24 (it runs the `.ts` tools directly).
10
+
11
+ ```sh
12
+ npm install # dev tools only: typescript, @types/node
13
+ npm run dev # preview page at http://localhost:3003
14
+ npm run typecheck
15
+ npm run build # src/ → dist/
16
+ ```
17
+
18
+ ## License
19
+
20
+ [MIT](LICENSE)
@@ -0,0 +1,10 @@
1
+ /*! morphico v0.0.1 | MIT License */
2
+ var morphico = (function () {
3
+ 'use strict';
4
+ // index.ts
5
+ // morphico public API. The icon() / text() layers come later; for now only the version is exported.
6
+ /** Package version, e.g. "0.0.1" (tools/build.ts replaces 'dev'). */
7
+ const version = '0.0.1';
8
+
9
+ return { version };
10
+ })();
@@ -0,0 +1,7 @@
1
+ /*! morphico v0.0.1 | MIT License */
2
+ // index.ts
3
+ // morphico public API. The icon() / text() layers come later; for now only the version is exported.
4
+ /** Package version, e.g. "0.0.1" (tools/build.ts replaces 'dev'). */
5
+ const version = '0.0.1';
6
+
7
+ export { version };
@@ -0,0 +1,12 @@
1
+ /** Maps linear progress (0…1) to eased progress. */
2
+ export type Easing = (progress: number) => number;
3
+ export declare const easings: {
4
+ linear: (progress: number) => number;
5
+ easeInOutCubic: (progress: number) => number;
6
+ easeOutBack: (progress: number) => number;
7
+ easeOutElastic: (progress: number) => number;
8
+ };
9
+ /** Called on every animation frame with the frame time; returns true while it wants more frames. */
10
+ export type FrameCallback = (frameTime: number) => boolean;
11
+ /** Adds a callback to the shared loop. Returns a function that removes it again. */
12
+ export declare const animate: (onFrame: FrameCallback) => (() => void);
@@ -0,0 +1,30 @@
1
+ import type { CubicSegment, IconSet, PairLayout, PathNumbers, Point, Stroke } from './types.js';
2
+ export declare const line: (fromX: number, fromY: number, toX: number, toY: number) => Stroke;
3
+ /** Angles in degrees. Because y points down, `endAngle > startAngle` draws clockwise on screen. */
4
+ export declare const arc: (centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number) => Stroke;
5
+ export declare const cubic: (startX: number, startY: number, control1X: number, control1Y: number, control2X: number, control2Y: number, endX: number, endY: number) => Stroke;
6
+ export declare const pointOnCircle: (centerX: number, centerY: number, radius: number, angle: number) => Point;
7
+ export declare const segmentCountOf: (path: PathNumbers) => number;
8
+ export declare const toSegments: (path: PathNumbers) => CubicSegment[];
9
+ export declare const fromSegments: (segments: CubicSegment[]) => PathNumbers;
10
+ /** Same picture, different segment order: start a closed loop at another segment and/or draw it backwards. */
11
+ export declare const reorderSegments: (path: PathNumbers, { startSegment, reversed }?: PairLayout) => PathNumbers;
12
+ export declare const interpolate: (from: PathNumbers, to: PathNumbers, progress: number) => PathNumbers;
13
+ /** SVG `d` attribute: `M x y` followed by one `C` per segment. */
14
+ export declare const toPathData: (path: PathNumbers) => string;
15
+ /** Rotates the whole shape around the icon center (12, 12). */
16
+ export declare const rotateAroundCenter: (path: PathNumbers, angle: number) => PathNumbers;
17
+ /**
18
+ * The part of a stroke between two progress values (0…1) as one cubic segment.
19
+ * A piece of a line/arc/cubic is exactly a line/arc/cubic, so segment ends can slide along a stroke
20
+ * without changing how it looks.
21
+ */
22
+ export declare const strokePiece: (stroke: Stroke, startProgress: number, endProgress: number) => CubicSegment;
23
+ /** Lays out cubic segments along the strokes; see `PairLayout.breakpoints`. */
24
+ export declare const layoutStrokes: (strokes: Stroke[], breakpoints: number[]) => PathNumbers;
25
+ /** Default breakpoints: segments spread over the strokes by length, arcs get at least one segment per 90°. */
26
+ export declare const defaultBreakpoints: (strokes: Stroke[], segmentCount: number) => number[];
27
+ /** Every state of the set laid out with its default breakpoints. */
28
+ export declare const defaultShapes: (iconSet: IconSet) => Record<string, PathNumbers>;
29
+ /** The shape of `state` laid out for morphing to or from `otherState`. */
30
+ export declare const shapeForPair: (iconSet: IconSet, shapes: Record<string, PathNumbers>, state: string, otherState: string) => PathNumbers;
@@ -0,0 +1,2 @@
1
+ /** Package version, e.g. "0.0.1" (tools/build.ts replaces 'dev'). */
2
+ export declare const version: string;
@@ -0,0 +1,3 @@
1
+ import type { IconSet } from '../types.js';
2
+ declare const digitsV1: IconSet;
3
+ export default digitsV1;
@@ -0,0 +1,3 @@
1
+ import type { IconSet } from '../types.js';
2
+ declare const digitsV2: IconSet;
3
+ export default digitsV2;
@@ -0,0 +1,3 @@
1
+ import type { IconSet } from '../types.js';
2
+ declare const digitsV3: IconSet;
3
+ export default digitsV3;
@@ -0,0 +1,63 @@
1
+ /** A point `[x, y]`. */
2
+ export type Point = [x: number, y: number];
3
+ /** One cubic Bézier segment. */
4
+ export type CubicSegment = [start: Point, control1: Point, control2: Point, end: Point];
5
+ /**
6
+ * Path data as a flat list of numbers: the start point (x, y), then 6 numbers per cubic segment
7
+ * (control1, control2, end). Within an icon set every shape has the same segment count,
8
+ * so any two shapes interpolate number by number.
9
+ */
10
+ export type PathNumbers = number[];
11
+ export interface LineStroke {
12
+ kind: 'line';
13
+ from: Point;
14
+ to: Point;
15
+ }
16
+ /** Angles in degrees. Because y points down, `endAngle > startAngle` draws clockwise on screen. */
17
+ export interface ArcStroke {
18
+ kind: 'arc';
19
+ center: Point;
20
+ radius: number;
21
+ startAngle: number;
22
+ endAngle: number;
23
+ }
24
+ export interface CubicStroke {
25
+ kind: 'cubic';
26
+ segment: CubicSegment;
27
+ }
28
+ /** One piece of a drawing: a straight line, a circular arc or a free cubic curve. */
29
+ export type Stroke = LineStroke | ArcStroke | CubicStroke;
30
+ /**
31
+ * How to lay out a shape for one morph pair. Every option keeps the picture the same and only changes
32
+ * which part of it each segment draws, so segments pair up better with the other shape.
33
+ */
34
+ export interface PairLayout {
35
+ /** Closed loops: start drawing at this segment instead of segment 0. */
36
+ startSegment?: number;
37
+ /** Draw in the opposite direction. */
38
+ reversed?: boolean;
39
+ /**
40
+ * `segmentCount + 1` positions along the strokes where segments start/end.
41
+ * Integer part = stroke index, fraction = position within that stroke.
42
+ * Two equal neighbours make a zero-length segment that "grows" during the morph.
43
+ * Rules: a segment never spans two strokes; an arc segment covers at most 90°.
44
+ */
45
+ breakpoints?: number[];
46
+ /** Lay out the breakpoints along `alternativeStrokes[tracing]` instead of the state's own strokes. */
47
+ tracing?: string;
48
+ /** Rotate by this many degrees around the icon center (only for shapes that look the same turned). */
49
+ rotation?: number;
50
+ }
51
+ export interface IconSet {
52
+ /** Cubic segments per shape. The state that needs the most segments decides it. */
53
+ segmentCount: number;
54
+ strokeWidth: number;
55
+ /** The strokes of each state, as one continuous line in drawing order. */
56
+ strokes: Record<string, Stroke[]>;
57
+ /** Alternative tracings: the same picture (with round joins) drawn in a different order. */
58
+ alternativeStrokes: Record<string, Stroke[]>;
59
+ /** `pairLayouts[state][otherState]`: how to lay out `state` when morphing to or from `otherState`. */
60
+ pairLayouts: Record<string, Record<string, PairLayout>>;
61
+ /** `spins[fromState][toState]`: degrees to rotate around the icon center while morphing. */
62
+ spins: Record<string, Record<string, number>>;
63
+ }
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "morphico",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Morphing line-art icons: smooth SVG path transitions between digits and other states. No dependencies.",
5
+ "license": "MIT",
6
+ "author": "Raycho Ivanov",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rastiv/morphico.git"
10
+ },
11
+ "homepage": "https://github.com/rastiv/morphico#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/rastiv/morphico/issues"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/types/index.d.ts",
19
+ "default": "./dist/morphico.mjs"
20
+ }
21
+ },
22
+ "module": "./dist/morphico.mjs",
23
+ "types": "./dist/types/index.d.ts",
24
+ "jsdelivr": "./dist/morphico.js",
25
+ "unpkg": "./dist/morphico.js",
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "sideEffects": false,
30
+ "scripts": {
31
+ "dev": "node tools/serve.ts",
32
+ "typecheck": "tsc -p tsconfig.json && tsc -p tools/tsconfig.json",
33
+ "build": "node tools/build.ts",
34
+ "check": "node tools/check.ts",
35
+ "verify": "node tools/verify.ts",
36
+ "prepublishOnly": "npm run typecheck && npm run build"
37
+ },
38
+ "keywords": [
39
+ "icons",
40
+ "svg",
41
+ "morph",
42
+ "animation",
43
+ "digits",
44
+ "countdown"
45
+ ],
46
+ "devDependencies": {
47
+ "@types/node": "^24.19.2",
48
+ "typescript": "^7.0.2"
49
+ }
50
+ }