@algorisys/tinyfly 0.120.0 → 0.122.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 +13 -6
- package/docs/character-appearance.md +62 -1
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +8 -1
- package/docs/maps.md +2 -2
- package/docs/math.md +26 -4
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +1397 -1342
- package/lib/addons/cricket-play-BRehNToP.js +5506 -0
- package/lib/addons/math.js +1349 -1275
- package/lib/addons/sports.js +1 -1
- package/lib/browser/tinyfly-math.iife.js +4 -4
- package/lib/browser/tinyfly.iife.js +12 -12
- package/lib/browser/tinyfly.js +6500 -6171
- package/lib/browser/tinyfly.umd.js +12 -12
- package/lib/types/characters/body/bean-figure.d.ts +154 -0
- package/lib/types/characters/cast.d.ts +204 -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 +2 -1
- package/lib/types/math/index.d.ts +1 -0
- package/lib/types/math/ml/loss-surface.d.ts +118 -0
- package/llms-full.txt +110 -17
- package/llms.txt +31 -31
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +7 -1
- package/lib/addons/cricket-play-C5CkNOc6.js +0 -5219
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { Point } from '../../adapters/canvas/sketch';
|
|
2
|
+
import type { CharacterJoints } from '../character';
|
|
3
|
+
/**
|
|
4
|
+
* The bean figure (`figure: 'bean'`): the common white outlined stick-figure
|
|
5
|
+
* style. A white figure with a thick black outline, smooth noodle limbs, a
|
|
6
|
+
* shaped body (rounded shoulders, a slight waist, fuller hips), a round head with big oval eyes (`face.style: 'oval'`),
|
|
7
|
+
* white mittens and big cartoon shoes.
|
|
8
|
+
*
|
|
9
|
+
* The rig solves the pose as for every figure (poses, gaits, dances, reaches
|
|
10
|
+
* and turns all work); this module draws the body. Each limb is ONE smooth
|
|
11
|
+
* curve through its joints, stroked in the ink and then stroked again,
|
|
12
|
+
* narrower, in the fill, with round caps and joins, so elbows and knees never
|
|
13
|
+
* show a seam. The front arm joins the body without a seam either: its
|
|
14
|
+
* outline is left out where it lies inside the body near the shoulder, so its
|
|
15
|
+
* fill flows into the body's.
|
|
16
|
+
*
|
|
17
|
+
* `limbs: 'line'` is the bare variant: arms, legs and the neck are single
|
|
18
|
+
* round-capped ink lines (with an optional pale `halo` edge so they read on a
|
|
19
|
+
* dark set); the body, eyes, mittens and shoes stay.
|
|
20
|
+
*
|
|
21
|
+
* Detective gear: a trench `coat` (lapels, a belt and buckle, buttons, a hem
|
|
22
|
+
* at the knee, sleeves to the wrist) and a `fedora` (a brim, a pinched crown
|
|
23
|
+
* and a band). Big dark aviator `shades` are `face.shades` (see face.ts).
|
|
24
|
+
*
|
|
25
|
+
* Painter order: the back arm, the legs and the neck, the body (and the
|
|
26
|
+
* coat), then the near arm and the head (and the fedora). Plain tube legs and
|
|
27
|
+
* neck join the body without a seam, so they come after it.
|
|
28
|
+
*/
|
|
29
|
+
export interface BeanOptions {
|
|
30
|
+
/** `tube` (default): outlined noodles in the fill; `line`: bare ink lines */
|
|
31
|
+
limbs?: 'tube' | 'line';
|
|
32
|
+
/** Body fullness: the half-width at the hips is 0.068 of the height times this (default 1; 1.3 chubby, 0.85 thin) */
|
|
33
|
+
torso?: number;
|
|
34
|
+
/** A tube limb's width (inside the outline), fraction of the height (default 0.024) */
|
|
35
|
+
limbWidth?: number;
|
|
36
|
+
/** A `line` limb's width, fraction of the height (default 0.017) */
|
|
37
|
+
lineWidth?: number;
|
|
38
|
+
/** Outline width, fraction of the height (default 0.0105) */
|
|
39
|
+
outlineWidth?: number;
|
|
40
|
+
/** Body, limbs, mittens and shoes (default white) */
|
|
41
|
+
fill?: string;
|
|
42
|
+
/** A tee in this colour over the body (default none: the plain figure) */
|
|
43
|
+
shirt?: string | null;
|
|
44
|
+
/** The tee's sleeves (default short) */
|
|
45
|
+
sleeves?: 'short' | 'long' | 'none';
|
|
46
|
+
/** Trousers in this colour (default none) */
|
|
47
|
+
trousers?: string | null;
|
|
48
|
+
/** Shoe colour (default the fill); a dark shoe gets a shine and a dark sole */
|
|
49
|
+
shoes?: string;
|
|
50
|
+
/** A pale edge round `line` limbs, so they read on a dark set (default none) */
|
|
51
|
+
halo?: string | null;
|
|
52
|
+
/** A trench coat in this colour, over the body to the knees, sleeves to the wrist (default none) */
|
|
53
|
+
coat?: string | null;
|
|
54
|
+
/** A fedora in this colour on the head (default none) */
|
|
55
|
+
fedora?: string | null;
|
|
56
|
+
/** Big dark aviator shades in place of the eyes, the brows still showing: sets `face.shades` (default false) */
|
|
57
|
+
shades?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface Bean {
|
|
60
|
+
limbs: 'tube' | 'line';
|
|
61
|
+
torso: number;
|
|
62
|
+
limbWidth: number;
|
|
63
|
+
lineWidth: number;
|
|
64
|
+
outlineWidth: number;
|
|
65
|
+
fill: string;
|
|
66
|
+
shirt: string | null;
|
|
67
|
+
sleeves: 'short' | 'long' | 'none';
|
|
68
|
+
trousers: string | null;
|
|
69
|
+
shoes: string;
|
|
70
|
+
halo: string | null;
|
|
71
|
+
coat: string | null;
|
|
72
|
+
fedora: string | null;
|
|
73
|
+
}
|
|
74
|
+
/** Every bean option spelled out (plain data). */
|
|
75
|
+
export declare function resolveBean(options?: BeanOptions): Bean;
|
|
76
|
+
/**
|
|
77
|
+
* The body: rounded shoulders, a slight waist, fuller hips and a rounded
|
|
78
|
+
* seat, along the hip-to-shoulder line. `length` is that line's length,
|
|
79
|
+
* `width` the half-width at the hips (0.068 of the height × `torso`).
|
|
80
|
+
*/
|
|
81
|
+
export interface BeanTorso {
|
|
82
|
+
cx: number;
|
|
83
|
+
cy: number;
|
|
84
|
+
length: number;
|
|
85
|
+
width: number;
|
|
86
|
+
/** The direction from the hips to the shoulders, radians */
|
|
87
|
+
angle: number;
|
|
88
|
+
}
|
|
89
|
+
export declare function beanTorso(bean: Bean, joints: CharacterJoints): BeanTorso;
|
|
90
|
+
/** The body's outline as points in the drawing space (for hit tests and checks). */
|
|
91
|
+
export declare function beanTorsoOutline(t: BeanTorso, samples?: number): Point[];
|
|
92
|
+
/**
|
|
93
|
+
* The bean's drawing order: the back arm, the legs far to near, the neck,
|
|
94
|
+
* the body ('spine'), then any leg reaching well forward (seated thighs),
|
|
95
|
+
* the near arm and any arm reaching forward, and the head. The arm nearer the viewer is the front one; level, the
|
|
96
|
+
* character's left. `reach` is how far each limb's furthest joint comes
|
|
97
|
+
* toward the viewer from its root, px (from the solved skeleton); without
|
|
98
|
+
* it no limb counts as reaching.
|
|
99
|
+
*/
|
|
100
|
+
export declare function beanOrder(bean: Bean, joints: CharacterJoints, reach?: Record<string, number>): string[];
|
|
101
|
+
/** How far toward the viewer (fraction of the height) a hand must reach from its shoulder for the arm to go over the body */
|
|
102
|
+
export declare const BEAN_ARM_REACH = 0.08;
|
|
103
|
+
/** How far toward the viewer a knee or foot must come from its hip for the leg to go over the body (seated, a high kick) */
|
|
104
|
+
export declare const BEAN_LEG_REACH = 0.12;
|
|
105
|
+
/** Whether a part is drawn over the bean's body, by the drawing order in the joints. */
|
|
106
|
+
export declare function beanOverBody(joints: CharacterJoints, id: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* A limb's centre line: through root, joint and end, rounded at the joint (a
|
|
109
|
+
* quadratic that passes through the joint), sampled finely so the strokes
|
|
110
|
+
* stay smooth at any size.
|
|
111
|
+
*/
|
|
112
|
+
export declare function beanLimbLine(root: Point, joint: Point, end: Point, samples?: number): Point[];
|
|
113
|
+
/** A white mitten at the end of a forearm: an oval along it, past the wrist. */
|
|
114
|
+
export declare function mittenAt(elbow: Point, wrist: Point, height: number): {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
rx: number;
|
|
118
|
+
ry: number;
|
|
119
|
+
angle: number;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Where a shoe goes: the ankle's x, the ground under it (the toe's level),
|
|
123
|
+
* which way it points (+1 screen-right), its length, and how far it tips
|
|
124
|
+
* when the foot does (a kick, pointed toes), radians.
|
|
125
|
+
*/
|
|
126
|
+
export declare function beanShoeAt(ankle: Point, toe: Point, height: number, facing: number): {
|
|
127
|
+
x: number;
|
|
128
|
+
ankle: number;
|
|
129
|
+
ground: number;
|
|
130
|
+
dir: number;
|
|
131
|
+
length: number;
|
|
132
|
+
tip: number;
|
|
133
|
+
};
|
|
134
|
+
/** The shoe's sole colour, and a dark shoe's */
|
|
135
|
+
export declare const BEAN_SOLE = "#d6d3d1";
|
|
136
|
+
export declare const BEAN_DARK_SOLE = "#3f3f46";
|
|
137
|
+
/** The fedora's head: what `drawBeanFedora` needs of the solved head. */
|
|
138
|
+
export interface BeanHead {
|
|
139
|
+
center: Point;
|
|
140
|
+
rx: number;
|
|
141
|
+
angle: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A fedora on the head: a wide brim, a pinched crown and a dark band,
|
|
145
|
+
* tilting with the head and sliding a little with `head.turn`.
|
|
146
|
+
*/
|
|
147
|
+
export declare function drawBeanFedora(ctx: CanvasRenderingContext2D, head: BeanHead, color: string, ink: string, outline: number, headTurn?: number): void;
|
|
148
|
+
export interface BeanDrawOptions {
|
|
149
|
+
ink: string;
|
|
150
|
+
/** The hands: `mitten` drawn here; others by the caller */
|
|
151
|
+
hands: 'dot' | 'cartoon' | 'mitten';
|
|
152
|
+
}
|
|
153
|
+
/** Draw one part of a bean figure ('arm.left', 'leg.right', 'neck', 'spine'). */
|
|
154
|
+
export declare function drawBeanPart(ctx: CanvasRenderingContext2D, bean: Bean, joints: CharacterJoints, id: string, options: BeanDrawOptions): void;
|
|
@@ -13,8 +13,8 @@ import type { CharacterOptions } from './character';
|
|
|
13
13
|
export interface CastMember {
|
|
14
14
|
/** What to call them in a picker */
|
|
15
15
|
label: string;
|
|
16
|
-
/** A family, occupation, colour anime
|
|
17
|
-
group: 'family' | 'work' | 'anime' | 'manga';
|
|
16
|
+
/** A family, occupation, colour anime, young adult manga or bean (white outlined stick figure) preset. */
|
|
17
|
+
group: 'family' | 'work' | 'anime' | 'manga' | 'bean';
|
|
18
18
|
/** Height next to an adult (1) */
|
|
19
19
|
scale: number;
|
|
20
20
|
/** Everything else about them */
|
|
@@ -453,7 +453,209 @@ export declare const MANGA_CAST: {
|
|
|
453
453
|
};
|
|
454
454
|
};
|
|
455
455
|
export type MangaCastName = keyof typeof MANGA_CAST;
|
|
456
|
+
/**
|
|
457
|
+
* Bean figures (`figure: 'bean'`): white outlined stick figures with big oval
|
|
458
|
+
* eyes, told apart by hair, glasses, facial hair and a colour or two. Original,
|
|
459
|
+
* generic starting points; every field stays editable.
|
|
460
|
+
*/
|
|
461
|
+
export declare const BEAN_CAST: {
|
|
462
|
+
beanMan: {
|
|
463
|
+
label: string;
|
|
464
|
+
group: "bean";
|
|
465
|
+
scale: number;
|
|
466
|
+
options: {
|
|
467
|
+
figure: "bean";
|
|
468
|
+
hair: {
|
|
469
|
+
style: "short";
|
|
470
|
+
color: string;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
beanWoman: {
|
|
475
|
+
label: string;
|
|
476
|
+
group: "bean";
|
|
477
|
+
scale: number;
|
|
478
|
+
options: {
|
|
479
|
+
figure: "bean";
|
|
480
|
+
hair: {
|
|
481
|
+
style: "bob";
|
|
482
|
+
color: string;
|
|
483
|
+
};
|
|
484
|
+
bean: {
|
|
485
|
+
torso: number;
|
|
486
|
+
};
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
beanKid: {
|
|
490
|
+
label: string;
|
|
491
|
+
group: "bean";
|
|
492
|
+
scale: number;
|
|
493
|
+
options: {
|
|
494
|
+
figure: "bean";
|
|
495
|
+
headSize: number;
|
|
496
|
+
legLength: number;
|
|
497
|
+
armLength: number;
|
|
498
|
+
hair: {
|
|
499
|
+
style: "spiky";
|
|
500
|
+
color: string;
|
|
501
|
+
};
|
|
502
|
+
bean: {
|
|
503
|
+
shirt: string;
|
|
504
|
+
trousers: string;
|
|
505
|
+
torso: number;
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
beanBoss: {
|
|
510
|
+
label: string;
|
|
511
|
+
group: "bean";
|
|
512
|
+
scale: number;
|
|
513
|
+
options: {
|
|
514
|
+
figure: "bean";
|
|
515
|
+
hair: {
|
|
516
|
+
style: "slickBack";
|
|
517
|
+
color: string;
|
|
518
|
+
};
|
|
519
|
+
facialHair: "shortMoustache";
|
|
520
|
+
glasses: "square";
|
|
521
|
+
bean: {
|
|
522
|
+
shirt: string;
|
|
523
|
+
trousers: string;
|
|
524
|
+
sleeves: "long";
|
|
525
|
+
torso: number;
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
beanDetective: {
|
|
530
|
+
label: string;
|
|
531
|
+
group: "bean";
|
|
532
|
+
scale: number;
|
|
533
|
+
options: {
|
|
534
|
+
figure: "bean";
|
|
535
|
+
hair: {
|
|
536
|
+
style: "short";
|
|
537
|
+
color: string;
|
|
538
|
+
};
|
|
539
|
+
bean: {
|
|
540
|
+
coat: string;
|
|
541
|
+
fedora: string;
|
|
542
|
+
shades: true;
|
|
543
|
+
trousers: string;
|
|
544
|
+
shoes: string;
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
};
|
|
548
|
+
beanStick: {
|
|
549
|
+
label: string;
|
|
550
|
+
group: "bean";
|
|
551
|
+
scale: number;
|
|
552
|
+
options: {
|
|
553
|
+
figure: "bean";
|
|
554
|
+
bean: {
|
|
555
|
+
limbs: "line";
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
export type BeanCastName = keyof typeof BEAN_CAST;
|
|
456
561
|
export declare const CHARACTER_CAST: {
|
|
562
|
+
beanMan: {
|
|
563
|
+
label: string;
|
|
564
|
+
group: "bean";
|
|
565
|
+
scale: number;
|
|
566
|
+
options: {
|
|
567
|
+
figure: "bean";
|
|
568
|
+
hair: {
|
|
569
|
+
style: "short";
|
|
570
|
+
color: string;
|
|
571
|
+
};
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
beanWoman: {
|
|
575
|
+
label: string;
|
|
576
|
+
group: "bean";
|
|
577
|
+
scale: number;
|
|
578
|
+
options: {
|
|
579
|
+
figure: "bean";
|
|
580
|
+
hair: {
|
|
581
|
+
style: "bob";
|
|
582
|
+
color: string;
|
|
583
|
+
};
|
|
584
|
+
bean: {
|
|
585
|
+
torso: number;
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
beanKid: {
|
|
590
|
+
label: string;
|
|
591
|
+
group: "bean";
|
|
592
|
+
scale: number;
|
|
593
|
+
options: {
|
|
594
|
+
figure: "bean";
|
|
595
|
+
headSize: number;
|
|
596
|
+
legLength: number;
|
|
597
|
+
armLength: number;
|
|
598
|
+
hair: {
|
|
599
|
+
style: "spiky";
|
|
600
|
+
color: string;
|
|
601
|
+
};
|
|
602
|
+
bean: {
|
|
603
|
+
shirt: string;
|
|
604
|
+
trousers: string;
|
|
605
|
+
torso: number;
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
beanBoss: {
|
|
610
|
+
label: string;
|
|
611
|
+
group: "bean";
|
|
612
|
+
scale: number;
|
|
613
|
+
options: {
|
|
614
|
+
figure: "bean";
|
|
615
|
+
hair: {
|
|
616
|
+
style: "slickBack";
|
|
617
|
+
color: string;
|
|
618
|
+
};
|
|
619
|
+
facialHair: "shortMoustache";
|
|
620
|
+
glasses: "square";
|
|
621
|
+
bean: {
|
|
622
|
+
shirt: string;
|
|
623
|
+
trousers: string;
|
|
624
|
+
sleeves: "long";
|
|
625
|
+
torso: number;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
beanDetective: {
|
|
630
|
+
label: string;
|
|
631
|
+
group: "bean";
|
|
632
|
+
scale: number;
|
|
633
|
+
options: {
|
|
634
|
+
figure: "bean";
|
|
635
|
+
hair: {
|
|
636
|
+
style: "short";
|
|
637
|
+
color: string;
|
|
638
|
+
};
|
|
639
|
+
bean: {
|
|
640
|
+
coat: string;
|
|
641
|
+
fedora: string;
|
|
642
|
+
shades: true;
|
|
643
|
+
trousers: string;
|
|
644
|
+
shoes: string;
|
|
645
|
+
};
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
beanStick: {
|
|
649
|
+
label: string;
|
|
650
|
+
group: "bean";
|
|
651
|
+
scale: number;
|
|
652
|
+
options: {
|
|
653
|
+
figure: "bean";
|
|
654
|
+
bean: {
|
|
655
|
+
limbs: "line";
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
};
|
|
457
659
|
mangaYoungMan: {
|
|
458
660
|
label: string;
|
|
459
661
|
group: "manga";
|
|
@@ -16,6 +16,7 @@ import { type BasicOutfitOptions } from './wardrobe/basic-outfit';
|
|
|
16
16
|
import { type LeafOutfitOptions } from './wardrobe/leaf-outfit';
|
|
17
17
|
import { type Holding, type HoldingSpec } from './hands/held-items';
|
|
18
18
|
import { type HandPose } from './hands/hand-rig';
|
|
19
|
+
import { type Bean, type BeanOptions } from './body/bean-figure';
|
|
19
20
|
/**
|
|
20
21
|
* Characters (v2): any body plan, posed by numbers, turned in 3D, drawn flat
|
|
21
22
|
* in a look (clean, pencil, silhouette) and a figure style (fluid, stick).
|
|
@@ -23,8 +24,12 @@ import { type HandPose } from './hands/hand-rig';
|
|
|
23
24
|
* The v1 stick figure (`stickFigureTarget`, `drawStickFigure`) is separate
|
|
24
25
|
* and unchanged. See docs/character-system-m1.md.
|
|
25
26
|
*/
|
|
26
|
-
/**
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* `stick`: traditional stick figure; `fluid`: tapered limbs; `organic`: filled
|
|
29
|
+
* cartoon anatomy; `bean`: the white outlined figure (smooth outlined noodle
|
|
30
|
+
* limbs or bare lines, a shaped body, big oval eyes, mittens, cartoon shoes).
|
|
31
|
+
*/
|
|
32
|
+
export type FigureStyle = 'fluid' | 'stick' | 'organic' | 'bean';
|
|
28
33
|
/**
|
|
29
34
|
* Draws part of a character: clothes, hair, a prop. The context is in the
|
|
30
35
|
* character's drawing space (feet at 0, 0), saved and restored around the
|
|
@@ -61,6 +66,14 @@ export interface CharacterOptions extends HeadLookOptions {
|
|
|
61
66
|
/** What each hand holds (`{ right: 'mug' }`, `{ both: 'parcel' }`); a pose field `held.<side>` below 0.5 lets go */
|
|
62
67
|
holding?: HoldingSpec | null;
|
|
63
68
|
figure?: FigureStyle;
|
|
69
|
+
/**
|
|
70
|
+
* The bean figure's options (`figure: 'bean'`): `limbs` (tube | line),
|
|
71
|
+
* `torso` fullness, `limbWidth`, `lineWidth`, `outlineWidth` (fractions of
|
|
72
|
+
* the height), `fill`, a `shirt` colour with `sleeves`, `trousers`, `shoes`,
|
|
73
|
+
* a `halo` for line limbs, and detective gear: `coat`, `fedora`, `shades`.
|
|
74
|
+
* An `outfit`'s shirt, trousers and sleeves colour it too.
|
|
75
|
+
*/
|
|
76
|
+
bean?: BeanOptions;
|
|
64
77
|
/** Opt-in organic contours, skin material and independent outline settings. */
|
|
65
78
|
body?: OrganicBodyOptions;
|
|
66
79
|
look?: Look;
|
|
@@ -92,9 +105,10 @@ export interface CharacterOptions extends HeadLookOptions {
|
|
|
92
105
|
* Hands on the fluid figure: `dot` (default) a round end to each arm,
|
|
93
106
|
* `cartoon` posed cartoon hands (gloved in `skin`), shaped by the pose's
|
|
94
107
|
* `hand.left.*` / `hand.right.*` fields (any field of a hand pose, e.g.
|
|
95
|
-
* `hand.right.index.curl`; see {@link characterHandPose})
|
|
108
|
+
* `hand.right.index.curl`; see {@link characterHandPose}), `mitten` a
|
|
109
|
+
* plain oval mitten in `skin` (the bean figure's default)
|
|
96
110
|
*/
|
|
97
|
-
hands?: 'dot' | 'cartoon';
|
|
111
|
+
hands?: 'dot' | 'cartoon' | 'mitten';
|
|
98
112
|
/**
|
|
99
113
|
* Cartoon hands as `glove` (default: a thumb and three plump fingers, the
|
|
100
114
|
* classic cartoon glove) or `natural` (five slimmer fingers, so shapes like
|
|
@@ -113,6 +127,8 @@ export interface Character {
|
|
|
113
127
|
plan: BodyPlan;
|
|
114
128
|
figure: FigureStyle;
|
|
115
129
|
body?: OrganicBody;
|
|
130
|
+
/** The bean figure's resolved options (bean only) */
|
|
131
|
+
bean?: Bean;
|
|
116
132
|
look: Look;
|
|
117
133
|
illustrated: ResolvedIllustration;
|
|
118
134
|
height: number;
|
|
@@ -123,7 +139,7 @@ export interface Character {
|
|
|
123
139
|
pencil: PencilOptions;
|
|
124
140
|
layers: CharacterLayers;
|
|
125
141
|
contact: 'ground' | 'none';
|
|
126
|
-
hands: 'dot' | 'cartoon';
|
|
142
|
+
hands: 'dot' | 'cartoon' | 'mitten';
|
|
127
143
|
handStyle: 'glove' | 'natural';
|
|
128
144
|
handSize: number;
|
|
129
145
|
/** Hair, facial hair, glasses, a hat and ears: every choice spelled out, so a saved character never changes when a preset does */
|
|
@@ -25,8 +25,12 @@ export interface PupilCircle {
|
|
|
25
25
|
export interface FaceOptions {
|
|
26
26
|
/** `cartoon` keeps the classic face slide; `volume` follows the head's 3D axes (organic default). */
|
|
27
27
|
projection?: 'cartoon' | 'volume';
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* `simple` (default), colour `anime` eyes with irises, highlights and
|
|
30
|
+
* expressive lids, or big white `oval` eyes with small pupils and heavy
|
|
31
|
+
* brows (the bean figure's). Each uses the same pose fields.
|
|
32
|
+
*/
|
|
33
|
+
style?: 'simple' | 'anime' | 'oval';
|
|
30
34
|
/** Anime iris colour (default blue); plain data, including in scene JSON. */
|
|
31
35
|
iris?: string;
|
|
32
36
|
/** Head outline: round (default) or angular cheeks, jaw and chin. */
|
|
@@ -49,6 +53,8 @@ export interface FaceOptions {
|
|
|
49
53
|
tongue?: boolean;
|
|
50
54
|
/** A small nose between the eyes and the mouth (default none) */
|
|
51
55
|
nose?: boolean;
|
|
56
|
+
/** Big dark aviator lenses in place of the eyes, the brows still showing (`style: 'oval'`; default none) */
|
|
57
|
+
shades?: boolean;
|
|
52
58
|
/** The head's fill, for lids that cover the eye (default white) */
|
|
53
59
|
skin?: string;
|
|
54
60
|
/**
|
|
@@ -59,3 +65,17 @@ export interface FaceOptions {
|
|
|
59
65
|
inPupil?: (ctx: CanvasRenderingContext2D, pupil: PupilCircle) => void;
|
|
60
66
|
}
|
|
61
67
|
export declare function drawFace(pen: Pen, head: SolvedHead, pose: Pose, lineWidth: number, options?: FaceOptions, ctx?: CanvasRenderingContext2D): void;
|
|
68
|
+
/**
|
|
69
|
+
* Big oval eyes (`style: 'oval'`, the bean figure's): a tall white oval per
|
|
70
|
+
* eye, the two almost touching, with a small black pupil that follows the
|
|
71
|
+
* gaze, upper lids in the skin that lower with `lid` or a half-shut eye, and
|
|
72
|
+
* a heavy straight brow above each that `brow.*` raises and `browTilt` slants.
|
|
73
|
+
* Shut (a blink, a laugh) it is a lid line. All in head coordinates, so it
|
|
74
|
+
* turns with the head.
|
|
75
|
+
*/
|
|
76
|
+
export declare const OVAL_EYE: {
|
|
77
|
+
readonly x: 0.31;
|
|
78
|
+
readonly y: 0.12;
|
|
79
|
+
readonly rx: 0.29;
|
|
80
|
+
readonly ry: 0.44;
|
|
81
|
+
};
|
|
@@ -33,7 +33,8 @@ export { resolveOrganicBody, bodyProfileWidth, type OrganicBody, type OrganicBod
|
|
|
33
33
|
export { organicBodyContours, organicCenterLine, type OrganicBodyContours, type OrganicContour, type OrganicSample } from './body/organic-geometry';
|
|
34
34
|
export { BODY_SHAPES, bodyShapeProfiles, measuredHipWidth, resolveMeasurements, type BodyMeasurements, type BodyShapeName, type BodyShapeProfiles } from './body/body-shape';
|
|
35
35
|
export { humanPlan, humanPose, mirrorHumanPose, humanFieldLabel, HUMAN_REST, HUMAN_POSES, HUMAN_EXPRESSIONS, HUMAN_BUILDS, FOOT_SHAPES, type FootShape, type HumanBuild, type HumanBuildName, type HumanPoseName, type HumanExpressionName } from './species/human';
|
|
36
|
-
export { CHARACTER_CAST, ANIME_CAST, MANGA_CAST, castMember, type CastMember, type CastName, type AnimeCastName, type MangaCastName } from './cast';
|
|
36
|
+
export { CHARACTER_CAST, ANIME_CAST, MANGA_CAST, BEAN_CAST, castMember, type CastMember, type CastName, type AnimeCastName, type MangaCastName, type BeanCastName } from './cast';
|
|
37
|
+
export { resolveBean, beanTorso, beanTorsoOutline, beanOrder, beanOverBody, beanLimbLine, mittenAt, beanShoeAt, drawBeanFedora, BEAN_ARM_REACH, BEAN_LEG_REACH, BEAN_SOLE, BEAN_DARK_SOLE, type Bean, type BeanOptions, type BeanTorso } from './body/bean-figure';
|
|
37
38
|
export type { FaceOptions, PupilCircle } from './head/face';
|
|
38
39
|
export { meetHands, meetingSpacing, HAND_MEETINGS, embrace, embraceSpacing, EMBRACE, helpUp, helpUpSpacing, HELP_UP, type HandMeeting, type HandsMeet, type MeetingPartner, type MeetHandsOptions, type Embrace, type EmbraceOptions, type HelpUp, type HelpUpOptions } from './interactions';
|
|
39
40
|
export * from './species/human-motion';
|
|
@@ -29,6 +29,7 @@ export { descentPath, surface } from './ml/descent';
|
|
|
29
29
|
export { blobs, trainLogistic, predict, accuracy, logLoss, type LogisticModel } from './ml/classify';
|
|
30
30
|
export { kmeansHistory, assign, inertia } from './ml/kmeans';
|
|
31
31
|
export { colorAt, blendOver, COLORMAPS, type Colormap } from './ml/colormap';
|
|
32
|
+
export { lossSurface3D, type LossSurface3D, type LossSurfaceOptions, type LossSurfaceScene, type LossSceneObject } from './ml/loss-surface';
|
|
32
33
|
export { parseTex, TexError, TEX_COMMANDS, SYMBOLS, type TexNode, type TexClass } from './tex/tex-parser';
|
|
33
34
|
export { layoutTex, type TexLayout, type TexPiece, type TexGlyph, type TexRule, type TexStroke, type TexLayoutOptions } from './tex/tex-layout';
|
|
34
35
|
export { morphEquation, type MorphPiece, type PlacedLayout } from './tex/equation-morph';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Track } from '../../engine/types';
|
|
2
|
+
import type { Vec2 } from '../linear/vec2';
|
|
3
|
+
import { type Colormap } from './colormap';
|
|
4
|
+
/**
|
|
5
|
+
* A loss surface in 3D, as plain scene JSON for `@algorisys/tinyfly/scene-3d`:
|
|
6
|
+
* f(x, y) as a coloured mesh, a ball rolling down it by gradient descent
|
|
7
|
+
* (the same exact-gradient path the 2D `descent` item draws), the path
|
|
8
|
+
* appearing behind it, and an optional slow camera orbit.
|
|
9
|
+
*
|
|
10
|
+
* const loss = lossSurface3D({ expr: '(x^2 + 3 y^2) / 4', start: [-2.6, 1.8], rate: 0.25 })
|
|
11
|
+
* const scene = loadScene3D(loss.scene) // from @algorisys/tinyfly/scene-3d
|
|
12
|
+
* const timeline = new Timeline({ id: 'loss', config: { duration: loss.duration }, tracks: loss.tracks })
|
|
13
|
+
* drawScene3D(ctx, scene, timeline.getStateAtTime(t).values, { width, height })
|
|
14
|
+
*
|
|
15
|
+
* The maths module does not import scene-3d: the scene is data in its
|
|
16
|
+
* format (metres, y up), so it loads anywhere scene-3d does, Node included.
|
|
17
|
+
* Pure: the same options always give the same scene and tracks.
|
|
18
|
+
*/
|
|
19
|
+
export interface LossSurfaceOptions {
|
|
20
|
+
/** f(x, y), an expression (number values come from `scope`) */
|
|
21
|
+
expr: string;
|
|
22
|
+
/** The x and y ranges shown (default [[-3, 3], [-3, 3]]) */
|
|
23
|
+
region?: [[number, number], [number, number]];
|
|
24
|
+
/** Grid cells per side (default 36) */
|
|
25
|
+
resolution?: number;
|
|
26
|
+
/** Height of the highest point above the lowest, metres (default 1.6); the region spans 5 m */
|
|
27
|
+
height?: number;
|
|
28
|
+
/** Where descent starts, and its rate and momentum */
|
|
29
|
+
start: Vec2;
|
|
30
|
+
rate: number;
|
|
31
|
+
momentum?: number;
|
|
32
|
+
/** Steps taken (default 40) and how long each takes, ms (default 250) */
|
|
33
|
+
steps?: number;
|
|
34
|
+
stepDuration?: number;
|
|
35
|
+
/** Degrees the camera turns round the surface over the whole run (default 50; 0 for a fixed camera) */
|
|
36
|
+
orbit?: number;
|
|
37
|
+
colormap?: Colormap;
|
|
38
|
+
/** Scene id: tracks address objects as `<id>/<object>` (default `loss`) */
|
|
39
|
+
id?: string;
|
|
40
|
+
background?: string;
|
|
41
|
+
scope?: Record<string, number>;
|
|
42
|
+
}
|
|
43
|
+
type Vec3 = [number, number, number];
|
|
44
|
+
/** The scene objects this builds, in scene-3d's format. */
|
|
45
|
+
export type LossSceneObject = {
|
|
46
|
+
id: string;
|
|
47
|
+
kind: 'group';
|
|
48
|
+
position?: Vec3;
|
|
49
|
+
rotation?: Vec3;
|
|
50
|
+
} | {
|
|
51
|
+
id: string;
|
|
52
|
+
kind: 'camera';
|
|
53
|
+
parent?: string;
|
|
54
|
+
projection: 'perspective';
|
|
55
|
+
fov: number;
|
|
56
|
+
near: number;
|
|
57
|
+
far: number;
|
|
58
|
+
position: Vec3;
|
|
59
|
+
lookAt: Vec3;
|
|
60
|
+
} | {
|
|
61
|
+
id: string;
|
|
62
|
+
kind: 'light';
|
|
63
|
+
light: 'ambient' | 'directional';
|
|
64
|
+
color: string;
|
|
65
|
+
intensity: number;
|
|
66
|
+
position?: Vec3;
|
|
67
|
+
} | {
|
|
68
|
+
id: string;
|
|
69
|
+
kind: 'mesh';
|
|
70
|
+
material: string;
|
|
71
|
+
position?: Vec3;
|
|
72
|
+
geometry: {
|
|
73
|
+
type: 'mesh';
|
|
74
|
+
positions: number[];
|
|
75
|
+
indices: number[];
|
|
76
|
+
colors: string[];
|
|
77
|
+
} | {
|
|
78
|
+
type: 'sphere';
|
|
79
|
+
radius: number;
|
|
80
|
+
segments?: number;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
id: string;
|
|
84
|
+
kind: 'line';
|
|
85
|
+
points: Vec3[];
|
|
86
|
+
color: string;
|
|
87
|
+
width?: number;
|
|
88
|
+
visible?: boolean;
|
|
89
|
+
};
|
|
90
|
+
export interface LossSurfaceScene {
|
|
91
|
+
id: string;
|
|
92
|
+
camera: string;
|
|
93
|
+
background: string;
|
|
94
|
+
materials: Record<string, {
|
|
95
|
+
color: string;
|
|
96
|
+
shading?: 'unlit' | 'flat' | 'lambert' | 'toon';
|
|
97
|
+
doubleSided?: boolean;
|
|
98
|
+
creases?: boolean;
|
|
99
|
+
outline?: {
|
|
100
|
+
width: number;
|
|
101
|
+
color: string;
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
104
|
+
objects: LossSceneObject[];
|
|
105
|
+
}
|
|
106
|
+
export interface LossSurface3D {
|
|
107
|
+
scene: LossSurfaceScene;
|
|
108
|
+
/** The ball's position, the path appearing, the camera's orbit */
|
|
109
|
+
tracks: Track[];
|
|
110
|
+
/** ms, until the ball has finished */
|
|
111
|
+
duration: number;
|
|
112
|
+
/** The descent path in the function's own (x, y) */
|
|
113
|
+
path: Vec2[];
|
|
114
|
+
/** f along the path */
|
|
115
|
+
losses: number[];
|
|
116
|
+
}
|
|
117
|
+
export declare function lossSurface3D(options: LossSurfaceOptions): LossSurface3D;
|
|
118
|
+
export {};
|