@algorisys/tinyfly 0.122.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 +15 -4
- package/docs/character-appearance.md +30 -5
- 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 +11 -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 +4365 -3916
- package/lib/addons/{cricket-play-BRehNToP.js → cricket-play-BVKhsPUD.js} +2106 -2041
- package/lib/addons/sports.js +1 -1
- package/lib/browser/tinyfly.iife.js +15 -13
- package/lib/browser/tinyfly.js +9237 -8726
- package/lib/browser/tinyfly.umd.js +15 -13
- package/lib/types/characters/body/bean-figure.d.ts +37 -2
- package/lib/types/characters/capabilities.d.ts +11 -0
- package/lib/types/characters/cast.d.ts +42 -0
- package/lib/types/characters/index.d.ts +2 -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 +232 -15
- package/llms.txt +32 -31
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +7 -0
package/README.md
CHANGED
|
@@ -161,6 +161,17 @@ bare line limbs with `bean: { limbs: 'line' }`), a shaped body, big oval eyes (`
|
|
|
161
161
|
mittens and cartoon shoes, plus detective gear (`coat`, `fedora`, aviator `shades`), on the same rig, so every pose, gait, dance and expression works.
|
|
162
162
|
Try `character(castMember('beanMan', 400))` or the other `BEAN_CAST` presets; see
|
|
163
163
|
[the appearance guide](docs/character-appearance.md#bean-figures-white-outlined-stick-figures).
|
|
164
|
+
Household clothes dress them too: a `skirt` (a sari, or a kurta's hem with `length`) that
|
|
165
|
+
walks and sits with the legs, a `drape` (pallu or dupatta) and `bangles` (`castMember('beanSari', 400)`).
|
|
166
|
+
|
|
167
|
+
**Noir and detective scenes**: a canvas kit for detective stories, deterministic from time: rain in a
|
|
168
|
+
window, light through blinds, darkness with torch beams and holes, glow, vignette, lightning and a
|
|
169
|
+
flickering bulb (`drawRain`, `drawBlinds`, `drawDarkness`, …); the red clue magnifier, an evidence folder,
|
|
170
|
+
a clock and time chip, a freeze-frame suspect name card, a typed narration box and speech bubbles; and a
|
|
171
|
+
case board as data (`caseBoard` + `drawCaseBoard`: pinned photo and note cards, red string, marker
|
|
172
|
+
cross-outs and scribble-outs drawn on over time). Text and fonts are yours. See
|
|
173
|
+
[Noir and Detective Scenes](docs/noir-detective.md) and the
|
|
174
|
+
[Noir Case File](https://tinyfly.app/examples/live-noir-case-file) example.
|
|
164
175
|
|
|
165
176
|
The [Young Adult Manga Cast](https://tinyfly.app/examples/live-manga-cast)
|
|
166
177
|
adds four original presets with angular jaws, tapered chins, narrower eyes
|
|
@@ -291,7 +302,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
|
|
|
291
302
|
itself.
|
|
292
303
|
|
|
293
304
|
```html
|
|
294
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
305
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly.iife.js"></script>
|
|
295
306
|
<script>
|
|
296
307
|
tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
|
|
297
308
|
|
|
@@ -328,7 +339,7 @@ A teaching figure needs no code at all:
|
|
|
328
339
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
|
|
329
340
|
<figcaption>Appending to a full slice</figcaption>
|
|
330
341
|
</figure>
|
|
331
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
342
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
|
|
332
343
|
```
|
|
333
344
|
|
|
334
345
|
See [Teaching Animations](docs/teaching.md).
|
|
@@ -427,7 +438,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
|
|
|
427
438
|
<div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
|
|
428
439
|
</div>
|
|
429
440
|
|
|
430
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
441
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-player.iife.js"></script>
|
|
431
442
|
<script>
|
|
432
443
|
tinyfly.play('#animation', './animation.json', { loop: -1 })
|
|
433
444
|
</script>
|
|
@@ -536,7 +547,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
|
|
|
536
547
|
<svg viewBox="0 0 720 200">…</svg>
|
|
537
548
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
|
|
538
549
|
</figure>
|
|
539
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
550
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
540
551
|
```
|
|
541
552
|
|
|
542
553
|
### Audio / Video Sync
|
|
@@ -563,8 +563,9 @@ const stick = character(castMember('beanStick', 400)) // bare line limbs
|
|
|
563
563
|
the legs, join the body without a seam: their outline is left out where it
|
|
564
564
|
lies inside the body at the root, so the fills flow together. Under a tee or
|
|
565
565
|
trousers the hem shows instead.
|
|
566
|
-
- Painter order (`joints.parts[id].order`): the back arm, the legs
|
|
567
|
-
|
|
566
|
+
- Painter order (`joints.parts[id].order`): the back arm, the legs (and a
|
|
567
|
+
skirt over both), the neck, the body (with its drape, and coat), the near
|
|
568
|
+
arm and the head (and fedora). A limb reaching toward the viewer
|
|
568
569
|
(hands on the knees, seated thighs) draws over the body.
|
|
569
570
|
- `bean: { limbs, torso, limbWidth, lineWidth, outlineWidth, fill, shirt, sleeves, trousers, shoes }`:
|
|
570
571
|
`limbs: 'tube'` (default, outlined noodles) or `'line'` (bare round-capped
|
|
@@ -583,6 +584,26 @@ const stick = character(castMember('beanStick', 400)) // bare line limbs
|
|
|
583
584
|
(big dark aviator lenses in place of the eyes, the brows still showing,
|
|
584
585
|
so the face keeps its expression; the same as `face: { shades: true }` on
|
|
585
586
|
any oval-eyed face). `castMember('beanDetective', 400)` wears all three.
|
|
587
|
+
- Household clothes (all off by default):
|
|
588
|
+
- `skirt`: a colour (a sari or long skirt, ending just above the ankle so
|
|
589
|
+
the shoes show) or `{ color, length }`, `length` 0.1–1 of the way from
|
|
590
|
+
the hips to the ankles (about 0.45 for a kurta's hem over trousers). It
|
|
591
|
+
follows the legs: standing or walking it is one flared shape outside both
|
|
592
|
+
legs with two soft pleats; seated (`beanStanding(joints)` is false) it
|
|
593
|
+
lies along each thigh to the knees and shins, its ends kept above the
|
|
594
|
+
floor. Under a skirt the legs draw before the body, so the body covers
|
|
595
|
+
the waist.
|
|
596
|
+
- `drape`: a pallu or dupatta in that colour, a band from the shoulder by
|
|
597
|
+
the neck across the chest to the far hip, inside the body's outline.
|
|
598
|
+
- `bangles`: their colour; three thin rings across each forearm near the
|
|
599
|
+
wrist (`BEAN_BANGLE_STOPS`), over any sleeve.
|
|
600
|
+
- `castMember('beanSari', 400)` wears all three, with a blouse (`shirt`),
|
|
601
|
+
a low bun and dark shoes.
|
|
602
|
+
|
|
603
|
+
```js
|
|
604
|
+
const kurta = character({ figure: 'bean', height: 400, hair: { style: 'bob', color: '#222' },
|
|
605
|
+
bean: { shirt: '#0e7490', skirt: { color: '#0e7490', length: 0.45 }, trousers: '#f5f5f4', drape: '#fbbf24', bangles: '#dc2626' } })
|
|
606
|
+
```
|
|
586
607
|
- Defaults: ink `#111111`, white skin, `hands: 'mitten'`, shoulders 0.04 and
|
|
587
608
|
hips 0.02 of the height, `face: { style: 'oval', projection: 'volume', teeth: true, tongue: true }`.
|
|
588
609
|
The bean is always drawn in the clean look (its outline is the look).
|
|
@@ -594,12 +615,16 @@ const stick = character(castMember('beanStick', 400)) // bare line limbs
|
|
|
594
615
|
big eyes; `face.shades` puts aviators in their place.
|
|
595
616
|
- `hands: 'mitten'` (any figure) is a plain oval mitten along the forearm.
|
|
596
617
|
- Presets in `BEAN_CAST` (also in `CHARACTER_CAST`, group `bean`):
|
|
597
|
-
`beanMan`, `beanWoman`, `beanKid`, `beanBoss`, `beanDetective
|
|
598
|
-
`beanStick` (bare lines).
|
|
618
|
+
`beanMan`, `beanWoman`, `beanKid`, `beanBoss`, `beanDetective`,
|
|
619
|
+
`beanStick` (bare lines) and `beanSari` (a sari with a pallu and bangles).
|
|
599
620
|
- Helpers for your own layers: `beanTorso(bean, joints)` and
|
|
600
621
|
`beanTorsoOutline(torso)` (the body's shape), `beanLimbLine(root, joint, end)`
|
|
601
622
|
(a limb's centre line), `mittenAt`, `beanShoeAt`, `beanOrder`, `beanOverBody`,
|
|
602
|
-
`drawBeanFedora
|
|
623
|
+
`drawBeanFedora`, `beanAlongLeg(joints, side, f)` (a point along a leg) and
|
|
624
|
+
`beanStanding(joints)`.
|
|
625
|
+
- For detective and noir scenes around these figures (rain, blinds, torch
|
|
626
|
+
beams, clue markers, name cards, a case board), see
|
|
627
|
+
[Noir and Detective Scenes](noir-detective.md).
|
|
603
628
|
|
|
604
629
|
### Young adult manga cast
|
|
605
630
|
|
package/docs/editor-guide.md
CHANGED
|
@@ -1143,7 +1143,7 @@ The dialog shows the generated HTML/JavaScript code with a **Copy Code** button.
|
|
|
1143
1143
|
**Steps to embed:**
|
|
1144
1144
|
1. Build the player: `npm run build:player`
|
|
1145
1145
|
2. Copy `lib/player/tinyfly-player.iife.js` to your project (or load
|
|
1146
|
-
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
1146
|
+
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-player.iife.js`
|
|
1147
1147
|
instead; see [Deployment](DEPLOYMENT.md))
|
|
1148
1148
|
3. Copy the generated code into your HTML
|
|
1149
1149
|
4. Adjust the script `src` path if needed
|
package/docs/examples.md
CHANGED
|
@@ -11,6 +11,17 @@ its own controls and scrolling in a full viewport; gallery panels and code
|
|
|
11
11
|
sections remain in the original tab. **Copy code** exports the same standalone
|
|
12
12
|
HTML. [Try the manga example](https://tinyfly.app/examples/live-manga-cast/full).
|
|
13
13
|
|
|
14
|
+
## Noir Case File
|
|
15
|
+
|
|
16
|
+
[Noir Case File](https://tinyfly.app/examples/live-noir-case-file) plays a
|
|
17
|
+
detective scene from the noir kit: rain on the window, street light through
|
|
18
|
+
the blinds, a torch beam in the dark, the red clue magnifier, a speech
|
|
19
|
+
bubble, a freeze-frame name card, a narration box and a time chip. Switch to
|
|
20
|
+
the case board, where cards are pinned up, red string stretches between them
|
|
21
|
+
and the marker crosses out, strikes, scribbles out and rings them. The bean
|
|
22
|
+
cast wears a trench coat and a sari with a pallu and bangles. See
|
|
23
|
+
[Noir and Detective Scenes](noir-detective.md).
|
|
24
|
+
|
|
14
25
|
## Young Adult Manga Cast
|
|
15
26
|
|
|
16
27
|
[Young Adult Manga Cast](https://tinyfly.app/examples/live-manga-cast) shows
|
|
@@ -743,7 +754,7 @@ For simple website embedding without a build system.
|
|
|
743
754
|
</html>
|
|
744
755
|
```
|
|
745
756
|
|
|
746
|
-
Build the player with `npm run build:player` to generate `lib/player/tinyfly-player.iife.js`, or load it from the CDN: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
757
|
+
Build the player with `npm run build:player` to generate `lib/player/tinyfly-player.iife.js`, or load it from the CDN: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-player.iife.js`.
|
|
747
758
|
|
|
748
759
|
---
|
|
749
760
|
|
package/docs/getting-started.md
CHANGED
|
@@ -185,7 +185,7 @@ with a GSAP-style call (durations are in seconds here):
|
|
|
185
185
|
```html
|
|
186
186
|
<div class="box" style="width:60px;height:60px;background:#4a9eff"></div>
|
|
187
187
|
|
|
188
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
188
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly.iife.js"></script>
|
|
189
189
|
<script>
|
|
190
190
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
191
191
|
</script>
|
package/docs/gsap-compat.md
CHANGED
|
@@ -74,7 +74,7 @@ Without a build step, the all-in-one bundle exposes the same functions on a
|
|
|
74
74
|
global — `tinyfly.to()`, `tinyfly.timeline()` and so on:
|
|
75
75
|
|
|
76
76
|
```html
|
|
77
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly.iife.js"></script>
|
|
78
78
|
<script>
|
|
79
79
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
80
80
|
</script>
|
package/docs/llm-guide.md
CHANGED
|
@@ -223,6 +223,17 @@ lines (`bean: { limbs: 'tube' | 'line' }`), a shaped body (`bean.torso` fullness
|
|
|
223
223
|
(`face.style: 'oval'`, usable on any figure), `hands: 'mitten'` and cartoon shoes; colours from
|
|
224
224
|
`bean: { shirt, sleeves, trousers, shoes }` or an `outfit`; detective gear `bean: { coat, fedora, shades: true }`
|
|
225
225
|
(aviators replace the eyes, brows still show); `halo` gives line limbs a pale edge. A bean is always drawn clean.
|
|
226
|
+
Household clothes on a bean: `bean: { skirt: '#c2410c' }` (a sari to the ankle) or
|
|
227
|
+
`skirt: { color, length: 0.45 }` (a kurta hem; pair it with `trousers`), `drape` (a pallu or dupatta sash)
|
|
228
|
+
and `bangles`; preset `beanSari`. The skirt follows the legs (flared standing, along the thighs seated).
|
|
229
|
+
For detective / noir scenes use the canvas kit (docs/noir-detective.md): `drawRain(ctx, time, box)`,
|
|
230
|
+
`drawBlinds`, `drawDarkness(ctx, { amount, cones: [{ x, y, angle /* degrees */, length, width }], holes })`,
|
|
231
|
+
`drawGlow`, `drawVignette`, `drawClueMarker(ctx, time, { x, y, at })`, `drawNameCard(ctx, time, { name, role, at, anchor })`,
|
|
232
|
+
`drawNarrationBox(ctx, time, { text, start, end, speaker })`, `drawSpeechBubble(ctx, time, { text, start, end, tail })`,
|
|
233
|
+
`drawTimeChip`, `drawClockFace`, `drawEvidenceFolder`, and a case board as data:
|
|
234
|
+
`drawCaseBoard(ctx, caseBoard({ x, y, width, height, cards, strings, marks }), time, { drawCard })`
|
|
235
|
+
(marks `cross | strike | scribble | circle`; it returns the marker nib). All times are ms and every
|
|
236
|
+
function is a pure function of time; never use `Math.random` for rain or grain. Text is yours (any script).
|
|
226
237
|
The `look` values are `clean`, `pencil`, `silhouette` and `illustrated`
|
|
227
238
|
(inked and painted, tuned with `illustrated: { light, weight, taper, shadow, highlight }`).
|
|
228
239
|
Age is proportions, hair, creases and clothes, never a stoop; a `cane` in a hand or
|
package/docs/maps.md
CHANGED
|
@@ -14,8 +14,8 @@ On a page with no build step, load the maps add-on after the browser bundle; it
|
|
|
14
14
|
adds to the same `tinyfly` global:
|
|
15
15
|
|
|
16
16
|
```html
|
|
17
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
18
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
17
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly.iife.js"></script>
|
|
18
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-maps.iife.js"></script>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
It is a separate script because the offline world map it carries adds about
|
package/docs/math.md
CHANGED
|
@@ -258,7 +258,7 @@ lesson's step options (`duration`, `easing`, `delay`).
|
|
|
258
258
|
<figcaption>The determinant is the area of the unit square after the map.</figcaption>
|
|
259
259
|
</figure>
|
|
260
260
|
|
|
261
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
261
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
|
|
262
262
|
```
|
|
263
263
|
|
|
264
264
|
The figure draws itself into an SVG and redraws from the timeline whenever the
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Noir and Detective Scenes
|
|
2
|
+
|
|
3
|
+
A kit for detective stories and film-noir moods on a canvas: rain on the
|
|
4
|
+
window, street light through venetian blinds, a dark room with a torch beam,
|
|
5
|
+
soft pools of light and a vignette; the red magnifier that marks a clue, an
|
|
6
|
+
evidence folder, a wall clock and a time chip, a freeze-frame name card for a
|
|
7
|
+
suspect, a first-person narration box and speech bubbles; and a case board
|
|
8
|
+
with pinned cards, red string and the marker's cross-outs and scribble-outs.
|
|
9
|
+
|
|
10
|
+
Every function draws on a Canvas 2D context, takes the time in ms and plain
|
|
11
|
+
options, and draws the same thing for the same input: rain comes from a
|
|
12
|
+
seeded generator, never `Math.random`, so a frame looks the same whether it
|
|
13
|
+
is rendered in order, out of order or scrubbed to. Text is always yours (any
|
|
14
|
+
language or script) and so are the fonts (`font` is a CSS family list).
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { character, castMember, drawCharacter, humanPose, HUMAN_POSES,
|
|
18
|
+
drawRain, drawBlinds, drawDarkness, drawVignette, drawClueMarker,
|
|
19
|
+
drawNameCard, drawNarrationBox, drawTimeChip } from '@algorisys/tinyfly/characters'
|
|
20
|
+
|
|
21
|
+
const detective = character(castMember('beanDetective', 460))
|
|
22
|
+
|
|
23
|
+
function frame(ctx, time) {
|
|
24
|
+
ctx.fillStyle = '#232b37'
|
|
25
|
+
ctx.fillRect(0, 0, 1920, 1080)
|
|
26
|
+
drawRain(ctx, time, { x: 1500, y: 160, width: 340, height: 440 }) // the window
|
|
27
|
+
drawBlinds(ctx, { x: 0, y: 0, width: 1920, height: 1080, opacity: 0.08 })
|
|
28
|
+
ctx.save(); ctx.translate(560, 880)
|
|
29
|
+
drawCharacter(ctx, detective, humanPose({ ...HUMAN_POSES.think, turn: 0.45 }), time)
|
|
30
|
+
ctx.restore()
|
|
31
|
+
drawDarkness(ctx, { amount: 1, cones: [{ x: 640, y: 520, angle: 15, length: 760, width: 190 }] })
|
|
32
|
+
drawClueMarker(ctx, time, { x: 900, y: 680, at: 1500 })
|
|
33
|
+
drawNameCard(ctx, time, { name: 'The witness', role: 'heard footsteps', at: 6800, anchor: { x: 1340, y: 470 } })
|
|
34
|
+
drawVignette(ctx, { width: 1920, height: 1080 })
|
|
35
|
+
drawTimeChip(ctx, time, { x: 50, y: 40, text: 'Tuesday · 9:40 PM' })
|
|
36
|
+
drawNarrationBox(ctx, time, { text: 'It rained all night.', start: 300, end: 3400, speaker: 'Case file #1' })
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The [Noir Case File](https://tinyfly.app/examples/live-noir-case-file)
|
|
41
|
+
example plays a whole scene and its case board.
|
|
42
|
+
|
|
43
|
+
## Atmosphere
|
|
44
|
+
|
|
45
|
+
| Function | What it draws |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `drawRain(ctx, time, { x, y, width, height, drops?, opacity?, color?, speed?, length?, slant?, lineWidth?, seed? })` | Streaks falling in a box (a window, or the whole frame), clipped to it. 70 drops at 900–1440 px/s by default; `seed` moves them. |
|
|
48
|
+
| `drawBlinds(ctx, { x, y, width, height, opacity?, slope?, spacing?, band?, color? })` | Key light through venetian blinds: parallel slanted bands (`slope` 0.35, every 52 px, 24 px thick). |
|
|
49
|
+
| `drawDarkness(ctx, { amount, cones?, holes?, bounds?, color?, opacity?, beam?, beamOpacity? })` | A dark overlay (`amount` 0–1) with torch beams and round holes cut out. A cone is `{ x, y, angle, length, width }`: from its apex toward `angle` degrees (0 right, 90 down), `width` half-wide at its end; a hole is `{ x, y, radius }`. Beams keep a little of the dark and a faint warm tint (`beam: null` for none). `coneCorners(cone)` gives a beam's corners. |
|
|
50
|
+
| `drawGlow(ctx, { x, y, radius, color?, opacity? })` | A soft pool of light (a lamp, a lit window): a radial gradient to clear. |
|
|
51
|
+
| `drawVignette(ctx, { width, height, x?, y?, inner?, outer?, opacity?, color? })` | The frame's edges fall into dark, from `inner` to `outer` of the half-diagonal. |
|
|
52
|
+
| `lightningFlash(time, strikes, decay?)` | Flash brightness 0–1 from strike times; fill the frame with a pale blue at about 0.25 × this. |
|
|
53
|
+
| `lightFlicker(time, strength?)` | A failing bulb: 0 or `strength`, in an irregular but repeatable rhythm; darken the room by it. |
|
|
54
|
+
|
|
55
|
+
Colours may be `#rgb`, `#rrggbb`, `rgb()` or `rgba()`; opacities multiply in.
|
|
56
|
+
|
|
57
|
+
## Detective overlays
|
|
58
|
+
|
|
59
|
+
| Function | What it draws |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `drawClueMarker(ctx, time, { x, y, radius?, at, duration?, color?, lineWidth? })` | The red magnifier over a clue (or a red herring): pops on at `at`, pulses, fades out over the last 400 ms of `duration` (3000). Returns its opacity; `clueMarkerAt(time, { at, duration })` gives `{ opacity, scale }`. |
|
|
62
|
+
| `drawEvidenceFolder(ctx, { x, y, scale?, angle?, color?, ink?, label?, font? })` | A tabbed folder (68 × 48 px at scale 1), tilted `angle` degrees, with an optional short label. |
|
|
63
|
+
| `drawClockFace(ctx, { x, y, radius?, hours, minutes, face?, ink? })` | A wall clock showing a time; `clockHandAngles(hours, minutes)` gives the hands. |
|
|
64
|
+
| `drawTimeChip(ctx, time, { x, y, text, size?, font?, color?, background?, at? })` | A time or place chip (amber on black) that fades in; returns its width. |
|
|
65
|
+
| `drawNameCard(ctx, time, { name, role?, at, duration?, anchor, side?, frame?, dim?, color?, nameSize?, roleSize?, font?, tilt? })` | The freeze-frame suspect card: the frame dims (`dim` 0.35) and a slanted red band names them beside their head (`anchor`), on the side with room (`side: 'auto'`). Returns its opacity. |
|
|
66
|
+
| `drawNarrationBox(ctx, time, { text, start, end, speaker?, x?, width?, bottom?, size?, font?, background?, ink?, tagColor?, typeDuration? })` | A first-person narration box along the bottom: cream paper, the narrator's tag, the words typed on a whole word at a time (so every script types cleanly). `lineReveal(time, start, end)` gives `{ opacity, reveal }`. |
|
|
67
|
+
| `drawSpeechBubble(ctx, time, { text, start, end, tail, speaker?, maxWidth?, size?, font?, bounds?, maxCenterY?, gap?, fill?, ink? })` | A crisp comic bubble above the speaker, its tail to `tail` (their head), kept inside `bounds`; pops on at `start`, shrinks away after `end`. |
|
|
68
|
+
|
|
69
|
+
The defaults fit a 1920 × 1080 frame; pass `frame`, `bounds` or `x`/`width`
|
|
70
|
+
for another size. Draw overlays after the camera's transform is undone (in
|
|
71
|
+
screen space) and map heads with your camera, as `cameraPoint` does.
|
|
72
|
+
|
|
73
|
+
## The case board
|
|
74
|
+
|
|
75
|
+
A board is plain data: cards (photos of suspects, notes about clues), strings
|
|
76
|
+
between them and the marker's work, each with a time.
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import { caseBoard, drawCaseBoard, caseBoardMarkerTip, drawCharacter, humanPose } from '@algorisys/tinyfly/characters'
|
|
80
|
+
|
|
81
|
+
const board = caseBoard({
|
|
82
|
+
x: 60, y: 110, width: 1800, height: 900,
|
|
83
|
+
cards: [
|
|
84
|
+
{ id: 'title', x: 900, y: 40, kind: 'note', title: 'WHO CUT THE ALARM?', width: 520, height: 96 },
|
|
85
|
+
{ id: 'lift', x: 900, y: 300, title: 'Lift 2', note: 'stuck at 9:40' },
|
|
86
|
+
{ id: 'guard', x: 330, y: 540, title: 'The guard', note: 'had the key', at: 700 },
|
|
87
|
+
{ id: 'wire', x: 1450, y: 220, kind: 'note', title: 'alarm wire: cut', at: 1400 },
|
|
88
|
+
],
|
|
89
|
+
strings: [{ from: 'lift', to: 'guard', at: 1000 }, { from: 'lift', to: 'wire', at: 1400 }],
|
|
90
|
+
marks: [
|
|
91
|
+
{ on: 'guard', kind: 'cross', at: 3200 },
|
|
92
|
+
{ on: 'title', kind: 'scribble', at: 6000, duration: 1200 },
|
|
93
|
+
],
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const nib = drawCaseBoard(ctx, board, time, {
|
|
97
|
+
drawCard: (ctx, card, area) => { /* draw a portrait inside area (clipped), in the card's frame */ },
|
|
98
|
+
})
|
|
99
|
+
if (nib) drawMarkerHand(ctx, nib) // your own hand or pen, at the marker's nib
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- **Cards**: `{ id, x, y, kind?, title?, note?, width?, height?, angle?, color?, at?, highlight? }`.
|
|
103
|
+
`x`, `y` is where the card is pinned (its top centre), relative to the
|
|
104
|
+
board. `kind: 'photo'` (default, 220 × 260) is a print with a dark picture
|
|
105
|
+
area, a bold title and a red note; `kind: 'note'` (220 × 124) is a yellow
|
|
106
|
+
slip with the title and note in `handFont`. A card pops up onto its pin at
|
|
107
|
+
`at`; `highlight: { at, duration }` pulses an amber outline round it. Tilts
|
|
108
|
+
default to a small seeded angle.
|
|
109
|
+
- **Strings**: `{ from, to, at?, duration?, color? }`, red string stretching
|
|
110
|
+
from one pin to the other over `duration` (600 ms), under the cards.
|
|
111
|
+
- **Marks**: `{ on, kind, at, duration?, color?, width? }`, the marker drawn
|
|
112
|
+
on over `duration` (1400 ms): `cross` (two diagonals, one after the
|
|
113
|
+
other: ruled out), `strike` (one diagonal: half ruled out), `scribble` (a
|
|
114
|
+
zigzag across the card: scribbled out) and `circle` (a loose ring round
|
|
115
|
+
it). Marks stay once drawn.
|
|
116
|
+
- `caseBoard` checks the board and resolves every default; an unknown card
|
|
117
|
+
id or kind throws with a did-you-mean.
|
|
118
|
+
- `drawCaseBoard(ctx, board, time, { drawCard })` returns the marker's nib
|
|
119
|
+
while a mark is being drawn (else null), as does
|
|
120
|
+
`caseBoardMarkerTip(board, time)`: put a hand there. `caseCardBox(board, id)`
|
|
121
|
+
gives a card's pin, centre and corners; `caseMarkPath(board, mark)` a
|
|
122
|
+
mark's stroke points; `drawPushPin` and `drawMarkerStroke(ctx, points,
|
|
123
|
+
progress)` draw single pieces for your own boards.
|
|
124
|
+
|
|
125
|
+
## With the characters
|
|
126
|
+
|
|
127
|
+
The [bean figures](character-appearance.md#bean-figures-white-outlined-stick-figures)
|
|
128
|
+
come dressed for it: `castMember('beanDetective')` wears a trench coat, a
|
|
129
|
+
fedora and aviator shades, and household clothes (`skirt`, `drape`,
|
|
130
|
+
`bangles`; `castMember('beanSari')`) dress the witnesses. Draw a suspect in a
|
|
131
|
+
photo card through `drawCard`, and anchor a name card or a speech bubble at a
|
|
132
|
+
figure's head from `characterJoints`.
|
|
133
|
+
|
|
134
|
+
## In the catalog
|
|
135
|
+
|
|
136
|
+
`npx tinyfly capabilities` lists the kit under "Noir / detective kit";
|
|
137
|
+
`capabilities().noir` has it as data (`NOIR_KIT`).
|
package/docs/teaching.md
CHANGED
|
@@ -25,7 +25,7 @@ path for all of that:
|
|
|
25
25
|
</figure>
|
|
26
26
|
|
|
27
27
|
<!-- once, anywhere on the page (a site-wide footer is fine) -->
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.123.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Every `[data-tinyfly-embed]` mounts when the page is ready, with no per-post
|