@algorisys/tinyfly 0.74.1 → 0.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/lib/addons/adapters.js +236 -121
- package/lib/addons/characters.js +316 -144
- package/lib/addons/{dom-adapter-ChrbtkLC.js → dom-adapter-CrNwoomd.js} +52 -52
- package/lib/addons/gsap-compat.js +1 -1
- package/lib/addons/sketch-CB6VNfnR.js +128 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3110 -2819
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +2 -0
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +70 -70
- package/lib/headless/headless.js +300 -1
- package/lib/player/tinyfly-player.es.js +73 -73
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +18 -0
- package/lib/types/adapters/canvas/index.d.ts +3 -0
- package/lib/types/adapters/canvas/outline.d.ts +26 -0
- package/lib/types/adapters/canvas/polyline.d.ts +12 -0
- package/lib/types/adapters/canvas/sketch.d.ts +54 -0
- package/lib/types/characters/erase.d.ts +31 -0
- package/lib/types/characters/hand.d.ts +81 -0
- package/lib/types/characters/index.d.ts +7 -1
- package/lib/types/characters/polyline.d.ts +12 -0
- package/lib/types/characters/sketch.d.ts +54 -0
- package/lib/types/characters/stick-figure.d.ts +29 -4
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AnimationState, AnimatableValue } from '../../engine/types';
|
|
2
|
+
import { type SketchStyle } from './sketch';
|
|
2
3
|
/** Gradient stop definition */
|
|
3
4
|
export interface GradientStop {
|
|
4
5
|
offset: number;
|
|
@@ -60,6 +61,16 @@ export interface CanvasTargetBase {
|
|
|
60
61
|
shadowBlur?: number;
|
|
61
62
|
shadowColor?: string;
|
|
62
63
|
shine?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Draw the outline in hand-drawn pencil strokes that boil (rect, circle, line
|
|
66
|
+
* and path targets). The fill stays clean underneath.
|
|
67
|
+
*/
|
|
68
|
+
sketch?: SketchStyle;
|
|
69
|
+
/**
|
|
70
|
+
* How much of the outline is drawn, 0..1 (default 1), for drawing a shape on
|
|
71
|
+
* (rect, circle, line and path targets). The fill appears once it is complete.
|
|
72
|
+
*/
|
|
73
|
+
drawOn?: number;
|
|
63
74
|
}
|
|
64
75
|
/** Rectangle target */
|
|
65
76
|
export interface RectTarget extends CanvasTargetBase {
|
|
@@ -205,6 +216,13 @@ export declare class CanvasAdapter {
|
|
|
205
216
|
* Get target bounding box for gradient calculations.
|
|
206
217
|
*/
|
|
207
218
|
private getTargetBounds;
|
|
219
|
+
/** Whether a shape is drawn stroke by stroke: sketched, or only partly drawn on. */
|
|
220
|
+
private drawsOutline;
|
|
221
|
+
/**
|
|
222
|
+
* Draw a shape outline-first: the fill (clean) once the outline is complete,
|
|
223
|
+
* then the outline up to `drawOn`, in pencil strokes when sketched.
|
|
224
|
+
*/
|
|
225
|
+
private renderOutlined;
|
|
208
226
|
/**
|
|
209
227
|
* Render a rectangle.
|
|
210
228
|
*/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Point, SketchPen } from './sketch';
|
|
2
|
+
/**
|
|
3
|
+
* Shape outlines as strokes a pencil can draw: runs of straight segments, and
|
|
4
|
+
* curves sampled into points. The canvas adapter draws a shape this way when
|
|
5
|
+
* it is sketched or only partly drawn on (`drawOn` below 1).
|
|
6
|
+
*/
|
|
7
|
+
export interface OutlineStroke {
|
|
8
|
+
/** `line`: straight segments between the points; `curve`: a smooth curve through them */
|
|
9
|
+
kind: 'line' | 'curve';
|
|
10
|
+
points: Point[];
|
|
11
|
+
/** Length along the shape, for sharing out `drawOn` */
|
|
12
|
+
length: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The outline of SVG path data: each run of straight segments is one stroke
|
|
16
|
+
* (so a polygon is drawn in one go), each curved segment another.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pathOutline(pathData: string): OutlineStroke[];
|
|
19
|
+
/** The outline of a rectangle, with rounded corners when `radius` is above 0. */
|
|
20
|
+
export declare function rectOutline(x: number, y: number, width: number, height: number, radius?: number): OutlineStroke[];
|
|
21
|
+
/**
|
|
22
|
+
* Stroke an outline up to `progress` (0..1) of its total length, in order:
|
|
23
|
+
* sketched with a pen, or clean. Every stroke is handed to the pen even when
|
|
24
|
+
* none of it is drawn yet, so each keeps its own wobble as the outline grows.
|
|
25
|
+
*/
|
|
26
|
+
export declare function drawOutline(ctx: CanvasRenderingContext2D, strokes: OutlineStroke[], progress: number, pen?: SketchPen): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Point } from './sketch';
|
|
2
|
+
/**
|
|
3
|
+
* Polyline helpers measured by length, so `progress` 0..1 means "this much of
|
|
4
|
+
* the way along", whatever the spacing of the points. Drawing on, erasing and
|
|
5
|
+
* the hand that follows a stroke all use them.
|
|
6
|
+
*/
|
|
7
|
+
/** Total length of a polyline. */
|
|
8
|
+
export declare function pathLength(points: Point[]): number;
|
|
9
|
+
/** The start of a polyline, up to `progress` (0..1) of its length. */
|
|
10
|
+
export declare function partialPath(points: Point[], progress: number): Point[];
|
|
11
|
+
/** Where along a polyline `progress` (0..1) of its length is. */
|
|
12
|
+
export declare function pointAlong(points: Point[], progress: number): Point;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-drawn strokes for canvas drawing: each line is drawn a few times, a
|
|
3
|
+
* little off and a little bowed, the way a pencil line is. "Line boil" redraws
|
|
4
|
+
* the wobble a few times a second, so a still drawing looks alive.
|
|
5
|
+
*
|
|
6
|
+
* The wobble comes from a seeded generator keyed to the seed, the boil frame
|
|
7
|
+
* and the stroke's place in the drawing order, never from Math.random, so the
|
|
8
|
+
* same time always draws the same lines: a frame rendered twice, in a browser
|
|
9
|
+
* or headless, is identical.
|
|
10
|
+
*
|
|
11
|
+
* Every stroke takes a `progress` (0..1) to draw it on, as a pencil would: the
|
|
12
|
+
* part drawn so far lies exactly on the finished stroke, so it grows without
|
|
13
|
+
* jumping.
|
|
14
|
+
*/
|
|
15
|
+
export interface SketchStyle {
|
|
16
|
+
/** Largest wobble, px (default 2) */
|
|
17
|
+
roughness?: number;
|
|
18
|
+
/** Strokes per line: 1 is clean, 2 or 3 look sketched (default 2) */
|
|
19
|
+
passes?: number;
|
|
20
|
+
/** Redraws per second; 0 holds the wobble still (default 8, about "on threes" at 24 fps) */
|
|
21
|
+
boil?: number;
|
|
22
|
+
/** Seed for the wobble, so two drawings with the same style do not boil in step (default 1) */
|
|
23
|
+
seed?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface Point {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}
|
|
29
|
+
/** Which redraw is showing at `time` ms. */
|
|
30
|
+
export declare function boilFrame(time: number, boil: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Strokes in the context's current stroke style and line width. Each stroke's
|
|
33
|
+
* wobble is seeded by its place in the drawing order, so draw them in the same
|
|
34
|
+
* order every frame; a stroke drawn on partway wobbles exactly as it will when
|
|
35
|
+
* it is finished, and does not disturb the strokes after it.
|
|
36
|
+
*/
|
|
37
|
+
export interface SketchPen {
|
|
38
|
+
/** A line through the points, each segment slightly bowed; `progress` draws it on (default 1) */
|
|
39
|
+
line(points: Point[], progress?: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* A smooth curve through the points (a limb drawn as a curve). The wobble
|
|
42
|
+
* is spread along the whole curve rather than added at every point, so a
|
|
43
|
+
* finely sampled curve stays smooth instead of turning lumpy.
|
|
44
|
+
*/
|
|
45
|
+
curve(points: Point[], progress?: number): void;
|
|
46
|
+
/** A circle whose end overshoots its start, as a quick pencil circle does */
|
|
47
|
+
circle(cx: number, cy: number, r: number, progress?: number): void;
|
|
48
|
+
/** An ellipse drawn the same way as `circle` */
|
|
49
|
+
ellipse(cx: number, cy: number, rx: number, ry: number, progress?: number): void;
|
|
50
|
+
/** A small random offset, up to `scale` × roughness, for nudging details (a face) with the boil */
|
|
51
|
+
nudge(scale?: number): Point;
|
|
52
|
+
}
|
|
53
|
+
/** A pen whose wobble is fixed for the boil frame showing at `time` ms. */
|
|
54
|
+
export declare function sketchPen(ctx: CanvasRenderingContext2D, style: SketchStyle, time: number): SketchPen;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CustomTarget } from '../adapters/canvas';
|
|
2
|
+
import type { Point } from '../adapters/canvas/sketch';
|
|
3
|
+
import { type EraserStyle, type HandStyle } from './hand';
|
|
4
|
+
/**
|
|
5
|
+
* A back-and-forth scrub that covers a box, the way an eraser rubs out an area:
|
|
6
|
+
* `strokes` passes from side to side, stepping down the box.
|
|
7
|
+
*/
|
|
8
|
+
export declare function scrubPath(x: number, y: number, width: number, height: number, strokes?: number): Point[];
|
|
9
|
+
/**
|
|
10
|
+
* Clip the context so that drawing misses the swath an eraser `width` wide
|
|
11
|
+
* leaves along `path` up to `progress`. Wrap in save()/restore() to end it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function clipErased(ctx: CanvasRenderingContext2D, path: Point[], width: number, progress: number): void;
|
|
14
|
+
/** Run `draw` with the swath erased from it, for immediate-mode drawing. */
|
|
15
|
+
export declare function withErased(ctx: CanvasRenderingContext2D, path: Point[], width: number, progress: number, draw: () => void): void;
|
|
16
|
+
export interface ErasableOptions {
|
|
17
|
+
/** The eraser's path, in the target's own box (0, 0 is its top-left corner) */
|
|
18
|
+
path: Point[];
|
|
19
|
+
/** Eraser width, px (default 40) */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** Draw the eraser while it is rubbing (default true); a style changes its look */
|
|
22
|
+
eraser?: boolean | EraserStyle;
|
|
23
|
+
/** Draw a hand holding the eraser, reaching in from off screen (default false) */
|
|
24
|
+
hand?: boolean | HandStyle;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `target`, erasable: it gains an `erase` prop (0..1, how far along `path` the
|
|
28
|
+
* eraser has rubbed), and what the eraser has covered stays erased. The path
|
|
29
|
+
* is in the target's own box, so the erased part moves with the target.
|
|
30
|
+
*/
|
|
31
|
+
export declare function erasable(target: CustomTarget, options: ErasableOptions): CustomTarget;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { CustomTarget } from '../adapters/canvas';
|
|
2
|
+
import { type Point, type SketchPen, type SketchStyle } from '../adapters/canvas/sketch';
|
|
3
|
+
/**
|
|
4
|
+
* The animator's hand: a cartoon hand holding a pencil or an eraser, reaching
|
|
5
|
+
* in from off screen, with the tool's tip at a point. Put the point on the end
|
|
6
|
+
* of a stroke being drawn on (or erased) and the hand draws it.
|
|
7
|
+
*
|
|
8
|
+
* Shapes are drawn in the tool's frame: the tip at (0, 0) and the tool lying
|
|
9
|
+
* along +x, rotated by `angle`. Everything is plain Canvas 2D.
|
|
10
|
+
*/
|
|
11
|
+
export interface PencilStyle {
|
|
12
|
+
/** Lean, degrees (default -30: the pencil up and to the right of its tip) */
|
|
13
|
+
angle?: number;
|
|
14
|
+
/** Pencil length, px (default 240) */
|
|
15
|
+
length?: number;
|
|
16
|
+
/** Body colour (default yellow) */
|
|
17
|
+
color?: string;
|
|
18
|
+
/** Outline colour (default graphite) */
|
|
19
|
+
outline?: string;
|
|
20
|
+
}
|
|
21
|
+
/** A pencil with its tip at `at`. Pass a pen to outline it in sketched strokes. */
|
|
22
|
+
export declare function drawPencil(ctx: CanvasRenderingContext2D, at: Point, style?: PencilStyle, pen?: SketchPen): void;
|
|
23
|
+
export interface EraserStyle {
|
|
24
|
+
/** Eraser length along its body, px (default 90) */
|
|
25
|
+
length?: number;
|
|
26
|
+
/** Eraser thickness, px (default 34) */
|
|
27
|
+
thickness?: number;
|
|
28
|
+
/** Lean, degrees (default -35: the body up and to the right of the tip) */
|
|
29
|
+
angle?: number;
|
|
30
|
+
/** Rubber colour (default pink) */
|
|
31
|
+
color?: string;
|
|
32
|
+
/** Outline colour (default graphite) */
|
|
33
|
+
outline?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A rubber eraser whose rubbing end is at `at`. Pass a pen to outline it in
|
|
37
|
+
* sketched strokes; without one the outline is clean.
|
|
38
|
+
*/
|
|
39
|
+
export declare function drawEraser(ctx: CanvasRenderingContext2D, at: Point, style?: EraserStyle, pen?: SketchPen): void;
|
|
40
|
+
export interface HandStyle {
|
|
41
|
+
/** What the hand holds (default pencil) */
|
|
42
|
+
tool?: 'pencil' | 'eraser';
|
|
43
|
+
/** Lean of the tool, degrees (default -30) */
|
|
44
|
+
angle?: number;
|
|
45
|
+
/** Size, 1 is a pencil 240 px long (default 1) */
|
|
46
|
+
scale?: number;
|
|
47
|
+
/** Skin colour */
|
|
48
|
+
skin?: string;
|
|
49
|
+
/** Sleeve colour */
|
|
50
|
+
sleeve?: string;
|
|
51
|
+
/** Outline colour (default graphite) */
|
|
52
|
+
outline?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A hand holding a pencil or an eraser with the tool's tip at `at`, its arm
|
|
56
|
+
* reaching in from off screen. Pass a pen to sketch it: the tools are outlined
|
|
57
|
+
* in pencil strokes and the hand shifts with the boil.
|
|
58
|
+
*/
|
|
59
|
+
export declare function drawHand(ctx: CanvasRenderingContext2D, at: Point, style?: HandStyle, pen?: SketchPen): void;
|
|
60
|
+
/** A circle as points, starting at the top and running a little past a full turn, to draw on. */
|
|
61
|
+
export declare function circlePath(cx: number, cy: number, r: number, overshoot?: number, segments?: number): Point[];
|
|
62
|
+
export interface DrawnPathOptions {
|
|
63
|
+
/** The stroke, in scene coordinates */
|
|
64
|
+
path: Point[];
|
|
65
|
+
/** A smooth curve through the points (true) or straight segments between them (default false) */
|
|
66
|
+
smooth?: boolean;
|
|
67
|
+
/** Line colour (default graphite) */
|
|
68
|
+
color?: string;
|
|
69
|
+
/** Line width (default 5) */
|
|
70
|
+
lineWidth?: number;
|
|
71
|
+
/** Draw in sketched pencil strokes; omit for clean lines */
|
|
72
|
+
sketch?: SketchStyle;
|
|
73
|
+
/** Show the hand drawing it (default true); a style changes it */
|
|
74
|
+
hand?: boolean | HandStyle;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A `custom` canvas target that draws a stroke on. Its `draw` prop (0..1) is
|
|
78
|
+
* how much of the path is drawn, so drawing on is a timeline track; while it is
|
|
79
|
+
* between 0 and 1, a hand holds the pencil at the end of the line.
|
|
80
|
+
*/
|
|
81
|
+
export declare function drawnPathTarget(options: DrawnPathOptions): CustomTarget;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@algorisys/tinyfly/characters`: drawable, poseable characters for canvas
|
|
3
|
-
* scenes (browser or headless video).
|
|
3
|
+
* scenes (browser or headless video). The pencil pen and path helpers live
|
|
4
|
+
* with the canvas adapter (its shapes can be sketched too) and are re-exported
|
|
5
|
+
* here.
|
|
4
6
|
*/
|
|
5
7
|
export * from './stick-figure';
|
|
8
|
+
export * from '../adapters/canvas/sketch';
|
|
9
|
+
export * from './erase';
|
|
10
|
+
export * from '../adapters/canvas/polyline';
|
|
11
|
+
export * from './hand';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Point } from './sketch';
|
|
2
|
+
/**
|
|
3
|
+
* Polyline helpers measured by length, so `progress` 0..1 means "this much of
|
|
4
|
+
* the way along", whatever the spacing of the points. Drawing on, erasing and
|
|
5
|
+
* the hand that follows a stroke all use them.
|
|
6
|
+
*/
|
|
7
|
+
/** Total length of a polyline. */
|
|
8
|
+
export declare function pathLength(points: Point[]): number;
|
|
9
|
+
/** The start of a polyline, up to `progress` (0..1) of its length. */
|
|
10
|
+
export declare function partialPath(points: Point[], progress: number): Point[];
|
|
11
|
+
/** Where along a polyline `progress` (0..1) of its length is. */
|
|
12
|
+
export declare function pointAlong(points: Point[], progress: number): Point;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-drawn strokes for canvas drawing: each line is drawn a few times, a
|
|
3
|
+
* little off and a little bowed, the way a pencil line is. "Line boil" redraws
|
|
4
|
+
* the wobble a few times a second, so a still drawing looks alive.
|
|
5
|
+
*
|
|
6
|
+
* The wobble comes from a seeded generator keyed to the seed, the boil frame
|
|
7
|
+
* and the stroke's place in the drawing order, never from Math.random, so the
|
|
8
|
+
* same time always draws the same lines: a frame rendered twice, in a browser
|
|
9
|
+
* or headless, is identical.
|
|
10
|
+
*
|
|
11
|
+
* Every stroke takes a `progress` (0..1) to draw it on, as a pencil would: the
|
|
12
|
+
* part drawn so far lies exactly on the finished stroke, so it grows without
|
|
13
|
+
* jumping.
|
|
14
|
+
*/
|
|
15
|
+
export interface SketchStyle {
|
|
16
|
+
/** Largest wobble, px (default 2) */
|
|
17
|
+
roughness?: number;
|
|
18
|
+
/** Strokes per line: 1 is clean, 2 or 3 look sketched (default 2) */
|
|
19
|
+
passes?: number;
|
|
20
|
+
/** Redraws per second; 0 holds the wobble still (default 8, about "on threes" at 24 fps) */
|
|
21
|
+
boil?: number;
|
|
22
|
+
/** Seed for the wobble, so two drawings with the same style do not boil in step (default 1) */
|
|
23
|
+
seed?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface Point {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}
|
|
29
|
+
/** Which redraw is showing at `time` ms. */
|
|
30
|
+
export declare function boilFrame(time: number, boil: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Strokes in the context's current stroke style and line width. Each stroke's
|
|
33
|
+
* wobble is seeded by its place in the drawing order, so draw them in the same
|
|
34
|
+
* order every frame; a stroke drawn on partway wobbles exactly as it will when
|
|
35
|
+
* it is finished, and does not disturb the strokes after it.
|
|
36
|
+
*/
|
|
37
|
+
export interface SketchPen {
|
|
38
|
+
/** A line through the points, each segment slightly bowed; `progress` draws it on (default 1) */
|
|
39
|
+
line(points: Point[], progress?: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* A smooth curve through the points (a limb drawn as a curve). The wobble
|
|
42
|
+
* is spread along the whole curve rather than added at every point, so a
|
|
43
|
+
* finely sampled curve stays smooth instead of turning lumpy.
|
|
44
|
+
*/
|
|
45
|
+
curve(points: Point[], progress?: number): void;
|
|
46
|
+
/** A circle whose end overshoots its start, as a quick pencil circle does */
|
|
47
|
+
circle(cx: number, cy: number, r: number, progress?: number): void;
|
|
48
|
+
/** An ellipse drawn the same way as `circle` */
|
|
49
|
+
ellipse(cx: number, cy: number, rx: number, ry: number, progress?: number): void;
|
|
50
|
+
/** A small random offset, up to `scale` × roughness, for nudging details (a face) with the boil */
|
|
51
|
+
nudge(scale?: number): Point;
|
|
52
|
+
}
|
|
53
|
+
/** A pen whose wobble is fixed for the boil frame showing at `time` ms. */
|
|
54
|
+
export declare function sketchPen(ctx: CanvasRenderingContext2D, style: SketchStyle, time: number): SketchPen;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CustomTarget } from '../adapters/canvas';
|
|
2
2
|
import type { EasingType, Track } from '../engine/types';
|
|
3
|
+
import { type Point, type SketchStyle } from '../adapters/canvas/sketch';
|
|
3
4
|
/**
|
|
4
5
|
* A stick-figure rig: a pose is a handful of numbers, so poses blend, walk
|
|
5
6
|
* cycles are functions of a phase, and every joint can be a timeline track.
|
|
@@ -46,6 +47,12 @@ export interface StickPose {
|
|
|
46
47
|
/** Where the eyes look: -1..1 across (+ is the way the figure faces) and down (+) */
|
|
47
48
|
lookX: number;
|
|
48
49
|
lookY: number;
|
|
50
|
+
/**
|
|
51
|
+
* Squash and stretch: 1 normal, above 1 taller (a jump), below 1 squashed (a landing).
|
|
52
|
+
* The body and legs scale by it, the arms by its square root, and the head
|
|
53
|
+
* becomes an ellipse of the same area.
|
|
54
|
+
*/
|
|
55
|
+
stretch: number;
|
|
49
56
|
}
|
|
50
57
|
export declare const REST_POSE: StickPose;
|
|
51
58
|
/** A full pose from the fields that differ from rest. */
|
|
@@ -90,6 +97,8 @@ export declare const POSES: {
|
|
|
90
97
|
handsOnHips: StickPose;
|
|
91
98
|
sad: StickPose;
|
|
92
99
|
surprised: StickPose;
|
|
100
|
+
crouch: StickPose;
|
|
101
|
+
jump: StickPose;
|
|
93
102
|
};
|
|
94
103
|
export type PoseName = keyof typeof POSES;
|
|
95
104
|
/** Linear blend: `t` 0 is `from`, 1 is `to`. */
|
|
@@ -129,9 +138,22 @@ export interface StickStyle {
|
|
|
129
138
|
label?: string;
|
|
130
139
|
/** Name tag font (default bold, 11% of the height, sans-serif) */
|
|
131
140
|
labelFont?: string;
|
|
141
|
+
/** Draw in hand-drawn pencil strokes that boil (see `sketchPen`); omit for clean lines */
|
|
142
|
+
sketch?: SketchStyle;
|
|
143
|
+
/** Limbs: 0 straight segments jointed at elbows and knees (default), 1 smooth rubber-hose curves */
|
|
144
|
+
rubber?: number;
|
|
132
145
|
}
|
|
133
|
-
/**
|
|
134
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Points along a limb, blending the jointed shape (two straight segments) into
|
|
148
|
+
* a rubber-hose curve by `rubber` 0..1. The curve is the quadratic that passes
|
|
149
|
+
* through the joint halfway along, so a bent limb keeps its bend, rounded.
|
|
150
|
+
*/
|
|
151
|
+
export declare function rubberLimb(root: Point, joint: Point, end: Point, rubber: number, samples?: number): Point[];
|
|
152
|
+
/**
|
|
153
|
+
* Draw a figure with its feet at (0, 0). `time` (ms) only matters for a
|
|
154
|
+
* sketched style: it picks which boil frame of the wobble shows.
|
|
155
|
+
*/
|
|
156
|
+
export declare function drawStickFigure(ctx: CanvasRenderingContext2D, figure: StickPose, style?: StickStyle, time?: number): void;
|
|
135
157
|
/** Values a stick-figure target's tracks can animate, besides x/y/opacity/…. */
|
|
136
158
|
export interface StickFigureProps extends StickPose {
|
|
137
159
|
/** Walk cycle phase, in strides (animate it 0 → n for n strides) */
|
|
@@ -140,6 +162,8 @@ export interface StickFigureProps extends StickPose {
|
|
|
140
162
|
walking: number;
|
|
141
163
|
/** How much the mouth chatters, 0..1 */
|
|
142
164
|
talk: number;
|
|
165
|
+
/** Limbs from jointed (0) to rubber hose (1); starts at the style's `rubber` */
|
|
166
|
+
rubber: number;
|
|
143
167
|
}
|
|
144
168
|
export interface StickFigureTargetOptions {
|
|
145
169
|
/** Where the feet stand */
|
|
@@ -151,8 +175,9 @@ export interface StickFigureTargetOptions {
|
|
|
151
175
|
}
|
|
152
176
|
/**
|
|
153
177
|
* A `custom` canvas target that draws a stick figure. Its props are the pose
|
|
154
|
-
* plus `walk`, `walking` and `
|
|
155
|
-
* it. `x`/`y` here are the feet; the target's own box sits
|
|
178
|
+
* plus `walk`, `walking`, `talk` and `rubber`, so the timeline can pose, walk,
|
|
179
|
+
* voice and loosen it. `x`/`y` here are the feet; the target's own box sits
|
|
180
|
+
* above them (a stretched figure reaches above its box).
|
|
156
181
|
*/
|
|
157
182
|
export declare function stickFigureTarget(options: StickFigureTargetOptions): CustomTarget;
|
|
158
183
|
export interface PoseKey {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algorisys/tinyfly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Lightweight, API-driven animation engine and editor. The engine is framework-agnostic and runs in browsers, Web Workers, and Node.",
|
|
6
6
|
"license": "MIT",
|