@phin-tech/dottie 0.0.0-stage → 0.1.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.
@@ -0,0 +1,28 @@
1
+ import { angle } from "./element.ts";
2
+ import type { Element, Page, Port } from "./model.ts";
3
+ import { type Point, type Rect } from "./path.ts";
4
+ export type Index = Map<string, Element>;
5
+ export declare function portPoint(shape: Element, port: Port): Point;
6
+ /** Where the line from the shape's center toward `target` crosses its outline. */
7
+ export declare function edgePoint(shape: Element, toward: Point): Point;
8
+ export declare function endpoints(e: Element, index: Index): [Point, Point];
9
+ export type Route = {
10
+ kind: "polyline";
11
+ points: Point[];
12
+ } | {
13
+ kind: "cubic";
14
+ a: Point;
15
+ b: Point;
16
+ c: Point;
17
+ d: Point;
18
+ };
19
+ /** A route's centerline as points; a cubic is sampled at 25 points. */
20
+ export declare function routePoints(r: Route): Point[];
21
+ export declare function route(e: Element, index: Index): Route;
22
+ /** Arrowhead wing points for a tip at `tip` arriving from `from`. */
23
+ export declare function arrowhead(tip: Point, from: Point, size: number): [Point, Point];
24
+ export declare function connectorBounds(e: Element, index: Index): Rect;
25
+ /** Point halfway along the route, where a label sits. */
26
+ export declare function midpoint(e: Element, index: Index): Point;
27
+ export declare function indexOf(page: Page): Index;
28
+ export { angle };
@@ -0,0 +1,19 @@
1
+ import { frame } from "./element.ts";
2
+ import type { Element, RGBA } from "./model.ts";
3
+ import { Path, type Point } from "./path.ts";
4
+ export declare const BAND = 0.75;
5
+ /** Grid lines inside the polygons (even-odd) at world multiples of `cell`, leaving out lines on the edge. */
6
+ export declare function gridLines(polygons: Point[][], cell: number): [Point, Point][];
7
+ /** The faint pencil the grid is ruled in. */
8
+ export declare function lineColor(floor: RGBA): RGBA;
9
+ export declare function isFloor(e: Element): boolean;
10
+ export interface Rock {
11
+ ink: RGBA;
12
+ width: number;
13
+ path: Path;
14
+ }
15
+ /** A well-mixed value in [0, 1) from two integers and a salt (Guildhall's 32-bit hash). */
16
+ export declare function hash01(i: number, j: number, salt: number): number;
17
+ /** Hatching for every floor (already filtered by `isFloor`), in page coordinates. */
18
+ export declare function rock(floors: Element[]): Rock[];
19
+ export { frame };
@@ -0,0 +1,22 @@
1
+ import { type Element, type RGBA } from "./model.ts";
2
+ import { Path, type Point, type Rect, midX, midY } from "./path.ts";
3
+ export declare const frame: (e: Element) => Rect;
4
+ export declare const angle: (e: Element) => number;
5
+ export declare const center: (e: Element) => Point;
6
+ /** A point in the element's own (unrotated) frame, on the canvas. */
7
+ export declare const rotated: (e: Element, p: Point) => Point;
8
+ /** A canvas point in the element's own (unrotated) frame. */
9
+ export declare const unrotated: (e: Element, p: Point) => Point;
10
+ /** Bounding box of the frame after rotation. */
11
+ export declare function rotatedBounds(e: Element): Rect;
12
+ /** The element with automatic ink drawn as `ink`; a light ink is not used on a light, mostly opaque fill. */
13
+ export declare function resolvingInk(e: Element, ink: RGBA): Element;
14
+ export interface Contour {
15
+ closed: boolean;
16
+ points: Point[];
17
+ }
18
+ /** A `.path` element's contours in canvas coordinates: `1 + 3n` Bézier points each. */
19
+ export declare function shapeContours(e: Element): Contour[];
20
+ /** The exact (not sketchy) geometry of a `.path`. */
21
+ export declare function shapePath(e: Element): Path;
22
+ export { midX, midY };
@@ -0,0 +1,21 @@
1
+ import { type DottieFile, type RGBA } from "./model.ts";
2
+ export * from "./model.ts";
3
+ export { inspect, inspectFrame, inspectPage, sampleTimes } from "./inspect.ts";
4
+ export { DottiePlayer, Playback, definePlayer, pageIndex, withRoughness } from "./player.ts";
5
+ export { bounds, plan, svg, svgParts, type Plan, type Part } from "./svg.ts";
6
+ export { themeNamed, themes, type Theme } from "./theme.ts";
7
+ export { cameraView, frameTimes, posterTime, resolved, sceneAt, still, transientElements } from "./timeline.ts";
8
+ export interface RenderOptions {
9
+ /** Page name or 1-based number; the first page by default. */
10
+ page?: string | number;
11
+ /** Seconds into the animation; its poster frame (the end, unless set) by default. */
12
+ at?: number;
13
+ /** Draw precisely instead of sketchy. */
14
+ clean?: boolean;
15
+ /** Page color behind the drawing; null for transparent. White (or the page's theme) by default. */
16
+ background?: RGBA | null;
17
+ }
18
+ /** One page of a drawing as an SVG document, as Dottie's own SVG export draws it. */
19
+ export declare function render(source: string | DottieFile | unknown, options?: RenderOptions): string;
20
+ /** The library's version. */
21
+ export declare const VERSION = "0.1.0";
@@ -0,0 +1,7 @@
1
+ import { type DottieFile, type Page } from "./model.ts";
2
+ /** Times worth checking on an animated page (Inspector.sampleTimes). */
3
+ export declare function sampleTimes(page: Page): number[];
4
+ export declare function inspectFrame(page: Page, t: number): Record<string, unknown>;
5
+ export declare function inspectPage(page: Page, n: number, times: number[]): Record<string, unknown>;
6
+ /** A whole file: every page at its sample times (or `times`). */
7
+ export declare function inspect(file: DottieFile, times?: number[]): Record<string, unknown>;
@@ -0,0 +1,11 @@
1
+ export declare const ascent = 0.951995849609375, descent = 0.2129974365234375, leading = 0.0279998779296875;
2
+ export declare const boldAscent = 0.975006103515625, boldDescent = 0.2169952392578125, boldLeading = 0.0290069580078125;
3
+ export declare const italicAscent = 0.957000732421875, italicDescent = 0.2129974365234375, italicLeading = 0.0279998779296875;
4
+ export declare const boldItalicAscent = 0.975006103515625, boldItalicDescent = 0.2169952392578125, boldItalicLeading = 0.0290069580078125;
5
+ export declare const monoAdvance = 0.60205078125, monoAscent = 0.92822265625, monoDescent = 0.23583984375;
6
+ export declare const fonts: Record<"regular" | "bold" | "italic" | "boldItalic", {
7
+ w: Record<string, number>;
8
+ k: Record<string, number>;
9
+ }>;
10
+ /** Ascent, descent and leading per em of the fallback font for characters Helvetica Neue lacks. */
11
+ export declare const fallbackMetrics: Record<string, [number, number, number]>;
@@ -0,0 +1,181 @@
1
+ export interface RGBA {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ a: number;
6
+ }
7
+ export type FillStyle = "solid" | "hachure" | "crossHatch" | "grid";
8
+ export type DashStyle = "solid" | "dashed" | "dotted";
9
+ export type ElementKind = "rectangle" | "ellipse" | "diamond" | "text" | "connector" | "freehand" | "path" | "note" | "image";
10
+ export type Port = "top" | "right" | "bottom" | "left";
11
+ export type Routing = "straight" | "curved" | "elbow";
12
+ export type Arrowhead = "none" | "arrow" | "triangle" | "dot" | "bar";
13
+ export type Ease = "linear" | "easeIn" | "easeOut" | "easeInOut" | "hold";
14
+ export interface Style {
15
+ stroke: RGBA;
16
+ fill: RGBA;
17
+ fillStyle: FillStyle;
18
+ strokeWidth: number;
19
+ dash: DashStyle;
20
+ roughness: number;
21
+ bowing: number;
22
+ fontSize: number;
23
+ gridSize: number | null;
24
+ opacity: number | null;
25
+ }
26
+ export interface Endpoint {
27
+ elementID: string | null;
28
+ port: Port | null;
29
+ x: number;
30
+ y: number;
31
+ }
32
+ export interface ConnectorData {
33
+ start: Endpoint;
34
+ end: Endpoint;
35
+ routing: Routing;
36
+ startHead: Arrowhead;
37
+ endHead: Arrowhead;
38
+ }
39
+ export interface PathSubpath {
40
+ closed: boolean;
41
+ coords: number[];
42
+ }
43
+ export interface StrokePoint {
44
+ x: number;
45
+ y: number;
46
+ }
47
+ export interface EmbeddedImage {
48
+ data: string;
49
+ format: string;
50
+ }
51
+ export interface Element {
52
+ id: string;
53
+ /** A kind dottie.js doesn't know is kept as written and drawn as a labelled placeholder. */
54
+ kind: ElementKind | string;
55
+ x: number;
56
+ y: number;
57
+ width: number;
58
+ height: number;
59
+ style: Style;
60
+ seed: number;
61
+ layerID: string;
62
+ text: string | null;
63
+ connector: ConnectorData | null;
64
+ groupID: string | null;
65
+ points: StrokePoint[] | null;
66
+ path: number[] | null;
67
+ subpaths: PathSubpath[] | null;
68
+ evenOdd: boolean | null;
69
+ rotation: number | null;
70
+ link: string | null;
71
+ anchor: string | null;
72
+ /** Base64 bytes; an empty `data` is a picture that couldn't be found (drawn crossed out). */
73
+ image: EmbeddedImage | null;
74
+ reveal: number | null;
75
+ }
76
+ export interface Layer {
77
+ id: string;
78
+ name: string;
79
+ visible: boolean;
80
+ locked: boolean;
81
+ }
82
+ export interface Keyframe {
83
+ t: number;
84
+ x?: number;
85
+ y?: number;
86
+ width?: number;
87
+ height?: number;
88
+ rotation?: number;
89
+ strokeWidth?: number;
90
+ stroke?: RGBA;
91
+ fill?: RGBA;
92
+ visible?: boolean;
93
+ reveal?: number;
94
+ opacity?: number;
95
+ ease?: Ease;
96
+ }
97
+ export interface Follow {
98
+ path: string;
99
+ start: number;
100
+ end: number;
101
+ ease: Ease | null;
102
+ reverse: boolean | null;
103
+ orient: boolean | null;
104
+ laps: number | null;
105
+ }
106
+ export interface Repeat {
107
+ start: number;
108
+ end: number;
109
+ count: number | null;
110
+ }
111
+ export interface Track {
112
+ element: string;
113
+ keys: Keyframe[];
114
+ boil: boolean | null;
115
+ follow: Follow[] | null;
116
+ repeats: Repeat[] | null;
117
+ }
118
+ export interface CameraKey {
119
+ t: number;
120
+ x: number;
121
+ y: number;
122
+ width: number;
123
+ height: number;
124
+ ease: Ease | null;
125
+ }
126
+ export interface Marker {
127
+ t: number;
128
+ name: string;
129
+ }
130
+ export interface Timeline {
131
+ fps: number;
132
+ duration: number;
133
+ boil: number | null;
134
+ settle: boolean | null;
135
+ poster: number | null;
136
+ tracks: Track[];
137
+ camera: CameraKey[] | null;
138
+ markers: Marker[] | null;
139
+ }
140
+ export interface Page {
141
+ id: string;
142
+ name: string;
143
+ layers: Layer[];
144
+ elements: Element[];
145
+ theme: string | null;
146
+ timeline: Timeline | null;
147
+ }
148
+ export interface DottieFile {
149
+ version: number;
150
+ pages: Page[];
151
+ /** What was skipped or guessed while reading. Empty for a file Dottie wrote. */
152
+ warnings: string[];
153
+ }
154
+ /** The newest file version this library was written for. Newer files still load, with a warning. */
155
+ export declare const SUPPORTED_VERSION = 2;
156
+ export declare const KINDS: readonly string[];
157
+ /** The fields dottie.js reads, per object; the schema test checks they're exactly the schema's. Anything else
158
+ * in a file is newer than this version and is reported in `warnings`. */
159
+ export declare const KNOWN_FIELDS: Record<string, readonly string[]>;
160
+ export declare const MAX_DURATION = 3600;
161
+ export declare const BOIL_DRAWINGS = 3;
162
+ export declare const black: RGBA;
163
+ export declare const clear: RGBA;
164
+ export declare const inkOnDark: RGBA;
165
+ export declare class DottieFormatError extends Error {
166
+ }
167
+ export declare function clampTime(t: number): number;
168
+ export declare function clampFPS(f: number): number;
169
+ export declare function repeatIsValid(r: Repeat): boolean;
170
+ /** Sorts in place by `key`, keeping equal keys in their original order (as Swift's sort happens to for these). */
171
+ export declare function stableSortBy<T>(a: T[], key: (v: T) => number): void;
172
+ /** Reads a .dottie file from its JSON text (or the parsed object). Throws `DottieFormatError` when it isn't one. */
173
+ export declare function parseDottie(source: string | unknown): DottieFile;
174
+ export declare function luminance(c: RGBA): number;
175
+ export declare function sameColor(a: RGBA, b: RGBA): boolean;
176
+ export declare function isAutomaticInk(c: RGBA): boolean;
177
+ export declare function cloneElement(e: Element): Element;
178
+ /** Elements back to front: lower layers first, array order within a layer. */
179
+ export declare function orderedElements(page: Page): Element[];
180
+ /** Elements by id; with duplicate ids the first one wins, as in Dottie. */
181
+ export declare function elementIndex(page: Page): Map<string, Element>;
@@ -0,0 +1,47 @@
1
+ import type { Element } from "./model.ts";
2
+ import { type Rect } from "./path.ts";
3
+ export declare const PADDING = 12;
4
+ /** Where the text goes inside a note's frame. */
5
+ export declare function textRect(f: Rect): Rect;
6
+ type Inline = {
7
+ text: string;
8
+ bold?: boolean;
9
+ italic?: boolean;
10
+ mono?: boolean;
11
+ strike?: boolean;
12
+ link?: boolean;
13
+ };
14
+ type Block = {
15
+ kind: "heading";
16
+ level: number;
17
+ inline: Inline[];
18
+ } | {
19
+ kind: "paragraph";
20
+ inline: Inline[];
21
+ } | {
22
+ kind: "list";
23
+ ordered: number | null;
24
+ items: {
25
+ checkbox: boolean | null;
26
+ children: Block[];
27
+ }[];
28
+ } | {
29
+ kind: "quote";
30
+ children: Block[];
31
+ } | {
32
+ kind: "code";
33
+ text: string;
34
+ } | {
35
+ kind: "rule";
36
+ } | {
37
+ kind: "table";
38
+ align: (string | null)[];
39
+ head: Inline[][];
40
+ rows: Inline[][][];
41
+ };
42
+ export declare function parseBlocks(source: string): Block[];
43
+ /** Inline Markdown into styled runs; soft and hard breaks become line separators. */
44
+ export declare function inline(src: string, style?: Omit<Inline, "text">): Inline[];
45
+ /** The note's text as positioned SVG, laid out as Dottie lays it out (SVG.swift's noteText). */
46
+ export declare function noteMarkup(source: string, e: Element): string;
47
+ export {};
@@ -0,0 +1,76 @@
1
+ export interface Point {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ export interface Rect {
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ }
11
+ export type Segment = {
12
+ op: "M";
13
+ p: Point;
14
+ } | {
15
+ op: "L";
16
+ p: Point;
17
+ } | {
18
+ op: "Q";
19
+ c: Point;
20
+ p: Point;
21
+ } | {
22
+ op: "C";
23
+ c1: Point;
24
+ c2: Point;
25
+ p: Point;
26
+ } | {
27
+ op: "Z";
28
+ };
29
+ export declare class Path {
30
+ segments: Segment[];
31
+ get isEmpty(): boolean;
32
+ moveTo(p: Point): this;
33
+ lineTo(p: Point): this;
34
+ quadTo(p: Point, c: Point): this;
35
+ curveTo(p: Point, c1: Point, c2: Point): this;
36
+ close(): this;
37
+ addPath(other: Path): this;
38
+ /** move, then a line to each point (CGMutablePath.addLines). */
39
+ addLines(pts: Point[]): this;
40
+ /** CGPath(rect:): clockwise (on screen) from the top-left corner. */
41
+ static rect(r: Rect): Path;
42
+ /** CGPath(ellipseIn:): four cubics clockwise (on screen) from the right-hand point. */
43
+ addEllipse(r: Rect): this;
44
+ static ellipse(r: Rect): Path;
45
+ translated(dx: number, dy: number): Path;
46
+ /** Every contour as points, curves flattened into short segments (CGPath.contours). */
47
+ contours(): Point[][];
48
+ /** The first `fraction` of the path by length, contours in drawing order: a stroke being drawn on. */
49
+ trimmed(fraction: number): Path;
50
+ /** SVG path data, as Dottie's SVG export writes it. */
51
+ data(): string;
52
+ }
53
+ /** Swift's `.rounded()`: half away from zero. */
54
+ export declare function roundHalfAway(v: number): number;
55
+ /** Dottie's SVG number: two decimals, integers without a point. */
56
+ export declare function fmt(v: number): string;
57
+ /** Points along a path with their running length (Motion.swift's Polyline). */
58
+ export declare class Polyline {
59
+ points: Point[];
60
+ lengths: number[];
61
+ constructor(points: Point[]);
62
+ get length(): number;
63
+ /** The point `u` (0...1) of the way along, by distance. */
64
+ point(u: number): Point;
65
+ }
66
+ export declare const midX: (r: Rect) => number;
67
+ export declare const midY: (r: Rect) => number;
68
+ export declare const maxX: (r: Rect) => number;
69
+ export declare const maxY: (r: Rect) => number;
70
+ export declare function union(a: Rect | null, b: Rect): Rect;
71
+ export declare function inset(r: Rect, dx: number, dy: number): Rect;
72
+ export declare function rotate(p: Point, c: Point, a: number): Point;
73
+ /** A point on a cubic Bézier (StrokeFit.point). */
74
+ export declare function bezierPoint(b: Point[], t: number): Point;
75
+ /** A cubic Bézier chain (1 + 3n points) as a polyline of short steps (Element.flatten). */
76
+ export declare function flatten(cp: Point[], maxStep: number): Point[];
@@ -0,0 +1 @@
1
+ export * from "./index.ts";
@@ -0,0 +1,80 @@
1
+ import { type DottieFile, type Page, type RGBA } from "./model.ts";
2
+ import { type Plan } from "./svg.ts";
3
+ /** Finds a page by name (any case) or 1-based number; the first page when `spec` is empty or matches nothing. */
4
+ export declare function pageIndex(file: DottieFile, spec: string | null | undefined): number;
5
+ export declare function withRoughness(page: Page, roughness: number): Page;
6
+ /** Plays one page of a Dottie file into an element: the engine behind <dottie-player>, usable on its own. */
7
+ export declare class Playback {
8
+ readonly page: Page;
9
+ readonly plan: Plan;
10
+ readonly scenes: number[];
11
+ readonly sceneNames: string[];
12
+ readonly background: RGBA;
13
+ readonly ink: RGBA;
14
+ private svg;
15
+ private groups;
16
+ private order;
17
+ frame: number;
18
+ onFrame: ((frame: number) => void) | null;
19
+ constructor(page: Page, into: Element, options?: {
20
+ clean?: boolean;
21
+ });
22
+ get frameCount(): number;
23
+ get posterFrame(): number;
24
+ /** Draws frame `i`, replacing only the pieces whose markup changed since the last frame. */
25
+ show(i: number): void;
26
+ /** Draws the moment `t` (seconds) in the frame-`i` view. */
27
+ drawAt(t: number, i?: number): void;
28
+ /** The scene frame `i` is in, or -1 before the first. */
29
+ sceneAt(i: number): number;
30
+ }
31
+ /** HTMLElement where there is a DOM; a stand-in elsewhere, so the library still loads in Node (to render SVG). */
32
+ declare const ElementBase: typeof HTMLElement;
33
+ export declare class DottiePlayer extends ElementBase {
34
+ static observedAttributes: string[];
35
+ file: DottieFile | null;
36
+ playback: Playback | null;
37
+ private root;
38
+ private stage;
39
+ private bar;
40
+ private playButton;
41
+ private scrub;
42
+ private time;
43
+ private sceneLabel;
44
+ private prev;
45
+ private next;
46
+ private playing;
47
+ private last;
48
+ private acc;
49
+ private raf;
50
+ private loadToken;
51
+ private visible;
52
+ private observer;
53
+ constructor();
54
+ connectedCallback(): void;
55
+ disconnectedCallback(): void;
56
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
57
+ /** Loads from `src`, or from an inline JSON script child. */
58
+ load(): Promise<void>;
59
+ /** Shows an already-parsed file. */
60
+ setFile(file: DottieFile): void;
61
+ private mount;
62
+ get paused(): boolean;
63
+ get currentTime(): number;
64
+ set currentTime(t: number);
65
+ get duration(): number;
66
+ play(): void;
67
+ pause(): void;
68
+ /** Plays on to the next scene (from the start after the last). */
69
+ nextScene(): void;
70
+ /** Back to the start of this scene, or the one before if already there. */
71
+ prevScene(): void;
72
+ private setPlaying;
73
+ private schedule;
74
+ /** Steps whole frames at the timeline's rate; with scenes, playing stops at each one and at the end. */
75
+ private tick;
76
+ private key;
77
+ }
78
+ /** Registers <dottie-player> (or another tag name) once. */
79
+ export declare function definePlayer(tag?: string): void;
80
+ export {};
@@ -0,0 +1,17 @@
1
+ /** (hi, lo) as unsigned 32-bit halves of a 64-bit value. */
2
+ type U64 = [number, number];
3
+ export declare class SeededRNG {
4
+ private state;
5
+ constructor(seed: number);
6
+ /** The next 64 bits, as (hi, lo). */
7
+ next(): U64;
8
+ /** The top 53 bits of `next()`, exactly. */
9
+ private top53;
10
+ /** Uniform in -1...1. */
11
+ signed(): number;
12
+ /** Uniform in 0...1. */
13
+ unit(): number;
14
+ }
15
+ /** A different but repeatable seed for each boil step, never 0 (DottieDocument.boiled). */
16
+ export declare function boiled(seed: number, step: number): number;
17
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Path, type Point } from "./path.ts";
2
+ import type { SeededRNG } from "./rng.ts";
3
+ /** A hand-drawn line from `a` to `b`, traced twice. With `preserveEnds` both end points stay exact. */
4
+ export declare function line(a: Point, b: Point, rng: SeededRNG, roughness: number, bowing: number, preserveEnds: boolean, into: Path): void;
5
+ export declare function polygon(pts: Point[], rng: SeededRNG, roughness: number, bowing: number): Path;
6
+ export declare function ellipse(r: {
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ }, rng: SeededRNG, roughness: number): Path;
12
+ export declare function catmullRom(p: Point[], path: Path): void;
13
+ /** rough.js's default hachure angle. */
14
+ export declare const HACHURE_ANGLE: number;
15
+ /** Parallel lines `gap` apart at `angle` inside the polygons (even-odd), aligned to the shape. */
16
+ export declare function hachureLines(polygons: Point[][], angle: number, gap: number): [Point, Point][];
@@ -0,0 +1,17 @@
1
+ import { type Index } from "./connector.ts";
2
+ import type { DashStyle, Element } from "./model.ts";
3
+ import { Path, type Point } from "./path.ts";
4
+ /** The `.grid` cell size actually drawn. */
5
+ export declare const cellSize: (e: Element) => number;
6
+ /** Outline path for an element; roughness 0 gives exact geometry. */
7
+ export declare function outline(e: Element): Path;
8
+ /** Every contour of a filled shape as a polygon; only a `.path` has more than one. */
9
+ export declare function fillPolygons(e: Element): Point[][];
10
+ /** Precise shape used for fills. */
11
+ export declare function fillPath(e: Element): Path;
12
+ /** Pen-shaded fill for hachure / crossHatch, or the cell lines of a grid fill; empty for solid fills. */
13
+ export declare function hachurePath(e: Element): Path;
14
+ /** Dash lengths for a stroke width; null for a solid line. */
15
+ export declare function dashPattern(dash: DashStyle, width: number): number[] | null;
16
+ /** A connector as the stroked line (with open arrowheads) and the closed heads filled in the stroke color. */
17
+ export declare function connectorParts(e: Element, index: Index): [Path, Path];
@@ -0,0 +1,3 @@
1
+ import type { RGBA } from "./model.ts";
2
+ export declare function color(c: RGBA): string;
3
+ export declare function escapeXML(s: string): string;
@@ -0,0 +1,36 @@
1
+ import { type Index } from "./connector.ts";
2
+ import { type Element, type Page, type RGBA } from "./model.ts";
3
+ import { color, escapeXML } from "./svg-util.ts";
4
+ import { type Rect } from "./path.ts";
5
+ /** The drawing's extent plus `padding`; a floor's rock hatching reaches past its shape. */
6
+ export declare function bounds(page: Page, padding?: number): Rect;
7
+ export interface Plan {
8
+ times: number[];
9
+ /** The part of the page each frame shows. */
10
+ rects: Rect[];
11
+ /** Output size in points. */
12
+ size: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ }
17
+ /** What an animation shows over time (Exporter.animation): with a camera, its view at each frame, widened to
18
+ * the first key's shape; without, the bounds of the whole animation for every frame. */
19
+ export declare function plan(page: Page): Plan;
20
+ /** The opening `<svg>` tag for `b`, with the page color behind everything when `paint`. */
21
+ export declare function svgOpen(b: Rect, background: RGBA | null, paint: boolean): string;
22
+ export interface Part {
23
+ key: string;
24
+ markup: string;
25
+ }
26
+ /** The SVG for each thing drawn, back to front, keyed by element id (rock hatching as "rock"). */
27
+ export declare function svgParts(page: Page, background: RGBA | null, fixed?: Rect): {
28
+ bounds: Rect;
29
+ parts: Part[];
30
+ };
31
+ /** A whole page as an SVG document. Pass `background: null` for a transparent page. */
32
+ export declare function svg(page: Page, background?: RGBA | null, fixed?: Rect): string;
33
+ /** Where a connector's label sits. */
34
+ export declare function labelRect(e: Element, index: Index): Rect;
35
+ export declare function textElement(text: string, f: Rect, e: Element, centered: boolean): string;
36
+ export { color, escapeXML };
@@ -0,0 +1,15 @@
1
+ export type Face = "regular" | "bold" | "italic" | "boldItalic";
2
+ /** Width of a run of text at `fontSize`, kerned. */
3
+ export declare function measure(s: string, fontSize: number, face?: Face): number;
4
+ /** First line's height, and each further line's, for the regular face (CoreText rounds each metric). */
5
+ export declare function lineHeights(fontSize: number): [number, number];
6
+ /** Whether a line may break after `ch` when `next` follows (Unicode line breaking as CoreText does it: after
7
+ * a space, and after a slash or hyphen not followed by a digit, a space or another of itself). */
8
+ export declare function breaksAfter(ch: string, next: string): boolean;
9
+ /** Lines `s` wraps into within `maxWidth` (or inside a piece too long for a line). */
10
+ export declare function wrap(s: string, fontSize: number, maxWidth: number, face?: Face): string[];
11
+ /** The size CoreText suggests for `s` wrapped at `maxWidth`, rounded up (Renderer.textSize). */
12
+ export declare function textSize(s: string, fontSize: number, maxWidth: number): {
13
+ width: number;
14
+ height: number;
15
+ };
@@ -0,0 +1,10 @@
1
+ import type { RGBA } from "./model.ts";
2
+ export interface Theme {
3
+ id: string;
4
+ name: string;
5
+ background: RGBA;
6
+ ink: RGBA;
7
+ }
8
+ export declare const themes: Theme[];
9
+ /** The theme a page names, or null (white page, black ink) for none or one this version doesn't know. */
10
+ export declare function themeNamed(id: string | null | undefined): Theme | null;
@@ -0,0 +1,36 @@
1
+ import { type Ease, type Element, type Follow, type Page, type Timeline, type Track } from "./model.ts";
2
+ import { Polyline, type Point, type Rect } from "./path.ts";
3
+ export declare function applyEase(ease: Ease, u: number): number;
4
+ /** The time inside the track's own keys that `t` plays (repeats folded back). */
5
+ export declare function localTime(track: Track, t: number): number;
6
+ /** Whether some property is tweening at `t`: between two keys that set it to different values, not held. */
7
+ export declare function isChanging(track: Track, t: number): boolean;
8
+ /** Whether the element is shown at `t`. */
9
+ export declare function isVisible(track: Track, t: number): boolean;
10
+ /** `e` posed at `t` (returns a copy). */
11
+ export declare function applyTrack(track: Track, e: Element, t: number): Element;
12
+ /** The path span placing the element at `t`, unless an x or y key after it has taken the element back. */
13
+ export declare function followSpan(track: Track, t: number): Follow | null;
14
+ /** The clean route of a connector, or the clean, rotated outline of any other element. */
15
+ export declare function tracing(e: Element, page: Page): Polyline;
16
+ /** `e` moved onto the path it is following at `t`, if any. `page` has every key applied. */
17
+ export declare function following(track: Track, e: Element, t: number, page: Page): Element;
18
+ /** The page as a still drawing at `t` seconds (DottieDocument.resolved(at:)). A page without a timeline is returned as is. */
19
+ export declare function resolved(page: Page, t: number): Page;
20
+ /** The moment a still picture of the page shows: its poster, else the end. */
21
+ export declare function posterTime(page: Page): number;
22
+ /** The page as a still picture (its poster frame when animated). */
23
+ export declare function still(page: Page): Page;
24
+ export declare function cameraRect(tl: Timeline, t: number): Rect | null;
25
+ /** What exports show at `t`: the camera's view widened (never cropped) to the first key's shape. */
26
+ export declare function cameraView(tl: Timeline, t: number): Rect | null;
27
+ /** `r` widened about its center to the width-to-height ratio `aspect`. */
28
+ export declare function fit(r: Rect, aspect: number): Rect;
29
+ export declare function frameCount(tl: Timeline): number;
30
+ /** The times exports and playback draw: every frame, plus the end when it falls between frames. */
31
+ export declare function frameTimes(tl: Timeline): number[];
32
+ /** The index of the last scene marker at or before `t`, or -1. */
33
+ export declare function sceneAt(tl: Timeline, t: number): number;
34
+ /** Elements that only exist in motion: hidden at the start and in the still (packets, mostly). */
35
+ export declare function transientElements(page: Page): Set<string>;
36
+ export type { Point };