@algorisys/tinyfly 0.121.0 → 0.123.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 +22 -4
- package/docs/character-appearance.md +87 -1
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +12 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +17 -0
- package/docs/maps.md +2 -2
- package/docs/math.md +1 -1
- package/docs/noir-detective.md +137 -0
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +4250 -3747
- package/lib/addons/cricket-play-BVKhsPUD.js +5571 -0
- package/lib/addons/sports.js +1 -1
- package/lib/browser/tinyfly.iife.js +15 -13
- package/lib/browser/tinyfly.js +8603 -7764
- package/lib/browser/tinyfly.umd.js +15 -13
- package/lib/types/characters/body/bean-figure.d.ts +189 -0
- package/lib/types/characters/capabilities.d.ts +11 -0
- package/lib/types/characters/cast.d.ts +246 -2
- package/lib/types/characters/character.d.ts +21 -5
- package/lib/types/characters/head/face.d.ts +22 -2
- package/lib/types/characters/index.d.ts +3 -1
- package/lib/types/characters/noir/atmosphere.d.ts +124 -0
- package/lib/types/characters/noir/case-board.d.ts +137 -0
- package/lib/types/characters/noir/index.d.ts +12 -0
- package/lib/types/characters/noir/noir-kit.d.ts +38 -0
- package/lib/types/characters/noir/noir-utils.d.ts +31 -0
- package/lib/types/characters/noir/overlays.d.ts +178 -0
- package/llms-full.txt +299 -13
- package/llms.txt +32 -31
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +12 -0
- package/lib/addons/cricket-play-C5CkNOc6.js +0 -5219
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noir atmosphere for canvas scenes: rain in a window, light through
|
|
3
|
+
* venetian blinds, a dark room with torch beams and holes of light, soft
|
|
4
|
+
* pools of light, a vignette, lightning and a failing bulb.
|
|
5
|
+
*
|
|
6
|
+
* Everything is a pure function of its options and the time (ms): rain drops
|
|
7
|
+
* come from a seeded generator, never `Math.random`, so any frame draws the
|
|
8
|
+
* same whether it is rendered in order, out of order, or scrubbed to.
|
|
9
|
+
*/
|
|
10
|
+
export interface NoirBox {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RainOptions extends NoirBox {
|
|
17
|
+
/** How many streaks (default 70) */
|
|
18
|
+
drops?: number;
|
|
19
|
+
/** Streak opacity (default 0.35) */
|
|
20
|
+
opacity?: number;
|
|
21
|
+
/** Streak colour (default a cold blue-white) */
|
|
22
|
+
color?: string;
|
|
23
|
+
/** Fall speed of the slowest drop, px per second (default 900; the fastest are 60% quicker) */
|
|
24
|
+
speed?: number;
|
|
25
|
+
/** Streak length, px (default 34) */
|
|
26
|
+
length?: number;
|
|
27
|
+
/** Sideways drift over one streak, px; negative slants left (default -8) */
|
|
28
|
+
slant?: number;
|
|
29
|
+
/** Stroke width, px (default 2) */
|
|
30
|
+
lineWidth?: number;
|
|
31
|
+
/** Seed for where the drops fall (default 1) */
|
|
32
|
+
seed?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Rain streaks falling inside a box (a window, the whole frame), clipped to it. */
|
|
35
|
+
export declare function drawRain(ctx: CanvasRenderingContext2D, time: number, options: RainOptions): void;
|
|
36
|
+
export interface BlindsOptions extends NoirBox {
|
|
37
|
+
/** Band opacity (default 0.12) */
|
|
38
|
+
opacity?: number;
|
|
39
|
+
/** Rise of each band per px across (default 0.35: falling to the right) */
|
|
40
|
+
slope?: number;
|
|
41
|
+
/** Distance between bands, px (default 52) */
|
|
42
|
+
spacing?: number;
|
|
43
|
+
/** Band thickness, px (default 24) */
|
|
44
|
+
band?: number;
|
|
45
|
+
/** Light colour (default a warm white) */
|
|
46
|
+
color?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Key light through venetian blinds: parallel slanted bright bands across a box. */
|
|
49
|
+
export declare function drawBlinds(ctx: CanvasRenderingContext2D, options: BlindsOptions): void;
|
|
50
|
+
/** A torch beam: from (x, y) toward `angle` (degrees: 0 right, 90 down), `length` long, `width` half-wide at its end. */
|
|
51
|
+
export interface LightCone {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
angle: number;
|
|
55
|
+
length: number;
|
|
56
|
+
width: number;
|
|
57
|
+
}
|
|
58
|
+
/** A round hole of light (a lamp, a lit window). */
|
|
59
|
+
export interface LightHole {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
radius: number;
|
|
63
|
+
}
|
|
64
|
+
export interface DarknessOptions {
|
|
65
|
+
/** How dark, 0 (none) … 1 (full) */
|
|
66
|
+
amount: number;
|
|
67
|
+
/** Torch beams cut out of the dark */
|
|
68
|
+
cones?: LightCone[];
|
|
69
|
+
/** Round holes cut out of the dark */
|
|
70
|
+
holes?: LightHole[];
|
|
71
|
+
/** The area to darken (default a very large box: the whole canvas at any camera) */
|
|
72
|
+
bounds?: NoirBox;
|
|
73
|
+
/** The dark's colour (default near-black blue) */
|
|
74
|
+
color?: string;
|
|
75
|
+
/** Opacity of the dark at `amount` 1 (default 0.9) */
|
|
76
|
+
opacity?: number;
|
|
77
|
+
/** A faint tint inside each beam (default a warm white at 0.08; `null` for none) */
|
|
78
|
+
beam?: string | null;
|
|
79
|
+
beamOpacity?: number;
|
|
80
|
+
}
|
|
81
|
+
/** The three corners of a cone (apex first), in scene px. */
|
|
82
|
+
export declare function coneCorners(cone: LightCone): Array<{
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
}>;
|
|
86
|
+
/** A dark overlay with torch beams and round holes of light cut out of it. */
|
|
87
|
+
export declare function drawDarkness(ctx: CanvasRenderingContext2D, options: DarknessOptions): void;
|
|
88
|
+
export interface GlowOptions {
|
|
89
|
+
x: number;
|
|
90
|
+
y: number;
|
|
91
|
+
radius: number;
|
|
92
|
+
/** Light colour (default amber) */
|
|
93
|
+
color?: string;
|
|
94
|
+
/** Opacity at the centre (default 0.5), falling to 0 at the radius */
|
|
95
|
+
opacity?: number;
|
|
96
|
+
}
|
|
97
|
+
/** A soft pool of light: a radial gradient from `color` to clear. */
|
|
98
|
+
export declare function drawGlow(ctx: CanvasRenderingContext2D, options: GlowOptions): void;
|
|
99
|
+
export interface VignetteOptions {
|
|
100
|
+
width: number;
|
|
101
|
+
height: number;
|
|
102
|
+
x?: number;
|
|
103
|
+
y?: number;
|
|
104
|
+
/** Where the darkening starts, as a fraction of the half-diagonal (default 0.38) */
|
|
105
|
+
inner?: number;
|
|
106
|
+
/** Where it is full, as a fraction of the half-diagonal (default 1.05) */
|
|
107
|
+
outer?: number;
|
|
108
|
+
/** Darkness at the corners (default 0.55) */
|
|
109
|
+
opacity?: number;
|
|
110
|
+
color?: string;
|
|
111
|
+
}
|
|
112
|
+
/** A vignette: the frame's edges fall into dark. */
|
|
113
|
+
export declare function drawVignette(ctx: CanvasRenderingContext2D, options: VignetteOptions): void;
|
|
114
|
+
/**
|
|
115
|
+
* Lightning: how bright a flash is at `time` (0..1), from strikes at the
|
|
116
|
+
* given times (ms); each flares instantly and fades over `decay` ms either side.
|
|
117
|
+
* Fill the frame with a pale blue at about 0.25 × this.
|
|
118
|
+
*/
|
|
119
|
+
export declare function lightningFlash(time: number, strikes: number[], decay?: number): number;
|
|
120
|
+
/**
|
|
121
|
+
* A failing bulb: how much darker the room is at `time` (0 or `strength`),
|
|
122
|
+
* flickering in an irregular but repeatable rhythm.
|
|
123
|
+
*/
|
|
124
|
+
export declare function lightFlicker(time: number, strength?: number): number;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Point } from '../../adapters/canvas/sketch';
|
|
2
|
+
/**
|
|
3
|
+
* A detective's case board as plain data: a cork board with pinned cards
|
|
4
|
+
* (photos of suspects, notes about clues), red string between them, and the
|
|
5
|
+
* marker's work over them (a cross-out, a single strike, a scribble-out, a
|
|
6
|
+
* ring round a card), each drawn on over time.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const board = caseBoard({
|
|
10
|
+
* x: 60, y: 110, width: 1800, height: 900,
|
|
11
|
+
* cards: [
|
|
12
|
+
* { id: 'victim', x: 900, y: 240, title: 'The victim', note: 'Lift 2 · 9:40' },
|
|
13
|
+
* { id: 'aunt', x: 270, y: 190, title: 'The aunt', note: 'a grudge', at: 400 },
|
|
14
|
+
* { id: 'wire', x: 600, y: 200, kind: 'note', title: 'alarm wire: cut', at: 1200 },
|
|
15
|
+
* ],
|
|
16
|
+
* strings: [{ from: 'victim', to: 'aunt', at: 900 }, { from: 'victim', to: 'wire', at: 1500 }],
|
|
17
|
+
* marks: [{ on: 'aunt', kind: 'cross', at: 4000, duration: 1400 }],
|
|
18
|
+
* })
|
|
19
|
+
* drawCaseBoard(ctx, board, time, { drawCard: (ctx, card, area) => …draw a portrait in area… })
|
|
20
|
+
* const tip = caseBoardMarkerTip(board, time) // where the marker's nib is, for a hand
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Card positions are relative to the board's top-left; `x`, `y` is where a
|
|
24
|
+
* card is pinned (its top centre). Times are ms. Text is the caller's.
|
|
25
|
+
*/
|
|
26
|
+
export type CaseCardKind = 'photo' | 'note';
|
|
27
|
+
export type CaseMarkKind = 'cross' | 'strike' | 'scribble' | 'circle';
|
|
28
|
+
export declare const CASE_CARD_KINDS: readonly CaseCardKind[];
|
|
29
|
+
export declare const CASE_MARK_KINDS: Record<CaseMarkKind, string>;
|
|
30
|
+
export interface CaseCard {
|
|
31
|
+
id: string;
|
|
32
|
+
/** Where it is pinned (its top centre), relative to the board */
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
/** `photo` (default): a print with a picture area, a title and a red note; `note`: a coloured slip with handwriting */
|
|
36
|
+
kind?: CaseCardKind;
|
|
37
|
+
title?: string;
|
|
38
|
+
note?: string;
|
|
39
|
+
/** Size, px (default photo 220 × 260, note 220 × 124) */
|
|
40
|
+
width?: number;
|
|
41
|
+
height?: number;
|
|
42
|
+
/** Tilt, degrees (default a small seeded tilt) */
|
|
43
|
+
angle?: number;
|
|
44
|
+
/** Paper colour (default photo cream, note yellow) */
|
|
45
|
+
color?: string;
|
|
46
|
+
/** When it is pinned up (pops on), ms (default 0: already up) */
|
|
47
|
+
at?: number;
|
|
48
|
+
/** A pulsing amber outline from `at` for `duration` ms */
|
|
49
|
+
highlight?: {
|
|
50
|
+
at: number;
|
|
51
|
+
duration: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface CaseString {
|
|
55
|
+
from: string;
|
|
56
|
+
to: string;
|
|
57
|
+
/** When it starts to stretch from `from` to `to`, ms (default 0) and how long that takes (default 600) */
|
|
58
|
+
at?: number;
|
|
59
|
+
duration?: number;
|
|
60
|
+
color?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface CaseMark {
|
|
63
|
+
/** The card it goes over */
|
|
64
|
+
on: string;
|
|
65
|
+
kind: CaseMarkKind;
|
|
66
|
+
/** When the marker starts, ms, and how long the stroke takes (default 1400) */
|
|
67
|
+
at: number;
|
|
68
|
+
duration?: number;
|
|
69
|
+
color?: string;
|
|
70
|
+
/** Stroke width, px (default 16; 18 for a scribble) */
|
|
71
|
+
width?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface CaseBoardOptions {
|
|
74
|
+
/** The board's top-left and size, scene px */
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
cards: CaseCard[];
|
|
80
|
+
strings?: CaseString[];
|
|
81
|
+
marks?: CaseMark[];
|
|
82
|
+
/** Cork colour (default a warm brown) and frame colour */
|
|
83
|
+
cork?: string;
|
|
84
|
+
frame?: string;
|
|
85
|
+
ink?: string;
|
|
86
|
+
/** Font family for titles (default system-ui) and for handwriting on notes (default the same) */
|
|
87
|
+
font?: string;
|
|
88
|
+
handFont?: string;
|
|
89
|
+
/** Seed for the cork's grain and the cards' default tilts (default 1) */
|
|
90
|
+
seed?: number;
|
|
91
|
+
}
|
|
92
|
+
export interface CaseBoard extends Required<Omit<CaseBoardOptions, 'cards' | 'strings' | 'marks'>> {
|
|
93
|
+
cards: Array<Required<Omit<CaseCard, 'title' | 'note' | 'highlight'>> & Pick<CaseCard, 'title' | 'note' | 'highlight'>>;
|
|
94
|
+
strings: Array<Required<CaseString>>;
|
|
95
|
+
marks: Array<Required<CaseMark>>;
|
|
96
|
+
}
|
|
97
|
+
/** A resolved card on a board (every default filled in). */
|
|
98
|
+
export type CaseBoardCard = CaseBoard['cards'][number];
|
|
99
|
+
/** Check and resolve a case board: every default spelled out, every id checked (with a did-you-mean). */
|
|
100
|
+
export declare function caseBoard(options: CaseBoardOptions): CaseBoard;
|
|
101
|
+
/** Where a card is: its pin and its four corners, scene px. */
|
|
102
|
+
export declare function caseCardBox(board: CaseBoard, id: string): {
|
|
103
|
+
pin: Point;
|
|
104
|
+
center: Point;
|
|
105
|
+
corners: Point[];
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
};
|
|
109
|
+
/** A mark's stroke path, scene px (a cross is its two diagonals end to end, drawn in turn). */
|
|
110
|
+
export declare function caseMarkPath(board: CaseBoard, mark: Pick<CaseMark, 'on' | 'kind'>): Point[][];
|
|
111
|
+
/** Where the marker's nib is at `time` (scene px), or null when no mark is being drawn. */
|
|
112
|
+
export declare function caseBoardMarkerTip(board: CaseBoard, time: number): Point | null;
|
|
113
|
+
/** A red push pin with a highlight. */
|
|
114
|
+
export declare function drawPushPin(ctx: CanvasRenderingContext2D, x: number, y: number, options?: {
|
|
115
|
+
color?: string;
|
|
116
|
+
radius?: number;
|
|
117
|
+
ink?: string;
|
|
118
|
+
}): void;
|
|
119
|
+
/** The first `progress` (0..1) of a marker stroke along points; returns the nib's point. */
|
|
120
|
+
export declare function drawMarkerStroke(ctx: CanvasRenderingContext2D, points: Point[], progress: number, options?: {
|
|
121
|
+
color?: string;
|
|
122
|
+
width?: number;
|
|
123
|
+
}): Point | null;
|
|
124
|
+
export interface DrawCaseBoardOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Draws a card's picture (a suspect's portrait, a clue's sketch) inside
|
|
127
|
+
* `area`, in the card's own frame (origin at the pin), clipped to the area.
|
|
128
|
+
*/
|
|
129
|
+
drawCard?: (ctx: CanvasRenderingContext2D, card: CaseBoardCard, area: {
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
}, time: number) => void;
|
|
135
|
+
}
|
|
136
|
+
/** Draw the board as it is at `time`: cork, strings, cards, pins and the marker's work. Returns the marker's nib, if a mark is being drawn. */
|
|
137
|
+
export declare function drawCaseBoard(ctx: CanvasRenderingContext2D, board: CaseBoard, time: number, options?: DrawCaseBoardOptions): Point | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The noir / detective kit: atmosphere (rain, blinds, darkness with torch
|
|
3
|
+
* beams, glow, vignette, lightning, a failing bulb), detective overlays (the
|
|
4
|
+
* clue marker, an evidence folder, a clock and a time chip, a suspect's name
|
|
5
|
+
* card, a narration box, speech bubbles) and a case board (cards, pins, red
|
|
6
|
+
* string, marker cross-outs and scribble-outs). See docs/noir-detective.md.
|
|
7
|
+
*/
|
|
8
|
+
export * from './atmosphere';
|
|
9
|
+
export * from './overlays';
|
|
10
|
+
export * from './case-board';
|
|
11
|
+
export { fadeWindow, withAlpha, wrapText, popIn } from './noir-utils';
|
|
12
|
+
export { NOIR_KIT } from './noir-kit';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The noir / detective kit as data, for the capabilities catalog: every
|
|
3
|
+
* function with its call shape and what it draws.
|
|
4
|
+
*/
|
|
5
|
+
export declare const NOIR_KIT: {
|
|
6
|
+
readonly atmosphere: {
|
|
7
|
+
readonly 'drawRain(ctx, time, { x, y, width, height, drops?, opacity?, color?, speed?, length?, slant?, lineWidth?, seed? })': "rain streaks falling in a box (a window, the frame), clipped to it; seeded, a pure function of time";
|
|
8
|
+
readonly 'drawBlinds(ctx, { x, y, width, height, opacity?, slope?, spacing?, band?, color? })': "key light through venetian blinds: slanted bright bands";
|
|
9
|
+
readonly 'drawDarkness(ctx, { amount, cones?: [{ x, y, angle (deg), length, width }], holes?: [{ x, y, radius }], bounds?, color?, opacity?, beam?, beamOpacity? })': "a dark room with torch beams and round holes of light cut out (coneCorners(cone) gives a beam’s corners)";
|
|
10
|
+
readonly 'drawGlow(ctx, { x, y, radius, color?, opacity? })': "a soft pool of light";
|
|
11
|
+
readonly 'drawVignette(ctx, { width, height, x?, y?, inner?, outer?, opacity?, color? })': "the frame’s edges fall into dark";
|
|
12
|
+
readonly 'lightningFlash(time, strikes, decay?)': "flash brightness 0..1 from strike times (ms)";
|
|
13
|
+
readonly 'lightFlicker(time, strength?)': "a failing bulb: how much darker the room is (0 or strength)";
|
|
14
|
+
};
|
|
15
|
+
readonly overlays: {
|
|
16
|
+
readonly 'drawClueMarker(ctx, time, { x, y, radius?, at, duration?, color?, lineWidth? })': "the red magnifier over a clue: pops on, pulses, fades (clueMarkerAt gives its opacity and scale)";
|
|
17
|
+
readonly 'drawEvidenceFolder(ctx, { x, y, scale?, angle?, color?, ink?, label?, font? })': "a tabbed evidence folder";
|
|
18
|
+
readonly 'drawClockFace(ctx, { x, y, radius?, hours, minutes, face?, ink? })': "a wall clock showing a time (clockHandAngles gives the hands)";
|
|
19
|
+
readonly 'drawTimeChip(ctx, time, { x, y, text, size?, font?, color?, background?, at? })': "a time/place chip in a corner; returns its width";
|
|
20
|
+
readonly 'drawNameCard(ctx, time, { name, role?, at, duration?, anchor, side?, frame?, dim?, color?, font?, tilt? })': "a freeze-frame suspect card: the frame dims, a slanted red band beside the head";
|
|
21
|
+
readonly 'drawNarrationBox(ctx, time, { text, start, end, speaker?, x?, width?, bottom?, size?, font?, typeDuration? })': "a first-person narration box along the bottom, words typed on (lineReveal gives opacity and reveal)";
|
|
22
|
+
readonly 'drawSpeechBubble(ctx, time, { text, start, end, tail, speaker?, maxWidth?, size?, font?, bounds?, maxCenterY?, gap? })': "a comic speech bubble above the speaker, tail to the head, popping on";
|
|
23
|
+
};
|
|
24
|
+
readonly caseBoard: {
|
|
25
|
+
readonly 'caseBoard({ x, y, width, height, cards, strings?, marks?, cork?, frame?, font?, handFont?, seed? })': "checks and resolves a case board (did-you-mean on unknown card ids and kinds)";
|
|
26
|
+
readonly 'drawCaseBoard(ctx, board, time, { drawCard? })': "the board at a time: cork, red strings stretching, cards popping up on pins, marker strokes; returns the nib point while a mark is drawn";
|
|
27
|
+
readonly 'caseBoardMarkerTip(board, time)': "where the marker’s nib is (for a hand), or null";
|
|
28
|
+
readonly 'caseCardBox(board, id)': "a card’s pin, centre and corners, scene px";
|
|
29
|
+
readonly 'caseMarkPath(board, { on, kind })': "a mark’s stroke points";
|
|
30
|
+
readonly 'drawPushPin(ctx, x, y, { color?, radius? })': "a red push pin";
|
|
31
|
+
readonly 'drawMarkerStroke(ctx, points, progress, { color?, width? })': "the first part of a marker stroke; returns the nib";
|
|
32
|
+
};
|
|
33
|
+
readonly cardKinds: readonly import("./case-board").CaseCardKind[];
|
|
34
|
+
readonly markKinds: Record<import("./case-board").CaseMarkKind, string>;
|
|
35
|
+
readonly card: "{ id, x, y (its pin, relative to the board), kind?, title?, note?, width?, height?, angle?, color?, at?, highlight?: { at, duration } }";
|
|
36
|
+
readonly string: "{ from, to, at?, duration?, color? }";
|
|
37
|
+
readonly mark: "{ on, kind, at, duration?, color?, width? }";
|
|
38
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small pure helpers shared by the noir / detective kit: timing windows,
|
|
3
|
+
* easing, colours with an alpha, and word wrapping. Nothing here keeps state.
|
|
4
|
+
*/
|
|
5
|
+
export declare const clamp01: (v: number) => number;
|
|
6
|
+
/** Smoothstep 0..1. */
|
|
7
|
+
export declare const smooth: (k: number) => number;
|
|
8
|
+
/** Progress 0..1 of `time` through [start, start + length]. */
|
|
9
|
+
export declare const progressIn: (time: number, start: number, length: number) => number;
|
|
10
|
+
/** A back-out pop 0..1 that overshoots a little before settling (cards pinned, a marker appearing). */
|
|
11
|
+
export declare function popIn(k: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* How visible something is at `time` that appears at `at` and lasts
|
|
14
|
+
* `duration` ms: it fades in over `fadeIn`, holds, and fades out over the
|
|
15
|
+
* last `fadeOut` ms (0 outside the window).
|
|
16
|
+
*/
|
|
17
|
+
export declare function fadeWindow(time: number, at: number, duration: number, fadeIn?: number, fadeOut?: number): number;
|
|
18
|
+
/** Any `#rgb`, `#rrggbb`, `rgb()` or `rgba()` colour with its alpha multiplied by `alpha` (other forms come back as they are). */
|
|
19
|
+
export declare function withAlpha(color: string, alpha: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Break text into lines no wider than `maxWidth` in the context's current
|
|
22
|
+
* font, at spaces (an explicit `\n` always breaks). A single word wider than
|
|
23
|
+
* the line stays whole.
|
|
24
|
+
*/
|
|
25
|
+
export declare function wrapText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string[];
|
|
26
|
+
/** A rounded rectangle path (no fill or stroke). */
|
|
27
|
+
export declare function roundedRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number): void;
|
|
28
|
+
/** A CSS font string: `weight size family`. */
|
|
29
|
+
export declare const fontOf: (size: number, weight: string | number, family: string) => string;
|
|
30
|
+
/** The default font family for the kit's text (any CSS family list works). */
|
|
31
|
+
export declare const NOIR_FONT = "system-ui, sans-serif";
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { Point } from '../../adapters/canvas/sketch';
|
|
2
|
+
/**
|
|
3
|
+
* Detective overlays for canvas scenes: the red magnifier that marks a clue,
|
|
4
|
+
* an evidence folder, a wall clock and a time chip, a freeze-frame name card
|
|
5
|
+
* for a suspect, a first-person narration box and a comic speech bubble.
|
|
6
|
+
*
|
|
7
|
+
* Every function takes the time (ms) and plain options and draws the same
|
|
8
|
+
* thing for the same input. Text is always the caller's (any language, any
|
|
9
|
+
* font family); nothing is measured except with the context's own font.
|
|
10
|
+
*/
|
|
11
|
+
export declare const NOIR_RED = "#d7263d";
|
|
12
|
+
export declare const NOIR_AMBER = "#f5b942";
|
|
13
|
+
export declare const NOIR_CREAM = "#efe6d2";
|
|
14
|
+
export declare const NOIR_INK = "#111111";
|
|
15
|
+
export interface ClueMarkerOptions {
|
|
16
|
+
/** Centre of the ring, scene px */
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
/** Ring radius, px (default 46) */
|
|
20
|
+
radius?: number;
|
|
21
|
+
/** When it pops on, ms */
|
|
22
|
+
at: number;
|
|
23
|
+
/** How long it stays, ms (default 3000), fading out over the last 400 */
|
|
24
|
+
duration?: number;
|
|
25
|
+
color?: string;
|
|
26
|
+
/** Ring width, px (default 6; the handle is 10/6 of it) */
|
|
27
|
+
lineWidth?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* How the clue marker shows at `time`: `opacity` (pops on over 300 ms, fades
|
|
31
|
+
* out over the last 400) and `scale` (a gentle pulse), or opacity 0 outside
|
|
32
|
+
* its window.
|
|
33
|
+
*/
|
|
34
|
+
export declare function clueMarkerAt(time: number, options: Pick<ClueMarkerOptions, 'at' | 'duration'>): {
|
|
35
|
+
opacity: number;
|
|
36
|
+
scale: number;
|
|
37
|
+
};
|
|
38
|
+
/** The red magnifier: a pulsing ring with a handle, over something worth noticing. Returns its opacity. */
|
|
39
|
+
export declare function drawClueMarker(ctx: CanvasRenderingContext2D, time: number, options: ClueMarkerOptions): number;
|
|
40
|
+
export interface EvidenceFolderOptions {
|
|
41
|
+
/** Centre, scene px */
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
/** 1 = 68 × 48 px (default 1) */
|
|
45
|
+
scale?: number;
|
|
46
|
+
/** Tilt, degrees (default 0) */
|
|
47
|
+
angle?: number;
|
|
48
|
+
color?: string;
|
|
49
|
+
ink?: string;
|
|
50
|
+
/** A short label on its front, in the caller's font (default none) */
|
|
51
|
+
label?: string;
|
|
52
|
+
labelColor?: string;
|
|
53
|
+
font?: string;
|
|
54
|
+
}
|
|
55
|
+
/** An evidence folder: a tabbed folder with a stripe (and an optional label). */
|
|
56
|
+
export declare function drawEvidenceFolder(ctx: CanvasRenderingContext2D, options: EvidenceFolderOptions): void;
|
|
57
|
+
export interface ClockFaceOptions {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
/** Default 52 px */
|
|
61
|
+
radius?: number;
|
|
62
|
+
/** 0–23 (with minutes, the hour hand moves between hours) */
|
|
63
|
+
hours: number;
|
|
64
|
+
minutes: number;
|
|
65
|
+
face?: string;
|
|
66
|
+
ink?: string;
|
|
67
|
+
}
|
|
68
|
+
/** A wall clock showing a time: a face with twelve ticks, an hour and a minute hand. */
|
|
69
|
+
export declare function drawClockFace(ctx: CanvasRenderingContext2D, options: ClockFaceOptions): void;
|
|
70
|
+
/** The clock's hand angles, radians clockwise from 12. */
|
|
71
|
+
export declare function clockHandAngles(hours: number, minutes: number): {
|
|
72
|
+
hour: number;
|
|
73
|
+
minute: number;
|
|
74
|
+
};
|
|
75
|
+
export interface TimeChipOptions {
|
|
76
|
+
/** Top-left corner, scene px */
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
/** Its text: a time, a place, a day ("Tuesday · 9:40 PM") */
|
|
80
|
+
text: string;
|
|
81
|
+
/** Font size, px (default 30) */
|
|
82
|
+
size?: number;
|
|
83
|
+
font?: string;
|
|
84
|
+
/** Text and border colour (default amber) */
|
|
85
|
+
color?: string;
|
|
86
|
+
background?: string;
|
|
87
|
+
/** When it fades in, ms (default 100), over 400 ms */
|
|
88
|
+
at?: number;
|
|
89
|
+
}
|
|
90
|
+
/** A time/place chip in a corner: amber text in a black box. Returns its width. */
|
|
91
|
+
export declare function drawTimeChip(ctx: CanvasRenderingContext2D, time: number, options: TimeChipOptions): number;
|
|
92
|
+
export interface NameCardOptions {
|
|
93
|
+
/** The suspect's name */
|
|
94
|
+
name: string;
|
|
95
|
+
/** A second line: who they are, a motive (default none) */
|
|
96
|
+
role?: string;
|
|
97
|
+
/** When it shows, ms, and for how long (default 2600) */
|
|
98
|
+
at: number;
|
|
99
|
+
duration?: number;
|
|
100
|
+
/** The suspect's head, scene px: the card goes beside it */
|
|
101
|
+
anchor: Point;
|
|
102
|
+
/** Which side of the head (default auto: right of a head in the left 57% of the frame) */
|
|
103
|
+
side?: 'auto' | 'left' | 'right';
|
|
104
|
+
/** The frame, for the dimming and the auto side (default 1920 × 1080) */
|
|
105
|
+
frame?: {
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
};
|
|
109
|
+
/** Dim the rest of the frame to this (default 0.35; 0 for none) */
|
|
110
|
+
dim?: number;
|
|
111
|
+
color?: string;
|
|
112
|
+
ink?: string;
|
|
113
|
+
nameSize?: number;
|
|
114
|
+
roleSize?: number;
|
|
115
|
+
font?: string;
|
|
116
|
+
/** Tilt, degrees (default -3.4) */
|
|
117
|
+
tilt?: number;
|
|
118
|
+
}
|
|
119
|
+
/** A freeze-frame name card: the frame dims and a slanted red band names the suspect beside their head. Returns its opacity. */
|
|
120
|
+
export declare function drawNameCard(ctx: CanvasRenderingContext2D, time: number, options: NameCardOptions): number;
|
|
121
|
+
/** How a line of text shows over its window: `opacity` and `reveal` (0..1 of its words typed on). */
|
|
122
|
+
export declare function lineReveal(time: number, start: number, end: number, typeDuration?: number): {
|
|
123
|
+
opacity: number;
|
|
124
|
+
reveal: number;
|
|
125
|
+
};
|
|
126
|
+
export interface NarrationBoxOptions {
|
|
127
|
+
text: string;
|
|
128
|
+
/** The line's start and end, ms */
|
|
129
|
+
start: number;
|
|
130
|
+
end: number;
|
|
131
|
+
/** Who narrates: a small tag on the box's top-left (default none) */
|
|
132
|
+
speaker?: string;
|
|
133
|
+
/** The box's left edge and width, and where its bottom sits, scene px (default a 1920 × 1080 frame's) */
|
|
134
|
+
x?: number;
|
|
135
|
+
width?: number;
|
|
136
|
+
bottom?: number;
|
|
137
|
+
/** Font size, px (default 42) */
|
|
138
|
+
size?: number;
|
|
139
|
+
font?: string;
|
|
140
|
+
background?: string;
|
|
141
|
+
ink?: string;
|
|
142
|
+
tagColor?: string;
|
|
143
|
+
/** How long the words take to type on, ms (default half the line, at most 1600) */
|
|
144
|
+
typeDuration?: number;
|
|
145
|
+
}
|
|
146
|
+
/** A first-person narration box along the bottom: cream paper, the narrator's tag, the words typed on. Returns its opacity. */
|
|
147
|
+
export declare function drawNarrationBox(ctx: CanvasRenderingContext2D, time: number, options: NarrationBoxOptions): number;
|
|
148
|
+
export interface SpeechBubbleOptions {
|
|
149
|
+
text: string;
|
|
150
|
+
/** The line's start and end, ms */
|
|
151
|
+
start: number;
|
|
152
|
+
end: number;
|
|
153
|
+
/** Where the tail points (the speaker's head), scene px */
|
|
154
|
+
tail: Point;
|
|
155
|
+
/** The speaker's name on a dark tag (default none) */
|
|
156
|
+
speaker?: string;
|
|
157
|
+
/** The widest a text line may be, px (default 640) */
|
|
158
|
+
maxWidth?: number;
|
|
159
|
+
size?: number;
|
|
160
|
+
font?: string;
|
|
161
|
+
/** The area the bubble keeps inside (default a 1920 × 1080 frame, 40 px in) */
|
|
162
|
+
bounds?: {
|
|
163
|
+
x: number;
|
|
164
|
+
y: number;
|
|
165
|
+
width: number;
|
|
166
|
+
height: number;
|
|
167
|
+
};
|
|
168
|
+
/** The lowest the bubble's centre may sit, scene y (default none) */
|
|
169
|
+
maxCenterY?: number;
|
|
170
|
+
/** Gap between the bubble and the head, px (default 70) */
|
|
171
|
+
gap?: number;
|
|
172
|
+
fill?: string;
|
|
173
|
+
ink?: string;
|
|
174
|
+
tagColor?: string;
|
|
175
|
+
tagText?: string;
|
|
176
|
+
}
|
|
177
|
+
/** A crisp comic speech bubble above a speaker, its tail to their head; pops on and shrinks away. Returns its scale. */
|
|
178
|
+
export declare function drawSpeechBubble(ctx: CanvasRenderingContext2D, time: number, options: SpeechBubbleOptions): number;
|