@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
package/README.md
CHANGED
|
@@ -155,6 +155,24 @@ Coloured irises, highlights, lids and age creases use the same expressions,
|
|
|
155
155
|
head turns and motion APIs. Choose a preset in the editor's Cast picker or
|
|
156
156
|
use `character(castMember('animeYoungWoman', 300))` in code.
|
|
157
157
|
|
|
158
|
+
**Bean figures**: `figure: 'bean'` draws the white outlined stick-figure style natively:
|
|
159
|
+
smooth outlined noodle limbs with no seams at the elbows, knees, shoulders, neck or hips (or
|
|
160
|
+
bare line limbs with `bean: { limbs: 'line' }`), a shaped body, big oval eyes (`face.style: 'oval'`),
|
|
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
|
+
Try `character(castMember('beanMan', 400))` or the other `BEAN_CAST` presets; see
|
|
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.
|
|
175
|
+
|
|
158
176
|
The [Young Adult Manga Cast](https://tinyfly.app/examples/live-manga-cast)
|
|
159
177
|
adds four original presets with angular jaws, tapered chins, narrower eyes
|
|
160
178
|
and pointed hair tufts. Use `MANGA_CAST` or `castMember('mangaYoungMan', 300)`;
|
|
@@ -284,7 +302,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
|
|
|
284
302
|
itself.
|
|
285
303
|
|
|
286
304
|
```html
|
|
287
|
-
<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>
|
|
288
306
|
<script>
|
|
289
307
|
tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
|
|
290
308
|
|
|
@@ -321,7 +339,7 @@ A teaching figure needs no code at all:
|
|
|
321
339
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
|
|
322
340
|
<figcaption>Appending to a full slice</figcaption>
|
|
323
341
|
</figure>
|
|
324
|
-
<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>
|
|
325
343
|
```
|
|
326
344
|
|
|
327
345
|
See [Teaching Animations](docs/teaching.md).
|
|
@@ -420,7 +438,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
|
|
|
420
438
|
<div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
|
|
421
439
|
</div>
|
|
422
440
|
|
|
423
|
-
<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>
|
|
424
442
|
<script>
|
|
425
443
|
tinyfly.play('#animation', './animation.json', { loop: -1 })
|
|
426
444
|
</script>
|
|
@@ -529,7 +547,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
|
|
|
529
547
|
<svg viewBox="0 0 720 200">…</svg>
|
|
530
548
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
|
|
531
549
|
</figure>
|
|
532
|
-
<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>
|
|
533
551
|
```
|
|
534
552
|
|
|
535
553
|
### Audio / Video Sync
|
|
@@ -497,7 +497,7 @@ cast member at an adult `height` (each stands at their own scale of it). The
|
|
|
497
497
|
family: `boy`, `girl`, `youngMan`, `youngWoman`, `man`, `woman`, `grandpa`,
|
|
498
498
|
`grandma`; at work (from the occupations sheet): `doctor`, `cook`, `builder`,
|
|
499
499
|
`courier`, `teacher`, `farmer`. `CHARACTER_CAST` has each one's `label`,
|
|
500
|
-
`group` (`family`, `work`, `anime` or `
|
|
500
|
+
`group` (`family`, `work`, `anime`, `manga` or `bean`), `scale` and `options`.
|
|
501
501
|
|
|
502
502
|
```js
|
|
503
503
|
const family = ['man', 'woman', 'girl', 'grandma'].map((name) => character(castMember(name, 280)))
|
|
@@ -540,6 +540,92 @@ face close-ups and a complete turnaround. Both the Character and 3D Scene
|
|
|
540
540
|
editors offer these presets in their Cast picker. The Character editor also
|
|
541
541
|
has Face style, Iris colour, Eyelashes and Age creases controls, saved in project JSON.
|
|
542
542
|
|
|
543
|
+
### Bean figures (white outlined stick figures)
|
|
544
|
+
|
|
545
|
+
`figure: 'bean'` draws the common white outlined stick-figure style: a white
|
|
546
|
+
figure with a thick black outline, smooth noodle limbs, a shaped body (rounded
|
|
547
|
+
shoulders, a slight waist, fuller hips and a rounded seat), a round head with
|
|
548
|
+
big white oval eyes, small pupils and heavy brows, white mittens and big
|
|
549
|
+
cartoon shoes (a flat sole on the ground, a rounded toe cap, a low heel). The
|
|
550
|
+
rig solves the pose as for every figure, so every pose, gait, dance, reach,
|
|
551
|
+
turn and lip-sync works on it.
|
|
552
|
+
|
|
553
|
+
```js
|
|
554
|
+
const hero = character({ figure: 'bean', height: 400, hair: { style: 'spiky', color: '#111' },
|
|
555
|
+
bean: { shirt: '#ef4444', trousers: '#1e3a5f' } })
|
|
556
|
+
drawCharacter(ctx, hero, humanPose({ ...HUMAN_POSES.point, ...HUMAN_EXPRESSIONS.happy, turn: 0.5 }))
|
|
557
|
+
const stick = character(castMember('beanStick', 400)) // bare line limbs
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
- Each limb is one smooth curve through its joints, stroked in the ink and
|
|
561
|
+
stroked again, narrower, in the fill, with round caps and joins: elbows and
|
|
562
|
+
knees never show a seam. The front arm, and on a plain figure the neck and
|
|
563
|
+
the legs, join the body without a seam: their outline is left out where it
|
|
564
|
+
lies inside the body at the root, so the fills flow together. Under a tee or
|
|
565
|
+
trousers the hem shows instead.
|
|
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
|
|
569
|
+
(hands on the knees, seated thighs) draws over the body.
|
|
570
|
+
- `bean: { limbs, torso, limbWidth, lineWidth, outlineWidth, fill, shirt, sleeves, trousers, shoes }`:
|
|
571
|
+
`limbs: 'tube'` (default, outlined noodles) or `'line'` (bare round-capped
|
|
572
|
+
ink lines for the arms, legs and neck; the body, eyes, mittens and shoes
|
|
573
|
+
stay; `halo: '#f5f5f4'` adds a pale edge so they read on a dark set); the
|
|
574
|
+
near arm is in front of the body in both modes; `torso` body fullness
|
|
575
|
+
(1; 1.3 chubby, 0.85 thin); widths as fractions of the height (0.024 tube,
|
|
576
|
+
0.017 line, 0.0105 outline; `lineWidth` on the character also sets the
|
|
577
|
+
outline); `fill` (white); a `shirt` colour with `sleeves: 'short' | 'long' | 'none'`;
|
|
578
|
+
`trousers`; `shoes` (the fill; a dark shoe gets a shine and a dark sole).
|
|
579
|
+
An `outfit`'s `shirt`, `trousers` and `sleeves` colour the bean too (its
|
|
580
|
+
layers are not used).
|
|
581
|
+
- Detective gear: `coat` (a trench coat in that colour: lapels, a belt and
|
|
582
|
+
buckle, double-breasted buttons, a hem at the knee and sleeves to the
|
|
583
|
+
wrist), `fedora` (a brim, a pinched crown and a band) and `shades: true`
|
|
584
|
+
(big dark aviator lenses in place of the eyes, the brows still showing,
|
|
585
|
+
so the face keeps its expression; the same as `face: { shades: true }` on
|
|
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
|
+
```
|
|
607
|
+
- Defaults: ink `#111111`, white skin, `hands: 'mitten'`, shoulders 0.04 and
|
|
608
|
+
hips 0.02 of the height, `face: { style: 'oval', projection: 'volume', teeth: true, tongue: true }`.
|
|
609
|
+
The bean is always drawn in the clean look (its outline is the look).
|
|
610
|
+
- `face.style: 'oval'` works on any figure: big white oval eyes almost
|
|
611
|
+
touching, a small pupil following `lookX`/`lookY`, lids in the skin for
|
|
612
|
+
`lid`, a blink or a half-open `eye.*`, a lid line when shut (arched up in a
|
|
613
|
+
laugh), heavy brows for `brow.left`/`brow.right` and `browTilt`, and
|
|
614
|
+
bigger eyes for `eye.*` above 1 and `bulge`. Glasses grow to fit round the
|
|
615
|
+
big eyes; `face.shades` puts aviators in their place.
|
|
616
|
+
- `hands: 'mitten'` (any figure) is a plain oval mitten along the forearm.
|
|
617
|
+
- Presets in `BEAN_CAST` (also in `CHARACTER_CAST`, group `bean`):
|
|
618
|
+
`beanMan`, `beanWoman`, `beanKid`, `beanBoss`, `beanDetective`,
|
|
619
|
+
`beanStick` (bare lines) and `beanSari` (a sari with a pallu and bangles).
|
|
620
|
+
- Helpers for your own layers: `beanTorso(bean, joints)` and
|
|
621
|
+
`beanTorsoOutline(torso)` (the body's shape), `beanLimbLine(root, joint, end)`
|
|
622
|
+
(a limb's centre line), `mittenAt`, `beanShoeAt`, `beanOrder`, `beanOverBody`,
|
|
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).
|
|
628
|
+
|
|
543
629
|
### Young adult manga cast
|
|
544
630
|
|
|
545
631
|
`MANGA_CAST` supplies four original archetypes: `mangaYoungMan`,
|
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
|
@@ -217,6 +217,23 @@ from. The eight presets in `ANIME_CAST` (`animeBoy`, `animeGirl`,
|
|
|
217
217
|
Use `face: { style: 'anime', iris: '#4b7fce', lashes: true, ageLines: 0.6 }`
|
|
218
218
|
for coloured expressive eyes and optional creases; this is a face style,
|
|
219
219
|
not a `look` value. It uses the same expressions, blink, gaze and turn fields.
|
|
220
|
+
White outlined stick figures are `figure: 'bean'` (presets `beanMan`, `beanWoman`,
|
|
221
|
+
`beanKid`, `beanBoss`, `beanDetective`, `beanStick` in `BEAN_CAST`): seamless outlined noodle limbs or bare
|
|
222
|
+
lines (`bean: { limbs: 'tube' | 'line' }`), a shaped body (`bean.torso` fullness), big oval eyes
|
|
223
|
+
(`face.style: 'oval'`, usable on any figure), `hands: 'mitten'` and cartoon shoes; colours from
|
|
224
|
+
`bean: { shirt, sleeves, trousers, shoes }` or an `outfit`; detective gear `bean: { coat, fedora, shades: true }`
|
|
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).
|
|
220
237
|
The `look` values are `clean`, `pencil`, `silhouette` and `illustrated`
|
|
221
238
|
(inked and painted, tuned with `illustrated: { light, weight, taper, shadow, highlight }`).
|
|
222
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
|