@johnoscott/isometric-engine 0.12.6 → 0.15.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/EDITOR-GUIDE.md +9 -2
- package/README.md +1 -1
- package/assets/app.css +6 -0
- package/assets/marks.css +2 -0
- package/iso-editor.js +194 -184
- package/iso-render.js +157 -148
- package/iso-systems.js +170 -159
- package/js/iso-editor/make-way.js +62 -0
- package/js/iso-editor/ui/canvas.js +477 -216
- package/js/iso-editor/ui/palette-look.js +53 -0
- package/js/iso-editor/ui/setup.js +3 -0
- package/js/iso-objects/ants.js +36 -0
- package/js/iso-objects/index.js +47 -1
- package/js/iso-objects/looks.js +25 -0
- package/js/iso-objects/motion-builder.js +130 -0
- package/js/iso-objects/motion-doc.js +500 -0
- package/js/iso-objects/motion-entry.js +32 -0
- package/js/iso-objects/motion.js +635 -0
- package/js/iso-objects/resolve.js +238 -0
- package/js/iso-objects/scene.js +15 -13
- package/js/iso-objects/timeline.js +553 -0
- package/js/iso-systems/compile.js +59 -1
- package/js/iso-systems/index.js +4 -1
- package/js/iso-systems/render.js +20 -0
- package/js/iso-systems/schema.json +39 -0
- package/js/iso-viewer/page.js +2 -1
- package/js/iso-viewer/player.js +23 -34
- package/package.json +46 -1
- package/src/iso-editor/make-way.ts +89 -0
- package/src/iso-editor/ui/app.css +4 -0
- package/src/iso-editor/ui/canvas.ts +390 -170
- package/src/iso-editor/ui/marks.css +2 -0
- package/src/iso-editor/ui/palette-look.ts +51 -0
- package/src/iso-editor/ui/setup.ts +8 -0
- package/src/iso-objects/ants.ts +53 -0
- package/src/iso-objects/compile.ts +4 -1
- package/src/iso-objects/index.ts +14 -1
- package/src/iso-objects/looks.ts +21 -0
- package/src/iso-objects/motion-builder.ts +79 -0
- package/src/iso-objects/motion-doc.ts +361 -0
- package/src/iso-objects/motion-entry.ts +12 -0
- package/src/iso-objects/motion.ts +616 -0
- package/src/iso-objects/resolve.ts +196 -0
- package/src/iso-objects/scene.ts +29 -13
- package/src/iso-objects/timeline.ts +443 -0
- package/src/iso-objects/types.ts +20 -2
- package/src/iso-systems/compile.ts +58 -3
- package/src/iso-systems/index.ts +4 -1
- package/src/iso-systems/render.ts +41 -0
- package/src/iso-systems/schema.json +39 -0
- package/src/iso-viewer/page.ts +2 -1
- package/src/iso-viewer/player.ts +24 -41
- package/types/iso-editor/make-way.d.ts +40 -0
- package/types/iso-editor/ui/canvas.d.ts +33 -12
- package/types/iso-editor/ui/palette-look.d.ts +5 -0
- package/types/iso-editor/ui/setup.d.ts +5 -0
- package/types/iso-objects/ants.d.ts +33 -0
- package/types/iso-objects/compile.d.ts +3 -0
- package/types/iso-objects/index.d.ts +14 -1
- package/types/iso-objects/looks.d.ts +4 -0
- package/types/iso-objects/motion-builder.d.ts +105 -0
- package/types/iso-objects/motion-doc.d.ts +787 -0
- package/types/iso-objects/motion-entry.d.ts +10 -0
- package/types/iso-objects/motion.d.ts +200 -0
- package/types/iso-objects/resolve.d.ts +20 -0
- package/types/iso-objects/scene.d.ts +11 -0
- package/types/iso-objects/timeline.d.ts +46 -0
- package/types/iso-objects/types.d.ts +32 -0
- package/types/iso-systems/compile.d.ts +20 -3
- package/types/iso-systems/index.d.ts +4 -1
- package/types/iso-systems/render.d.ts +21 -0
|
@@ -29,6 +29,29 @@
|
|
|
29
29
|
"scenes": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/scene" } }
|
|
30
30
|
},
|
|
31
31
|
"$defs": {
|
|
32
|
+
"motion": {
|
|
33
|
+
"type": "object", "additionalProperties": false, "minProperties": 1,
|
|
34
|
+
"description": "how this piece (a region: its contents too) moves when the drawing assembles or disassembles",
|
|
35
|
+
"properties": {
|
|
36
|
+
"style": { "enum": ["edge", "drop", "rise", "fly", "pop", "scatter", "build", "fade"], "description": "how it arrives" },
|
|
37
|
+
"out": { "enum": ["explode", "lift-off", "sink", "scatter", "fly-out", "collapse", "fade", "reverse"], "description": "how it leaves" },
|
|
38
|
+
"easing": { "enum": ["linear", "ease", "ease-in", "ease-out", "settle", "spring", "bounce"] },
|
|
39
|
+
"from": { "enum": ["left", "right", "top", "bottom"], "description": "fly: the side it comes from" },
|
|
40
|
+
"delay": { "type": "number", "minimum": 0, "description": "ms after its turn" },
|
|
41
|
+
"duration": { "type": "number", "exclusiveMinimum": 0, "description": "ms its own move takes" }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"variants": {
|
|
45
|
+
"type": "object", "minProperties": 1, "propertyNames": { "$ref": "#/$defs/id" },
|
|
46
|
+
"description": "other looks of it, by name, for a motion to switch to (its box stays as it is)",
|
|
47
|
+
"additionalProperties": {
|
|
48
|
+
"type": "object", "additionalProperties": false, "minProperties": 1,
|
|
49
|
+
"properties": {
|
|
50
|
+
"role": { "type": "string" }, "ghost": { "type": "boolean" }, "label": { "type": "string" }, "sub": { "type": "string" },
|
|
51
|
+
"face": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }, "deco": { "type": "array", "items": { "$ref": "#/$defs/deco" } }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
32
55
|
"id": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_-]*$" },
|
|
33
56
|
"grid": {
|
|
34
57
|
"type": "object",
|
|
@@ -88,6 +111,18 @@
|
|
|
88
111
|
"properties": {
|
|
89
112
|
"id": { "$ref": "#/$defs/id" },
|
|
90
113
|
"title": { "type": "string" },
|
|
114
|
+
"ants": {
|
|
115
|
+
"description": "its connectors march, showing which way they flow: all that may, these, or with a speed (units a second) and a dash",
|
|
116
|
+
"anyOf": [
|
|
117
|
+
{ "type": "boolean" },
|
|
118
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
119
|
+
{ "type": "object", "additionalProperties": false, "properties": {
|
|
120
|
+
"ids": { "type": "array", "items": { "type": "string" } },
|
|
121
|
+
"speed": { "type": "number" },
|
|
122
|
+
"dash": { "type": "array", "items": { "type": "number", "exclusiveMinimum": 0 }, "minItems": 2, "maxItems": 2 } } }
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"motion": { "type": "object", "description": "the scene's motion document (isomotion/1; its `isomotion: 1` may be left out)" },
|
|
91
126
|
"caption": { "type": "string" },
|
|
92
127
|
"aria": { "type": "string" },
|
|
93
128
|
"gap": { "type": "number", "exclusiveMinimum": 0 },
|
|
@@ -143,6 +178,8 @@
|
|
|
143
178
|
},
|
|
144
179
|
"around": { "type": "array", "items": { "$ref": "#/$defs/id" }, "description": "tunnel: routes it wraps" },
|
|
145
180
|
"regions": { "type": "array", "items": { "$ref": "#/$defs/region" } },
|
|
181
|
+
"motion": { "$ref": "#/$defs/motion" },
|
|
182
|
+
"variants": { "$ref": "#/$defs/variants" },
|
|
146
183
|
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } }
|
|
147
184
|
}
|
|
148
185
|
},
|
|
@@ -188,6 +225,8 @@
|
|
|
188
225
|
"dy": { "type": "number" }
|
|
189
226
|
}
|
|
190
227
|
},
|
|
228
|
+
"motion": { "$ref": "#/$defs/motion" },
|
|
229
|
+
"variants": { "$ref": "#/$defs/variants" },
|
|
191
230
|
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" }, "description": "nodes standing on top of this one" }
|
|
192
231
|
}
|
|
193
232
|
},
|
package/src/iso-viewer/page.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The HTML page around the scenes: header, one section per scene, theme toggle. One file, no network.
|
|
2
2
|
|
|
3
|
+
import { motionModel } from '../iso-objects/motion.ts';
|
|
3
4
|
import { esc } from '../iso-core/kernel.ts';
|
|
4
5
|
import type { Compiled } from '../iso-objects/compile.ts';
|
|
5
6
|
import { themeCss } from '../iso-core/theme.ts';
|
|
@@ -31,7 +32,7 @@ export function stepData(c: Compiled): string {
|
|
|
31
32
|
scenes: c.scenes.map(s => ({
|
|
32
33
|
id: s.id, loop: s.raw.loop ?? true, dim: s.raw.dim ?? 'flows', vis: s.steps.vis,
|
|
33
34
|
steps: s.steps.steps.map(st => ({ ...st, caption: md(st.caption) })),
|
|
34
|
-
assemble: s.assemble, grid: !!s.grid.show,
|
|
35
|
+
assemble: s.assemble, grid: !!s.grid.show, motion: motionModel(s),
|
|
35
36
|
})),
|
|
36
37
|
});
|
|
37
38
|
}
|
package/src/iso-viewer/player.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// #grid (show the floor grid), #assemble (play the assemble intro) and #assemble&at=MS (freeze it at that moment).
|
|
7
7
|
|
|
8
8
|
import { focusView } from '../iso-objects/focus.ts';
|
|
9
|
+
import { paint, planOf, type MotionModel } from '../iso-objects/motion.ts';
|
|
9
10
|
|
|
10
11
|
interface Token { route: string; kind: string; color: string }
|
|
11
12
|
interface Step {
|
|
@@ -13,17 +14,14 @@ interface Step {
|
|
|
13
14
|
phases: Token[][]; pulses: [number, number, number, number][]; lit: string[]; duration: number;
|
|
14
15
|
focus?: [number, number, number, number];
|
|
15
16
|
}
|
|
16
|
-
interface Piece { id: string; kind: 'region' | 'node'; dx: number; dy: number; delay: number; dur: number }
|
|
17
|
-
interface Assembly { pieces: Piece[]; routes: { id: string; delay: number; dur: number }[]; labels: { delay: number; dur: number }; total: number }
|
|
18
17
|
interface SceneData {
|
|
19
18
|
id: string; loop: boolean; dim: 'flows' | 'all'; steps: Step[]; vis: Record<string, boolean[]>;
|
|
20
|
-
assemble: boolean; grid: boolean;
|
|
19
|
+
assemble: boolean; grid: boolean; motion: MotionModel;
|
|
21
20
|
}
|
|
22
21
|
interface Data { scenes: SceneData[] }
|
|
23
22
|
|
|
24
23
|
const NS = 'http://www.w3.org/2000/svg';
|
|
25
24
|
const TRAVEL = 1150;
|
|
26
|
-
const EASE_IN = 'cubic-bezier(.16,.84,.3,1)';
|
|
27
25
|
|
|
28
26
|
function svgEl(tag: string, attrs: Record<string, string | number>, parent: Element): SVGElement {
|
|
29
27
|
const e = document.createElementNS(NS, tag);
|
|
@@ -77,7 +75,7 @@ function init() {
|
|
|
77
75
|
if (sd.dim === 'all') svg.classList.add('dim-all');
|
|
78
76
|
|
|
79
77
|
let cur = 0, playing = false, userPaused = false, active = false, timer = 0, raf = 0, groups = 0, t0 = 0;
|
|
80
|
-
let assembling = false, assembled = false,
|
|
78
|
+
let assembling = false, assembled = false, introTimer = 0, introDone: (() => void) | undefined;
|
|
81
79
|
let tokens: { path: SVGPathElement; len: number; gi: number; stop: boolean; c: SVGElement }[] = [];
|
|
82
80
|
|
|
83
81
|
// ---- grid ----
|
|
@@ -177,50 +175,35 @@ function init() {
|
|
|
177
175
|
function stop() { playing = false; clearTimeout(timer); setBtn(); restartProg(); }
|
|
178
176
|
function userPause() { userPaused = true; stop(); }
|
|
179
177
|
|
|
180
|
-
// ---- assemble:
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
function finishAssemble() {
|
|
184
|
-
if (!assembling) return;
|
|
185
|
-
for (const a of animations) a.finish();
|
|
186
|
-
}
|
|
178
|
+
// ---- assemble: the motion core's plan (the same a video is made from), painted as time goes by ----
|
|
179
|
+
const plan = planOf(sd.motion, 'assemble');
|
|
180
|
+
function finishAssemble() { if (assembling) introDone?.(); }
|
|
187
181
|
function assemble(freezeAt?: number) {
|
|
188
|
-
|
|
189
|
-
|
|
182
|
+
clearTimeout(introTimer);
|
|
183
|
+
introDone = undefined;
|
|
190
184
|
stop();
|
|
191
185
|
if (N) show(cur); // set what is visible at this step; focus comes back at the end
|
|
192
186
|
clearAnim();
|
|
193
187
|
svg.classList.remove('focus', 'pre-assemble', 'all');
|
|
194
188
|
assembling = true;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
for (const r of A.routes) {
|
|
204
|
-
const g = layer('flows')?.querySelector(`[data-hl="${CSS.escape(r.id)}"]`);
|
|
205
|
-
const path = g?.querySelector<SVGPathElement>('path.flow');
|
|
206
|
-
if (!g || !path) continue;
|
|
207
|
-
const len = path.getTotalLength();
|
|
208
|
-
run(g, [{ opacity: 0 }, { opacity: 1 }], r.delay, 80, 'linear');
|
|
209
|
-
run(path, [{ strokeDasharray: `${len} ${len}`, strokeDashoffset: len }, { strokeDasharray: `${len} ${len}`, strokeDashoffset: 0 }], r.delay, r.dur, 'ease-out');
|
|
210
|
-
}
|
|
211
|
-
for (const name of ['floor', 'labels', 'badges']) {
|
|
212
|
-
const L = layer(name);
|
|
213
|
-
if (L) run(L, [{ opacity: 0 }, { opacity: 1 }], A.labels.delay, A.labels.dur, 'ease-out');
|
|
214
|
-
}
|
|
215
|
-
if (freezeAt !== undefined) {
|
|
216
|
-
for (const a of animations) { a.pause(); a.currentTime = freezeAt; }
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
Promise.all(animations.map(a => a.finished)).then(() => {
|
|
220
|
-
assembling = false; assembled = true; animations = [];
|
|
189
|
+
if (freezeAt !== undefined) { paint(svg, plan.at(freezeAt)); return; }
|
|
190
|
+
const start = performance.now();
|
|
191
|
+
introDone = () => {
|
|
192
|
+
clearTimeout(introTimer);
|
|
193
|
+
introDone = undefined;
|
|
194
|
+
paint(svg, {});
|
|
195
|
+
assembling = false; assembled = true;
|
|
221
196
|
if (N) show(cur);
|
|
222
197
|
if (active && !userPaused) play();
|
|
223
|
-
}
|
|
198
|
+
};
|
|
199
|
+
// a timer, not a frame callback, so it also finishes where no frames are drawn
|
|
200
|
+
const step = () => {
|
|
201
|
+
const t = performance.now() - start;
|
|
202
|
+
if (t >= plan.duration) { introDone?.(); return; }
|
|
203
|
+
paint(svg, plan.at(t));
|
|
204
|
+
introTimer = window.setTimeout(step, 16);
|
|
205
|
+
};
|
|
206
|
+
step();
|
|
224
207
|
}
|
|
225
208
|
asmBtn?.addEventListener('click', () => { userPaused = false; assemble(); });
|
|
226
209
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** a drop that overlaps waits this long on one cell before anything shows (ms) */
|
|
2
|
+
export declare const DWELL_HINT = 150;
|
|
3
|
+
/** and this long, from the same start, before the things in its way give way (ms) */
|
|
4
|
+
export declare const DWELL_GIVE = 700;
|
|
5
|
+
/** what gave way goes back this long after the dragged thing no longer needs the place (ms) */
|
|
6
|
+
export declare const BACK_AFTER = 250;
|
|
7
|
+
/** a thing's glide to its place, or back (ms) */
|
|
8
|
+
export declare const GLIDE = 180;
|
|
9
|
+
/** the jiggle: how far (screen px), and how often (a second) */
|
|
10
|
+
export declare const JIGGLE: {
|
|
11
|
+
px: number;
|
|
12
|
+
hz: number;
|
|
13
|
+
};
|
|
14
|
+
/** the most things that may step aside for one drop */
|
|
15
|
+
export declare const MAX_CHAIN = 3;
|
|
16
|
+
export interface Rect {
|
|
17
|
+
x0: number;
|
|
18
|
+
y0: number;
|
|
19
|
+
x1: number;
|
|
20
|
+
y1: number;
|
|
21
|
+
}
|
|
22
|
+
export interface Beside extends Rect {
|
|
23
|
+
id: string;
|
|
24
|
+
/** whether it may be pinned somewhere else */
|
|
25
|
+
movable: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface WayOptions {
|
|
28
|
+
/** where the dragged thing would be */
|
|
29
|
+
foot: Rect;
|
|
30
|
+
/** everything else in the container */
|
|
31
|
+
others: Beside[];
|
|
32
|
+
/** the way it was going: its last step, or from where it started */
|
|
33
|
+
going: [number, number];
|
|
34
|
+
/** what a thing that steps aside must stay in (the container, less its margin); none: anywhere */
|
|
35
|
+
bounds?: Rect;
|
|
36
|
+
max?: number;
|
|
37
|
+
}
|
|
38
|
+
export declare const hits: (a: Rect, b: Rect) => boolean;
|
|
39
|
+
/** The steps (whole cells) of what would move, by id; undefined: nothing can make way. */
|
|
40
|
+
export declare function makeWay({ foot, others, going, bounds, max }: WayOptions): Map<string, [number, number]> | undefined;
|
|
@@ -4,9 +4,10 @@ import { type Actions } from './actions.js';
|
|
|
4
4
|
import { type Move } from '../../iso-objects/geometry.js';
|
|
5
5
|
import { type KindCatalog } from '../../iso-objects/kinds.js';
|
|
6
6
|
import type { CompiledScene } from '../../iso-objects/compile.js';
|
|
7
|
-
import type { EditorModel } from '../model.js';
|
|
7
|
+
import type { EditorModel, Command } from '../model.js';
|
|
8
8
|
import type { Problem } from '../validate.js';
|
|
9
9
|
import { type Commands } from '../commands.js';
|
|
10
|
+
import { type Beside } from '../make-way.js';
|
|
10
11
|
import type { ObjectKindInfo, ObjectRef, ConnectPlan, GroupPlan } from '../adapter.js';
|
|
11
12
|
import { type Path } from '../path.js';
|
|
12
13
|
import { type View } from '../../iso-viewer/viewport.js';
|
|
@@ -90,8 +91,12 @@ export interface CanvasUi {
|
|
|
90
91
|
* its own at the canvas's left, with a search box filtering by label and section, resizable and collapsible; its
|
|
91
92
|
* width and whether it is collapsed are kept in the host's store as `canvas-palette-dock`) */
|
|
92
93
|
paletteLayout?: 'floating' | 'docked';
|
|
93
|
-
/** (0.12.5) what a double click on an object does: shows it in the text (the default), or renames it
|
|
94
|
+
/** (0.12.5) what a double click on an object does: shows it in the text (the default), or renames it (0.14.1: what has no
|
|
95
|
+
* name, a connection, does nothing then) */
|
|
94
96
|
doubleClick?: 'text' | 'rename';
|
|
97
|
+
/** (0.14.0) whether what is in a drag's way jiggles before it gives way, and glides: 'always' (the default), or
|
|
98
|
+
* 'respect': not where the viewer prefers reduced motion (the outlines of where it would go still show) */
|
|
99
|
+
dragMotion?: 'always' | 'respect';
|
|
95
100
|
text: {
|
|
96
101
|
stage: string;
|
|
97
102
|
dragGroup: string;
|
|
@@ -134,6 +139,9 @@ export interface CanvasKit<M, D extends CanvasDrawing> {
|
|
|
134
139
|
} | undefined;
|
|
135
140
|
/** (0.10.0) the selection made into a new container (the adapter's group): Group, ⌘G, one undo step */
|
|
136
141
|
group?(members: ObjectRef[], data: unknown): GroupPlan | undefined;
|
|
142
|
+
/** (0.14.0) the palette's entries as what they make, drawn small (palette-look.ts): what draws those that show and aren't
|
|
143
|
+
* drawn yet. None: the entries' icons */
|
|
144
|
+
looks?(palette: HTMLElement, data: () => unknown, ui: CanvasUi, theme: string): () => void;
|
|
137
145
|
actions: Actions;
|
|
138
146
|
/** what an object's own menu offers, beyond rename, duplicate and delete */
|
|
139
147
|
objectItems(doc: EditorModel, path: Path, origin: 'canvas' | 'menu', note?: (t: string, tone?: 'bad') => void): MenuItem[];
|
|
@@ -182,6 +190,12 @@ export interface CanvasOpts<M, D extends CanvasDrawing, A extends object = objec
|
|
|
182
190
|
/** a layer over the drawing (none: the drawing and its marks only) */
|
|
183
191
|
layer?: (ctx: CanvasCtx<D>) => CanvasLayer<A>;
|
|
184
192
|
}
|
|
193
|
+
/** a new thing as a drag would make it: inside what (none: the canvas), by which command */
|
|
194
|
+
export interface FreshPlan {
|
|
195
|
+
into?: string;
|
|
196
|
+
label: string;
|
|
197
|
+
add: Command;
|
|
198
|
+
}
|
|
185
199
|
export declare function canvasView<M, D extends CanvasDrawing, A extends object = object>(host: HTMLElement, doc: EditorModel, opts: CanvasOpts<M, D, A>): {
|
|
186
200
|
addFromPalette: (sec: string, at?: {
|
|
187
201
|
x: number;
|
|
@@ -190,10 +204,6 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
|
|
|
190
204
|
palette: HTMLDivElement;
|
|
191
205
|
groupSelection: () => void;
|
|
192
206
|
startPick: () => void;
|
|
193
|
-
objectsUnder: (at: {
|
|
194
|
-
x: number;
|
|
195
|
-
y: number;
|
|
196
|
-
}) => ObjectRef[];
|
|
197
207
|
readonly linking: {
|
|
198
208
|
from: ObjectRef;
|
|
199
209
|
x?: number;
|
|
@@ -266,6 +276,7 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
|
|
|
266
276
|
z0?: number;
|
|
267
277
|
size?: [number, number];
|
|
268
278
|
parent?: {
|
|
279
|
+
id: string;
|
|
269
280
|
w: number;
|
|
270
281
|
d: number;
|
|
271
282
|
pad: number;
|
|
@@ -277,17 +288,27 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
|
|
|
277
288
|
};
|
|
278
289
|
label: string;
|
|
279
290
|
};
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
y0: number;
|
|
283
|
-
x1: number;
|
|
284
|
-
y1: number;
|
|
285
|
-
}[];
|
|
291
|
+
/** (0.14.0) how far the view was moved to keep the container still on screen (a trial may lay it out elsewhere) */
|
|
292
|
+
shifted?: [number, number];
|
|
286
293
|
move?: Move;
|
|
287
294
|
invalid?: boolean;
|
|
288
295
|
step?: number;
|
|
289
296
|
origCd?: D;
|
|
290
297
|
gridShown?: boolean;
|
|
298
|
+
/** what stands beside it in its container, where it stood when the drag began */
|
|
299
|
+
beside?: Beside[];
|
|
300
|
+
/** (0.14.0) what gave way to it, by how many cells; what would, while the drop waits; the last cell it could drop on */
|
|
301
|
+
given?: Map<string, [number, number]>;
|
|
302
|
+
way?: Map<string, [number, number]>;
|
|
303
|
+
clearAt?: [number, number];
|
|
304
|
+
/** (0.14.0) a new thing, from the palette (origCd: the drawing without it): the drawing with it, and what it is made as */
|
|
305
|
+
fresh?: {
|
|
306
|
+
base: D;
|
|
307
|
+
name: string;
|
|
308
|
+
path: Path;
|
|
309
|
+
plan: FreshPlan;
|
|
310
|
+
text: string;
|
|
311
|
+
};
|
|
291
312
|
/** siblings that flow after the dragged item, pinned where they stand so the drag doesn't push them */
|
|
292
313
|
keep?: [string, [number, number]][];
|
|
293
314
|
sel0?: Path[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CanvasDrawing, CanvasKit } from './canvas.js';
|
|
2
|
+
type Kit<M, D extends CanvasDrawing> = Pick<CanvasKit<M, D>, 'kinds' | 'commands' | 'trial'>;
|
|
3
|
+
/** The kit's `looks`: the entries that show, one at a time, each once; an entry that can't be drawn alone keeps its icon. */
|
|
4
|
+
export declare const paletteLooks: <M, D extends CanvasDrawing>(K: Kit<M, D>) => NonNullable<CanvasKit<M, D>['looks']>;
|
|
5
|
+
export {};
|
|
@@ -41,6 +41,11 @@ export interface DomainView<R, D extends CanvasDrawing> {
|
|
|
41
41
|
paletteLayout?: 'floating' | 'docked';
|
|
42
42
|
/** (0.12.5) what a double click on an object of the canvas does: shows it in the text (the default), or renames it */
|
|
43
43
|
doubleClick?: 'text' | 'rename';
|
|
44
|
+
/** (0.14.0) the palette's entries with their icon (the default), or with the thing itself, drawn small in the current theme */
|
|
45
|
+
paletteLook?: 'icon' | 'object';
|
|
46
|
+
/** (0.14.0) what is in a drag's way jiggles before it gives way, and glides: 'always' (the default), or 'respect': not where
|
|
47
|
+
* the viewer prefers reduced motion */
|
|
48
|
+
dragMotion?: 'always' | 'respect';
|
|
44
49
|
/** the canvas's 2D view (0.6.0): a 3D | 2D switch; its link kinds' styles (the host's canvas CSS adds flatCss) */
|
|
45
50
|
flat?: CanvasKit<R, D>['flat'];
|
|
46
51
|
/** a layer over the canvas, and a part beside the views (A: their calls) */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CompiledScene } from './compile.js';
|
|
2
|
+
export declare const ANT_SPEED: number;
|
|
3
|
+
export declare const ANT_DASH: Record<string, [number, number]>;
|
|
4
|
+
export declare const ANT_STILL: string[];
|
|
5
|
+
export interface AntsOptions {
|
|
6
|
+
/** how it moves (default: smil); 'none': the dashes, standing still */
|
|
7
|
+
by?: 'css' | 'smil' | 'none';
|
|
8
|
+
/** the connectors that march (default: every one that may) */
|
|
9
|
+
ids?: string[];
|
|
10
|
+
/** units a second, in the drawing's units (default: 32 in 1.1 s) */
|
|
11
|
+
speed?: number;
|
|
12
|
+
dash?: [number, number];
|
|
13
|
+
/** the connectors' dashes, by kind: the theme's `kinds` (a dashed kind marches with its own dash) */
|
|
14
|
+
kinds?: Record<string, {
|
|
15
|
+
dash?: 'solid' | 'dashed' | 'dotted';
|
|
16
|
+
}>;
|
|
17
|
+
/** kinds whose connectors stand still (default: blocked, planned) */
|
|
18
|
+
still?: string[];
|
|
19
|
+
}
|
|
20
|
+
/** for 'css': one rule and its keyframes. A page stops them, where they are, with --ants: paused. */
|
|
21
|
+
export declare const ANTS_CSS = "\n.flow.iso-ants{stroke-dasharray:var(--ant-on) var(--ant-off);animation:iso-ants var(--ant-turn) linear infinite;animation-play-state:var(--ants,running)}\n@keyframes iso-ants{to{stroke-dashoffset:var(--ant-to)}}\n";
|
|
22
|
+
/** the dash a connector marches with, or undefined when it stands still */
|
|
23
|
+
export declare function antDash(kind: string, o?: Pick<AntsOptions, 'dash' | 'kinds' | 'still'>): [number, number] | undefined;
|
|
24
|
+
/** what a scene's `ants:` in the file asks for, as options; undefined: none */
|
|
25
|
+
export declare function antsOf(raw: {
|
|
26
|
+
ants?: boolean | string[] | {
|
|
27
|
+
ids?: string[];
|
|
28
|
+
speed?: number;
|
|
29
|
+
dash?: [number, number];
|
|
30
|
+
};
|
|
31
|
+
} | undefined): Pick<AntsOptions, 'ids' | 'speed' | 'dash'> | undefined;
|
|
32
|
+
/** The scene's still, as SVG text, with its connectors marching. */
|
|
33
|
+
export declare function withAnts(scene: Pick<CompiledScene, 'rendered' | 'routes'>, o?: AntsOptions): string;
|
|
@@ -5,6 +5,7 @@ import { type RenderedScene } from './scene.js';
|
|
|
5
5
|
import { type Routed } from './route.js';
|
|
6
6
|
import { type Steps } from './steps.js';
|
|
7
7
|
import { type KindCatalog } from './kinds.js';
|
|
8
|
+
import type { MotionDoc } from './motion-doc.js';
|
|
8
9
|
import type { GridDef, RawDiagram, Theme } from './types.js';
|
|
9
10
|
export interface CompiledScene {
|
|
10
11
|
id: string;
|
|
@@ -15,6 +16,8 @@ export interface CompiledScene {
|
|
|
15
16
|
rendered: RenderedScene;
|
|
16
17
|
grid: GridDef;
|
|
17
18
|
assemble: boolean;
|
|
19
|
+
/** the file's `motion:` on this scene, checked against the drawing (a file with errors in it has none) */
|
|
20
|
+
motion?: MotionDoc;
|
|
18
21
|
}
|
|
19
22
|
export interface Compiled {
|
|
20
23
|
ok: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Side, StepRef, RawPlacement, RawDeco, RawNode, RawGate, RawRegion, RawNote, RawScene, GridDef, RawDiagram, RegionKindName, Placed, RawRole, RawKind, Theme } from './types.js';
|
|
1
|
+
export type { Side, StepRef, RawPlacement, RawDeco, RawNode, RawGate, RawRegion, RawNote, RawScene, GridDef, RawDiagram, RegionKindName, Placed, RawRole, RawKind, Theme, RawMotion, RawVariant } from './types.js';
|
|
2
2
|
export { regionKind, nodeKind, nodeKindOr, wallHeight, kindsCss } from './kinds.js';
|
|
3
3
|
export type { RegionShape, RegionKind, KindCatalog } from './kinds.js';
|
|
4
4
|
export { drawDecos, boxAsset, plate, cloudPath, drawCloud, defaultLabel, registerMarks, markCss, iconPainter, facePainter, placeholderIcon } from './assets.js';
|
|
@@ -11,6 +11,19 @@ export { silhouette, polyBounds, polyRectArea, rectArea, lineRectArea, Obstacles
|
|
|
11
11
|
export type { Rect, Poly, LabelText, PlacedLabel, CalloutSpot } from './labels.js';
|
|
12
12
|
export { offscreen, assembly } from './assemble.js';
|
|
13
13
|
export type { Edge, Piece, Assembly } from './assemble.js';
|
|
14
|
+
export { ASSEMBLE_STYLES, DISASSEMBLE_STYLES, MOTION_ORDERS, MOTION_EASINGS, motionModel, motionOrder, planOf, assemble, disassemble, alongPath, svgAt, paint, introSvg } from './motion.js';
|
|
15
|
+
export type { AssembleStyle, DisassembleStyle, MotionOrder, MotionEasing, Direction, PieceMotion, AssembleOptions, DisassembleOptions, PlanOptions, MotionPiece, MotionModel, MotionPlan, ScenePlan, SceneState, ItemState, LabelState, RouteState } from './motion.js';
|
|
16
|
+
export { drawLooks } from './looks.js';
|
|
17
|
+
export { withAnts, antsOf, antDash, ANTS_CSS, ANT_SPEED, ANT_DASH, ANT_STILL } from './ants.js';
|
|
18
|
+
export type { AntsOptions } from './ants.js';
|
|
19
|
+
export { motion, MotionBuilder, SeriesBuilder, NodesBuilder } from './motion-builder.js';
|
|
20
|
+
export type { SequenceOptions, Timing, CameraVerbs, Ids as MotionIds } from './motion-builder.js';
|
|
21
|
+
export { bindMotion, motionOfSteps } from './timeline.js';
|
|
22
|
+
export type { Timeline, BindOptions, BeatInfo, Cue } from './timeline.js';
|
|
23
|
+
export { MOTION_SCHEMA, EASING_NAMES, EXTRAPOLATE, checkMotion, msOf, readMs, easeOf, curveAt, springAt, bezier } from './motion-doc.js';
|
|
24
|
+
export type { MotionDoc, MotionNode, MotionTime, MotionEase, EasingName, Extrapolate, SpringConfig, Curve, Say as MotionSay, Focus, ReadTime, Sequence, SeriesItem, Transition, MotionDiag } from './motion-doc.js';
|
|
25
|
+
export { resolveSvg, FONT_STACKS } from './resolve.js';
|
|
26
|
+
export type { ResolveOptions, ThemeMode } from './resolve.js';
|
|
14
27
|
export { durationFor, resolveSteps, midpoint } from './steps.js';
|
|
15
28
|
export type { RawStep, Token, StepData, Say, Mark, Badge, Steps } from './steps.js';
|
|
16
29
|
export { focusView } from './focus.js';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Curve, Focus, MotionDoc, MotionEase, MotionNode, MotionTime, ReadTime, Say, Sequence, SeriesItem, Transition } from './motion-doc.js';
|
|
2
|
+
import type { AssembleOptions, DisassembleOptions } from './motion.js';
|
|
3
|
+
export interface Timing {
|
|
4
|
+
from?: MotionTime;
|
|
5
|
+
over?: MotionTime;
|
|
6
|
+
easing?: MotionEase;
|
|
7
|
+
}
|
|
8
|
+
/** a sequence's own keys; `read`: as long as its words take (true, or how) */
|
|
9
|
+
export type SequenceOptions = Omit<Sequence, 'name' | 'children' | 'layers' | 'series' | 'duration'> & {
|
|
10
|
+
duration?: MotionTime;
|
|
11
|
+
read?: ReadTime['read'];
|
|
12
|
+
};
|
|
13
|
+
export type Ids = string | string[];
|
|
14
|
+
export interface CameraVerbs<B> {
|
|
15
|
+
focus(on: Ids | [number, number, number, number], o?: Timing & {
|
|
16
|
+
zoom?: number;
|
|
17
|
+
margin?: number;
|
|
18
|
+
}): B;
|
|
19
|
+
fit(o?: Timing): B;
|
|
20
|
+
}
|
|
21
|
+
/** what is in a sequence (or in a document's layers), in the order it is said */
|
|
22
|
+
export declare class NodesBuilder {
|
|
23
|
+
/** @internal */
|
|
24
|
+
readonly nodes: MotionNode[];
|
|
25
|
+
private add;
|
|
26
|
+
assemble(o?: Omit<AssembleOptions, 'duration'>, t?: Timing): this;
|
|
27
|
+
disassemble(o?: Omit<DisassembleOptions, 'duration'>, t?: Timing): this;
|
|
28
|
+
/** tokens along connectors, one after another; a nested list at once; "id:kind" */
|
|
29
|
+
travel(routes: (string | string[])[], o?: Timing & {
|
|
30
|
+
each?: MotionTime;
|
|
31
|
+
hold?: MotionTime;
|
|
32
|
+
loop?: boolean;
|
|
33
|
+
}): this;
|
|
34
|
+
pulse(ids: Ids, o?: Timing & {
|
|
35
|
+
loop?: boolean;
|
|
36
|
+
}): this;
|
|
37
|
+
ants(ids?: Ids | true, o?: Timing & {
|
|
38
|
+
speed?: number;
|
|
39
|
+
dash?: [number, number];
|
|
40
|
+
}): this;
|
|
41
|
+
draw(routes: Ids, o?: Timing & {
|
|
42
|
+
by?: 'stroke' | 'grow';
|
|
43
|
+
stagger?: MotionTime;
|
|
44
|
+
}): this;
|
|
45
|
+
type(ids: Ids, o?: Timing): this;
|
|
46
|
+
move(id: string, o: {
|
|
47
|
+
from?: MotionTime;
|
|
48
|
+
x?: Curve;
|
|
49
|
+
y?: Curve;
|
|
50
|
+
scale?: Curve;
|
|
51
|
+
opacity?: Curve;
|
|
52
|
+
}): this;
|
|
53
|
+
lift(ids: Ids, by: number, o?: Timing & {
|
|
54
|
+
stagger?: MotionTime;
|
|
55
|
+
to?: 'up' | 'down';
|
|
56
|
+
opacity?: Curve;
|
|
57
|
+
}): this;
|
|
58
|
+
focus(lit: Ids, o?: Timing & Omit<Focus, 'lit'> & {
|
|
59
|
+
fade?: MotionTime;
|
|
60
|
+
}): this;
|
|
61
|
+
highlight(ids: Ids, o?: Timing & {
|
|
62
|
+
fade?: MotionTime;
|
|
63
|
+
}): this;
|
|
64
|
+
/** the view: on a thing, some things or a box; or the whole drawing again */
|
|
65
|
+
get camera(): CameraVerbs<this>;
|
|
66
|
+
/** a sequence in this one: a clock of its own, from `from` */
|
|
67
|
+
sequence(name: string | undefined, o?: SequenceOptions, fill?: (b: NodesBuilder) => unknown): this;
|
|
68
|
+
/** sequences one after another */
|
|
69
|
+
series(fill: (s: SeriesBuilder) => unknown): this;
|
|
70
|
+
/** nodes over one another */
|
|
71
|
+
layers(fill: (b: NodesBuilder) => unknown): this;
|
|
72
|
+
}
|
|
73
|
+
export declare class SeriesBuilder {
|
|
74
|
+
/** @internal */
|
|
75
|
+
readonly items: SeriesItem[];
|
|
76
|
+
sequence(name: string | undefined, o?: SequenceOptions, fill?: (b: NodesBuilder) => unknown): this;
|
|
77
|
+
transition(t: Transition): this;
|
|
78
|
+
}
|
|
79
|
+
export declare class MotionBuilder extends SeriesBuilder {
|
|
80
|
+
private over;
|
|
81
|
+
private marks;
|
|
82
|
+
private head;
|
|
83
|
+
constructor(head?: {
|
|
84
|
+
fps?: number;
|
|
85
|
+
seed?: number;
|
|
86
|
+
ambient?: 'on' | 'off';
|
|
87
|
+
});
|
|
88
|
+
/** a beat: a sequence with commentary */
|
|
89
|
+
beat(name: string, say: Say, o?: SequenceOptions, fill?: (b: NodesBuilder) => unknown): this;
|
|
90
|
+
/** the whole drawing arrives (a sequence as long as that takes) */
|
|
91
|
+
assemble(o?: Omit<AssembleOptions, 'duration'>, t?: Timing): this;
|
|
92
|
+
/** the whole drawing leaves */
|
|
93
|
+
disassemble(o?: Omit<DisassembleOptions, 'duration'>, t?: Timing): this;
|
|
94
|
+
/** a name for a moment: ms, or "beat+1200" */
|
|
95
|
+
mark(name: string, at: MotionTime): this;
|
|
96
|
+
/** nodes over the whole document, on its own clock */
|
|
97
|
+
layers(fill: (b: NodesBuilder) => unknown): this;
|
|
98
|
+
toJSON(): MotionDoc;
|
|
99
|
+
}
|
|
100
|
+
/** Start a motion document. */
|
|
101
|
+
export declare const motion: (head?: {
|
|
102
|
+
fps?: number;
|
|
103
|
+
seed?: number;
|
|
104
|
+
ambient?: 'on' | 'off';
|
|
105
|
+
}) => MotionBuilder;
|