open-bot-avatar 0.2.1 → 0.3.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 +25 -6
- package/dist/animator.d.ts +9 -4
- package/dist/animator.d.ts.map +1 -1
- package/dist/animator.js +32 -17
- package/dist/animator.js.map +1 -1
- package/dist/color.d.ts +4 -0
- package/dist/color.d.ts.map +1 -1
- package/dist/color.js +45 -0
- package/dist/color.js.map +1 -1
- package/dist/dom/mount.d.ts +8 -2
- package/dist/dom/mount.d.ts.map +1 -1
- package/dist/dom/mount.js +29 -8
- package/dist/dom/mount.js.map +1 -1
- package/dist/dom/paint.d.ts.map +1 -1
- package/dist/dom/paint.js +18 -5
- package/dist/dom/paint.js.map +1 -1
- package/dist/effects.d.ts +82 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/effects.js +352 -0
- package/dist/effects.js.map +1 -0
- package/dist/eyes.d.ts +29 -0
- package/dist/eyes.d.ts.map +1 -0
- package/dist/eyes.js +128 -0
- package/dist/eyes.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mood.d.ts +10 -5
- package/dist/mood.d.ts.map +1 -1
- package/dist/mood.js +3 -2
- package/dist/mood.js.map +1 -1
- package/dist/motion.d.ts +63 -10
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +239 -41
- package/dist/motion.js.map +1 -1
- package/dist/render.d.ts +68 -4
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +265 -34
- package/dist/render.js.map +1 -1
- package/dist/types.d.ts +35 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/animator.ts +40 -20
- package/src/color.ts +48 -0
- package/src/dom/mount.ts +38 -11
- package/src/dom/paint.ts +17 -5
- package/src/effects.ts +405 -0
- package/src/eyes.ts +157 -0
- package/src/index.ts +3 -3
- package/src/mood.ts +13 -7
- package/src/motion.ts +270 -48
- package/src/render.ts +335 -42
- package/src/types.ts +42 -7
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Bounds, Point } from './path.ts';
|
|
2
|
+
export interface Box {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
}
|
|
8
|
+
/** One piece of a ribbon: the part of it in front of the body, or the part behind. */
|
|
9
|
+
export interface RibbonPiece {
|
|
10
|
+
d: string;
|
|
11
|
+
front: boolean;
|
|
12
|
+
box: Box;
|
|
13
|
+
/**
|
|
14
|
+
* Which ribbon the piece belongs to. In a celebration, 0..8: hoop `ribbon / LANES`, lane
|
|
15
|
+
* `ribbon % LANES` (from the inner ring out). A working turn has one hoop with three to five
|
|
16
|
+
* ribbons, numbered 0..4 from the inner ring out.
|
|
17
|
+
*/
|
|
18
|
+
ribbon: number;
|
|
19
|
+
/**
|
|
20
|
+
* The stretch of its ribbon the piece covers, 0 (tail) to 1 (head), and the centre of the
|
|
21
|
+
* ribbon at either end of that stretch, for a gradient along it. A ribbon comes in a few
|
|
22
|
+
* stretches, each a little past the next where they meet so no seam shows.
|
|
23
|
+
*/
|
|
24
|
+
along: [number, number];
|
|
25
|
+
from: [number, number];
|
|
26
|
+
to: [number, number];
|
|
27
|
+
}
|
|
28
|
+
/** Where a body's hoops are centred, and how far the body reaches from there (see rimOf). */
|
|
29
|
+
export interface Rim {
|
|
30
|
+
cx: number;
|
|
31
|
+
cy: number;
|
|
32
|
+
at: (angle: number) => number;
|
|
33
|
+
max: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function rimOf(outlines: Point[][][], cx: number, cy: number): Rim;
|
|
36
|
+
export declare const LANES = 3;
|
|
37
|
+
export declare const HOOPS = 3;
|
|
38
|
+
/**
|
|
39
|
+
* The radius of the farthest ring a ribbon can ride round a body whose outline reaches `rimMax`
|
|
40
|
+
* from its centre at most, the widest a ribbon gets, and how far a ribbon reaches out from its
|
|
41
|
+
* ring (half that). Widths are the same for every avatar; the rings follow its outline.
|
|
42
|
+
*/
|
|
43
|
+
export declare function ribbonReach(rimMax?: number): {
|
|
44
|
+
radius: number;
|
|
45
|
+
width: number;
|
|
46
|
+
band: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The ribbons at one moment, as filled outlines: round at both ends, a little narrower at the
|
|
50
|
+
* tail than at the head and narrower behind the body, and split where a ribbon passes from
|
|
51
|
+
* behind the body to in front of it. `presence` 0..1 draws them out and back in. `cage` picks
|
|
52
|
+
* the layout: a working turn's 3 to 5 ribbons on one hoop (below 0.5), or a celebration's three
|
|
53
|
+
* on each of three hoops. `sweep` (radians, signed) is how far the body's turn has carried
|
|
54
|
+
* them; between turns they are not drawn. Each ribbon narrows where its hoop curves tighter than
|
|
55
|
+
* half its width, so its outline never folds over itself. `rim` gives the hoops' centre (the
|
|
56
|
+
* middle of the body's mass) and how far the body reaches from it along a direction: a working
|
|
57
|
+
* turn's hoop stands just outside the body along its own direction; a celebration's three share
|
|
58
|
+
* one radius, the largest any of them needs, so the cage stays round. Either way the ribbons pass
|
|
59
|
+
* behind the body only off its outline.
|
|
60
|
+
*/
|
|
61
|
+
export declare function ribbonPieces(b: Bounds, presence: number, seed: number, _time: number, sweep?: number, cage?: number, rim?: Rim): RibbonPiece[];
|
|
62
|
+
/** One part of a mark: a fixed outline about its own centre, and where that centre is this frame. */
|
|
63
|
+
export interface MarkPart {
|
|
64
|
+
/** Stable name of the outline, e.g. "dot". */
|
|
65
|
+
shape: string;
|
|
66
|
+
d: string;
|
|
67
|
+
box: Box;
|
|
68
|
+
/** Centre, viewBox units, then a rotation about the mark's centre (radians) and a scale about the part's own. */
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
turn: number;
|
|
72
|
+
scale: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The parts of the marks at one moment. `bang` and `dots` 0..1 are how far the body has given
|
|
76
|
+
* way to each (see Pose): a mark grows in as the body goes, from the body's centre.
|
|
77
|
+
* The dots take turns hopping; the exclamation mark jumps and shakes every couple of seconds.
|
|
78
|
+
*/
|
|
79
|
+
export declare function markParts(b: Bounds, bang: number, dots: number, seed: number, time: number, still: boolean): MarkPart[];
|
|
80
|
+
/** How much of its size the body keeps while it gives way to a mark: gone a little past half way. */
|
|
81
|
+
export declare function bodyScale(bang: number, dots: number): number;
|
|
82
|
+
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAU/C,MAAM,WAAW,GAAG;IAAG,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE;AAKnE,sFAAsF;AACtF,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,GAAG,CAAC;IACT;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtB;AA4DD,6FAA6F;AAC7F,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;CACb;AACD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAA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
|
3
|
+
* thinking or blocked bot turns into (three dots, an exclamation mark). Pure geometry in viewBox
|
|
4
|
+
* units, from the body's bounds, a seed and the animation clock.
|
|
5
|
+
*/
|
|
6
|
+
import { noise } from './motion.js';
|
|
7
|
+
const TAU = Math.PI * 2;
|
|
8
|
+
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
9
|
+
const smooth = (u) => { const x = clamp(u, 0, 1); return x * x * (3 - 2 * x); };
|
|
10
|
+
const f = (n) => {
|
|
11
|
+
const r = Math.round(n * 100) / 100;
|
|
12
|
+
return (Object.is(r, -0) ? 0 : r).toString();
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The ribbons ride hoops round the body's centre, laid out as PR #14 measured them from the
|
|
16
|
+
* Grok Bot demo, at one size for every avatar. Lengths are in design units: the demo's
|
|
17
|
+
* 228.541-unit space, which its bot fills; here that space is a body of the typical size,
|
|
18
|
+
* BODY units across, so one design unit is BODY / DESIGN avatar units whatever the avatar.
|
|
19
|
+
*
|
|
20
|
+
* A hoop is a ring of radius RING tipped HOOP_TILT out of the screen, so it shows as a flat ellipse, and
|
|
21
|
+
* rolled in the picture. Its near side is the top: a ribbon crosses in front of the body along
|
|
22
|
+
* the top and behind it along the bottom. A working bot uses one hoop, rolled HOOP_ROLL; a
|
|
23
|
+
* celebration three, each a third of a half turn further round, so they cross into a cage.
|
|
24
|
+
*
|
|
25
|
+
* Each hoop carries LANES ribbons on rings LADDER units apart in all, outward from its ring.
|
|
26
|
+
* A ribbon starts at the top of its hoop and goes round with the body's turn (`sweep`), each at
|
|
27
|
+
* its own share of it (FOLLOW) plus a drift of its own (DRIFT), so the ribbons on one hoop part
|
|
28
|
+
* as they go; its ring widens as it goes (WIDEN), and its tail trails up to ARC behind its head.
|
|
29
|
+
*/
|
|
30
|
+
const DESIGN = 228.541;
|
|
31
|
+
/** The typical body across its larger side (the median of the starters and gallery). */
|
|
32
|
+
const BODY = 80;
|
|
33
|
+
const UNIT = BODY / DESIGN;
|
|
34
|
+
/**
|
|
35
|
+
* A hoop's inner ring stands this far outside the body along the hoop's own direction: the hoop's
|
|
36
|
+
* sides, where its ribbons pass behind the body, lie just off the outline (the inner ribbon's
|
|
37
|
+
* edge included), whatever the shape. RING is the typical body's (half its widest row, 38.8,
|
|
38
|
+
* the median of the starters and gallery, × 116/114.27), for callers that give no outline.
|
|
39
|
+
*/
|
|
40
|
+
const RIM_MARGIN = 2;
|
|
41
|
+
const RING = 38.8 * (116 / 114.2705);
|
|
42
|
+
/**
|
|
43
|
+
* How far `outlines` (the body in each pose it takes) reach from (cx, cy): `at` along a direction
|
|
44
|
+
* (radians), either way, worked out exactly each time it is asked (a hoop asks once a frame, along
|
|
45
|
+
* its own roll); `max` the farthest over all directions, from RIM_STEPS samples over a half turn.
|
|
46
|
+
*/
|
|
47
|
+
const RIM_STEPS = 180;
|
|
48
|
+
/** How far `outlines` reach from (cx, cy) along a direction (radians), either way, exactly. */
|
|
49
|
+
function reachAlong(outlines, cx, cy, a) {
|
|
50
|
+
const ux = Math.cos(a), uy = Math.sin(a);
|
|
51
|
+
let far = 0;
|
|
52
|
+
for (const poly of outlines.flat()) {
|
|
53
|
+
for (let i = 0; i < poly.length; i++) {
|
|
54
|
+
const [x1, y1] = poly[i], [x2, y2] = poly[(i + 1) % poly.length];
|
|
55
|
+
const ex = x2 - x1, ey = y2 - y1, den = ux * ey - uy * ex;
|
|
56
|
+
if (Math.abs(den) < 1e-12)
|
|
57
|
+
continue;
|
|
58
|
+
// Where the line through the centre crosses this edge: t along the line, s along the edge.
|
|
59
|
+
const t = ((x1 - cx) * ey - (y1 - cy) * ex) / den, s = ((x1 - cx) * uy - (y1 - cy) * ux) / den;
|
|
60
|
+
if (s >= 0 && s <= 1)
|
|
61
|
+
far = Math.max(far, Math.abs(t));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return far;
|
|
65
|
+
}
|
|
66
|
+
/** How each hoop is rolled in the picture, for an avatar's seed: hoop 0 is a working turn's. */
|
|
67
|
+
function hoopRolls(seed) {
|
|
68
|
+
return Array.from({ length: HOOPS }, (_, i) => HOOP_ROLL + (i * Math.PI) / HOOPS + (noise(seed, 450 + i) - 0.5) * HOOP_JITTER);
|
|
69
|
+
}
|
|
70
|
+
export function rimOf(outlines, cx, cy) {
|
|
71
|
+
const at = (angle) => reachAlong(outlines, cx, cy, angle);
|
|
72
|
+
const steps = Array.from({ length: RIM_STEPS }, (_, k) => at((k * Math.PI) / RIM_STEPS));
|
|
73
|
+
// A spike between two samples can reach a little further than either: allow for a degree's sweep.
|
|
74
|
+
return { cx, cy, at, max: Math.max(...steps) * 1.02 };
|
|
75
|
+
}
|
|
76
|
+
const HOOP_TILT = 0.386;
|
|
77
|
+
const HOOP_ROLL = 0.157;
|
|
78
|
+
/** A hoop's roll jitter (full range, radians). */
|
|
79
|
+
const HOOP_JITTER = 0.24;
|
|
80
|
+
/**
|
|
81
|
+
* A hoop's tilt jitter. The ribbons on one hoop share its roll and tilt exactly: they overlap
|
|
82
|
+
* side by side, and only on one plane do they all pass behind the body along the same line, so
|
|
83
|
+
* which of them lies on top never flips where they do.
|
|
84
|
+
*/
|
|
85
|
+
const HOOP_TILT_JITTER = 0.08;
|
|
86
|
+
const LADDER = 38;
|
|
87
|
+
const ARC = [2.2, 3.4];
|
|
88
|
+
const FOLLOW = [0.74, 0.94];
|
|
89
|
+
/** Radians per second a ribbon drifts on by itself, and design units per second its ring widens. */
|
|
90
|
+
const DRIFT = [0.5, 1.1];
|
|
91
|
+
const WIDEN = 2.5;
|
|
92
|
+
/** How far behind the turn a ribbon starts, at most (radians). */
|
|
93
|
+
const START = 0.18;
|
|
94
|
+
/**
|
|
95
|
+
* A ribbon's width: a size per ribbon (design units; wider when there are only three, narrower
|
|
96
|
+
* among nine), times BRUSH. It narrows to FAR of that while its head is behind the body, is never
|
|
97
|
+
* wider than a third of its own length on screen, and runs from half that width at its tail to
|
|
98
|
+
* the full width at its head, round at both ends. It grows in over GROW_S and thins as it draws back in.
|
|
99
|
+
*/
|
|
100
|
+
const SIZE_FEW = [8, 10.5];
|
|
101
|
+
const SIZE_FOUR = [6.6, 8.6];
|
|
102
|
+
const SIZE_MANY = [5.6, 7.4];
|
|
103
|
+
/** A working turn lets out three to five ribbons on its one hoop (per avatar); a celebration three on each. */
|
|
104
|
+
const WORK_LANES = [3, 5];
|
|
105
|
+
const sizeFor = (count) => (count <= 3 ? SIZE_FEW : count === 4 ? SIZE_FOUR : SIZE_MANY);
|
|
106
|
+
const BRUSH = 1.7 * 1.98;
|
|
107
|
+
const FAR = 0.72;
|
|
108
|
+
const GROW_S = 0.34;
|
|
109
|
+
/** The ribbons on a turn are let out one after another, this long apart (seconds). */
|
|
110
|
+
const STAGGER = [0.055, 0.105];
|
|
111
|
+
/**
|
|
112
|
+
* How fast the sweep goes on average (radians per second), working and celebrating: the drift
|
|
113
|
+
* and widening are timed against it, so a ribbon is placed from the sweep alone.
|
|
114
|
+
*/
|
|
115
|
+
const SWEEP_RATE = [6.3, 15];
|
|
116
|
+
/** The longest a sweep lasts, seconds: the widening is bounded by it. */
|
|
117
|
+
const SWEEP_LONGEST = 4;
|
|
118
|
+
export const LANES = 3;
|
|
119
|
+
export const HOOPS = 3;
|
|
120
|
+
const SAMPLES = 24;
|
|
121
|
+
/** A ribbon is cut into stretches this many samples long, each with a gradient of its own, so its colour follows its length even where it curves round. */
|
|
122
|
+
const STRETCH = 6;
|
|
123
|
+
/** How far either side of a layer change a ribbon is sampled, radians: the piece behind runs this far on under the piece in front. */
|
|
124
|
+
const SLIVER = 0.02;
|
|
125
|
+
/** Points on each round end of a ribbon. */
|
|
126
|
+
const CAP = 7;
|
|
127
|
+
const mix = (range, u) => range[0] + (range[1] - range[0]) * u;
|
|
128
|
+
/**
|
|
129
|
+
* The radius of the farthest ring a ribbon can ride round a body whose outline reaches `rimMax`
|
|
130
|
+
* from its centre at most, the widest a ribbon gets, and how far a ribbon reaches out from its
|
|
131
|
+
* ring (half that). Widths are the same for every avatar; the rings follow its outline.
|
|
132
|
+
*/
|
|
133
|
+
export function ribbonReach(rimMax) {
|
|
134
|
+
const width = SIZE_FEW[1] * BRUSH * UNIT;
|
|
135
|
+
const ring = rimMax === undefined ? RING : rimMax + RIM_MARGIN;
|
|
136
|
+
return { radius: ring + (LADDER + WIDEN * SWEEP_LONGEST) * UNIT, width, band: width / 2 };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The ribbons at one moment, as filled outlines: round at both ends, a little narrower at the
|
|
140
|
+
* tail than at the head and narrower behind the body, and split where a ribbon passes from
|
|
141
|
+
* behind the body to in front of it. `presence` 0..1 draws them out and back in. `cage` picks
|
|
142
|
+
* the layout: a working turn's 3 to 5 ribbons on one hoop (below 0.5), or a celebration's three
|
|
143
|
+
* on each of three hoops. `sweep` (radians, signed) is how far the body's turn has carried
|
|
144
|
+
* them; between turns they are not drawn. Each ribbon narrows where its hoop curves tighter than
|
|
145
|
+
* half its width, so its outline never folds over itself. `rim` gives the hoops' centre (the
|
|
146
|
+
* middle of the body's mass) and how far the body reaches from it along a direction: a working
|
|
147
|
+
* turn's hoop stands just outside the body along its own direction; a celebration's three share
|
|
148
|
+
* one radius, the largest any of them needs, so the cage stays round. Either way the ribbons pass
|
|
149
|
+
* behind the body only off its outline.
|
|
150
|
+
*/
|
|
151
|
+
export function ribbonPieces(b, presence, seed, _time, sweep = 0, cage = 0, rim) {
|
|
152
|
+
const k = clamp(presence, 0, 1), more = cage >= 0.5 ? 1 : 0;
|
|
153
|
+
if (k <= 0.01)
|
|
154
|
+
return [];
|
|
155
|
+
const cx = rim ? rim.cx : (b.minX + b.maxX) / 2, cy = rim ? rim.cy : (b.minY + b.maxY) / 2;
|
|
156
|
+
const rolls = hoopRolls(seed), rollOf = (i) => rolls[i];
|
|
157
|
+
const cageRing = rim ? Math.max(...[0, 1, 2].map((i) => rim.at(rollOf(i)))) + RIM_MARGIN : RING;
|
|
158
|
+
const unit = UNIT;
|
|
159
|
+
const dir = sweep < 0 ? -1 : 1;
|
|
160
|
+
// How long the sweep has been going, from how far it has got.
|
|
161
|
+
const since = Math.abs(sweep) / mix(SWEEP_RATE, more);
|
|
162
|
+
const pieces = [];
|
|
163
|
+
for (let i = 0; i < (more ? HOOPS : 1); i++) {
|
|
164
|
+
const hoopRoll = rollOf(i);
|
|
165
|
+
const hoopTilt = HOOP_TILT + (noise(seed, 460 + i) - 0.5) * HOOP_TILT_JITTER;
|
|
166
|
+
const ring = more ? cageRing : rim ? rim.at(hoopRoll) + RIM_MARGIN : RING;
|
|
167
|
+
const lanes = i || more > 0 ? LANES : Math.round(mix(WORK_LANES, noise(seed, 47)));
|
|
168
|
+
for (let l = 0; l < lanes; l++) {
|
|
169
|
+
const n = (m) => noise(seed, 500 + (i * LANES + l) * 11 + m);
|
|
170
|
+
// Let out in turn, lane by lane across the hoops: how long ago this one was, and how far
|
|
171
|
+
// the turn had got by then.
|
|
172
|
+
const order = more > 0 ? l * HOOPS + i : l;
|
|
173
|
+
const at = order * mix(STAGGER, n(7));
|
|
174
|
+
const life = since - at;
|
|
175
|
+
if (life <= 0)
|
|
176
|
+
continue;
|
|
177
|
+
const before = since > 0 ? Math.abs(sweep) * (at / since) : 0;
|
|
178
|
+
const roll = hoopRoll;
|
|
179
|
+
const tilt = hoopTilt;
|
|
180
|
+
const flat = Math.sin(tilt), depth = Math.cos(tilt);
|
|
181
|
+
const cr = Math.cos(roll), sr = Math.sin(roll);
|
|
182
|
+
const r = ring + (l * LADDER * unit) / (lanes - 1) + mix([0, WIDEN], n(2)) * unit * life;
|
|
183
|
+
// The orbit angle (0 = the top of the hoop) of the head: it starts where the turn was when
|
|
184
|
+
// it was let out, a little behind, and goes its own share of the rest. Its tail trails it by
|
|
185
|
+
// as far as it has gone, up to its arc; drawing back in shortens and thins it.
|
|
186
|
+
const travel = (Math.abs(sweep) - before) * mix(FOLLOW, n(3)) + mix(DRIFT, n(4)) * life;
|
|
187
|
+
const head = dir * (before + travel - START * n(5));
|
|
188
|
+
const ret = 1 - clamp(k * 1.25, 0, 1);
|
|
189
|
+
const length = Math.min(mix(ARC, n(6)), travel) * (1 - ret * ret * (3 - 2 * ret));
|
|
190
|
+
if (length <= 0.02)
|
|
191
|
+
continue;
|
|
192
|
+
const size = mix(sizeFor(lanes), n(8)) * (1 - more) + mix(SIZE_MANY, n(8)) * more;
|
|
193
|
+
const nearHead = clamp(Math.cos(head) * depth, 0, 1);
|
|
194
|
+
let full = size * BRUSH * unit * (FAR + (1 - FAR) * nearHead) * smooth(life / GROW_S) * (1 - 0.72 * ret * ret);
|
|
195
|
+
// A point of the ribbon is in front of the body on the near half of its hoop (depth above 0).
|
|
196
|
+
const lamAt = (u) => head - dir * length * (1 - u);
|
|
197
|
+
const point = (lam) => {
|
|
198
|
+
const a = Math.sin(lam), y = -Math.cos(lam) * flat;
|
|
199
|
+
return [cx + r * (a * cr - y * sr), cy + r * (a * sr + y * cr)];
|
|
200
|
+
};
|
|
201
|
+
// Where along the ribbon (0 tail .. 1 head) to sample it: evenly, plus exactly where it
|
|
202
|
+
// passes from one layer to the other (the hoop's sides, where its depth is 0) and a sliver
|
|
203
|
+
// either side, so every ribbon on a hoop changes layer along the same line.
|
|
204
|
+
const along = (lam) => 1 - (head - lam) / (dir * length);
|
|
205
|
+
const sliver = SLIVER / length;
|
|
206
|
+
const ss = [];
|
|
207
|
+
for (let j = 0; j <= SAMPLES; j++)
|
|
208
|
+
ss.push(j / SAMPLES);
|
|
209
|
+
const lo = Math.min(head, head - dir * length), hi = Math.max(head, head - dir * length);
|
|
210
|
+
for (let side = Math.ceil((lo - Math.PI / 2) / Math.PI); Math.PI / 2 + side * Math.PI < hi; side++) {
|
|
211
|
+
const u = along(Math.PI / 2 + side * Math.PI);
|
|
212
|
+
for (const d of [-sliver, 0, sliver])
|
|
213
|
+
if (u + d > 0 && u + d < 1)
|
|
214
|
+
ss.push(u + d);
|
|
215
|
+
}
|
|
216
|
+
ss.sort((x, y) => x - y);
|
|
217
|
+
// A sample exactly on a side belongs with the stretch after it.
|
|
218
|
+
const near = ss.map((u) => Math.cos(lamAt(u) + dir * 1e-6) > 0);
|
|
219
|
+
// Centre, half width, unit normal (on screen) at each sample, tail to head.
|
|
220
|
+
const mid = [], halfs = [], norm = [], bend = [];
|
|
221
|
+
for (const u of ss) {
|
|
222
|
+
const lam = lamAt(u);
|
|
223
|
+
// On the hoop before its roll: the ellipse's normal.
|
|
224
|
+
const nx = Math.sin(lam) * flat, ny = -Math.cos(lam);
|
|
225
|
+
const nl = Math.hypot(nx, ny) || 1;
|
|
226
|
+
const ux = nx / nl, uy = ny / nl;
|
|
227
|
+
mid.push(point(lam));
|
|
228
|
+
norm.push([ux * cr - uy * sr, ux * sr + uy * cr]);
|
|
229
|
+
halfs.push(0.5 + 0.5 * u);
|
|
230
|
+
// How tightly the hoop curves here, as a radius: a ribbon wider than it would fold.
|
|
231
|
+
const c = Math.cos(lam), sn = Math.sin(lam);
|
|
232
|
+
bend.push((r * (c * c + flat * flat * sn * sn) ** 1.5) / flat);
|
|
233
|
+
}
|
|
234
|
+
const last = ss.length - 1;
|
|
235
|
+
// Never wider than a third of its own length on screen.
|
|
236
|
+
let onScreen = 0;
|
|
237
|
+
for (let j = 1; j <= last; j++)
|
|
238
|
+
onScreen += Math.hypot(mid[j][0] - mid[j - 1][0], mid[j][1] - mid[j - 1][1]);
|
|
239
|
+
full = Math.min(full, 0.34 * onScreen);
|
|
240
|
+
for (let j = 0; j <= last; j++)
|
|
241
|
+
halfs[j] = Math.min(halfs[j] * (full / 2), 0.9 * bend[j]);
|
|
242
|
+
const side = (j, sign) => [mid[j][0] + sign * norm[j][0] * halfs[j], mid[j][1] + sign * norm[j][1] * halfs[j]];
|
|
243
|
+
// A half circle round an end, from one edge to the other through the point ahead of it (or behind).
|
|
244
|
+
const cap = (j, ahead) => {
|
|
245
|
+
const o = ahead ? mid[j - 1] : mid[j + 1];
|
|
246
|
+
let tx = ahead ? mid[j][0] - o[0] : o[0] - mid[j][0], ty = ahead ? mid[j][1] - o[1] : o[1] - mid[j][1];
|
|
247
|
+
const tl = Math.hypot(tx, ty) || 1;
|
|
248
|
+
tx /= tl;
|
|
249
|
+
ty /= tl;
|
|
250
|
+
const [nx, ny] = norm[j], h = halfs[j], out = [];
|
|
251
|
+
for (let c = 1; c < CAP; c++) {
|
|
252
|
+
const t = (Math.PI * c) / CAP;
|
|
253
|
+
// Ahead: from the + edge forward round to the - edge; behind: from the - edge back to the +.
|
|
254
|
+
const e = ahead ? Math.cos(t) : -Math.cos(t), g = ahead ? Math.sin(t) : -Math.sin(t);
|
|
255
|
+
out.push([mid[j][0] + (nx * e + tx * g) * h, mid[j][1] + (ny * e + ty * g) * h]);
|
|
256
|
+
}
|
|
257
|
+
return out;
|
|
258
|
+
};
|
|
259
|
+
// Runs of samples on one side, and at most a stretch long, each become a piece. Pieces overlap
|
|
260
|
+
// by a sample where they meet, the one drawn first running on under the other, so no seam
|
|
261
|
+
// shows: within a side the earlier piece runs on under the later; between sides the piece
|
|
262
|
+
// behind the body (drawn before every piece in front) runs a sliver on under the piece in front.
|
|
263
|
+
let from = 0;
|
|
264
|
+
for (let j = 1; j <= last; j++) {
|
|
265
|
+
const turns = j < last && near[j] !== near[from];
|
|
266
|
+
if (j < last && !turns && j - from < STRETCH)
|
|
267
|
+
continue;
|
|
268
|
+
const to = j;
|
|
269
|
+
const behind = !near[from];
|
|
270
|
+
const end = to < last && (!turns || behind) ? to + 1 : to;
|
|
271
|
+
const start = from > 0 && behind && near[from - 1] ? from - 1 : from;
|
|
272
|
+
const pts = [];
|
|
273
|
+
for (let q = start; q <= end; q++)
|
|
274
|
+
pts.push(side(q, 1));
|
|
275
|
+
if (end === last)
|
|
276
|
+
pts.push(...cap(last, true));
|
|
277
|
+
for (let q = end; q >= start; q--)
|
|
278
|
+
pts.push(side(q, -1));
|
|
279
|
+
if (start === 0)
|
|
280
|
+
pts.push(...cap(0, false));
|
|
281
|
+
const xs = pts.map((p) => p[0]), ys = pts.map((p) => p[1]);
|
|
282
|
+
const x = Math.min(...xs), y = Math.min(...ys);
|
|
283
|
+
pieces.push({
|
|
284
|
+
d: `M${pts.map((p) => `${f(p[0])} ${f(p[1])}`).join('L')}Z`,
|
|
285
|
+
front: near[from],
|
|
286
|
+
box: { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y },
|
|
287
|
+
ribbon: i * LANES + l,
|
|
288
|
+
along: [ss[from], ss[to]],
|
|
289
|
+
from: mid[from],
|
|
290
|
+
to: mid[to],
|
|
291
|
+
});
|
|
292
|
+
from = j;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return pieces;
|
|
297
|
+
}
|
|
298
|
+
const circle = (r) => `M${f(r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(-r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(r)} 0Z`;
|
|
299
|
+
const capsule = (w, h) => {
|
|
300
|
+
const r = w / 2, y = h / 2 - r;
|
|
301
|
+
return `M${f(-r)} ${f(-y)}A${f(r)} ${f(r)} 0 0 1 ${f(r)} ${f(-y)}L${f(r)} ${f(y)}A${f(r)} ${f(r)} 0 0 1 ${f(-r)} ${f(y)}Z`;
|
|
302
|
+
};
|
|
303
|
+
/** The unit every mark is sized in: a share of the body's smaller side, within limits that read at any size. */
|
|
304
|
+
function markUnit(b) {
|
|
305
|
+
return clamp(Math.min(b.maxX - b.minX, b.maxY - b.minY), 34, 78);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* The parts of the marks at one moment. `bang` and `dots` 0..1 are how far the body has given
|
|
309
|
+
* way to each (see Pose): a mark grows in as the body goes, from the body's centre.
|
|
310
|
+
* The dots take turns hopping; the exclamation mark jumps and shakes every couple of seconds.
|
|
311
|
+
*/
|
|
312
|
+
export function markParts(b, bang, dots, seed, time, still) {
|
|
313
|
+
const cx = (b.minX + b.maxX) / 2, cy = (b.minY + b.maxY) / 2;
|
|
314
|
+
const u = markUnit(b);
|
|
315
|
+
const t = still ? 0 : time + noise(seed, 9) * 10;
|
|
316
|
+
const parts = [];
|
|
317
|
+
// A mark starts to grow just before the body is gone, so something is always on screen.
|
|
318
|
+
const grown = (weight) => smooth((clamp(weight, 0, 1) - 0.45) / 0.55);
|
|
319
|
+
const gb = grown(bang);
|
|
320
|
+
if (gb > 0) {
|
|
321
|
+
const barW = 0.21 * u, barH = 0.5 * u, dot = 0.115 * u, gap = 0.1 * u;
|
|
322
|
+
const total = barH + gap + 2 * dot;
|
|
323
|
+
// One alarm every 2.6 s: a jump, with a shake that dies away as it lands.
|
|
324
|
+
const p = still ? 1 : ((t % 2.6) + 2.6) % 2.6 / 2.6;
|
|
325
|
+
const alarm = p < 0.3 ? p / 0.3 : 1;
|
|
326
|
+
const jump = still ? 0 : Math.sin(Math.PI * alarm);
|
|
327
|
+
const turn = still ? 0 : 0.2 * Math.sin(TAU * 3 * alarm) * (1 - alarm);
|
|
328
|
+
const lift = -0.09 * u * jump;
|
|
329
|
+
const barY = -total / 2 + barH / 2, dotY = total / 2 - dot;
|
|
330
|
+
// The dot lags the bar on the way up, so the mark stretches as it jumps.
|
|
331
|
+
parts.push({ shape: 'bar', d: capsule(barW, barH), box: { x: -barW / 2, y: -barH / 2, w: barW, h: barH }, x: cx, y: cy + (barY + lift) * gb, turn, scale: gb }, { shape: 'dot', d: circle(dot), box: { x: -dot, y: -dot, w: 2 * dot, h: 2 * dot }, x: cx, y: cy + (dotY + lift * 0.45) * gb, turn, scale: gb });
|
|
332
|
+
}
|
|
333
|
+
const gd = grown(dots);
|
|
334
|
+
if (gd > 0) {
|
|
335
|
+
const r = 0.1 * u, step = 0.31 * u;
|
|
336
|
+
for (let i = 0; i < 3; i++) {
|
|
337
|
+
// Each dot hops in turn, a beat after the one before it.
|
|
338
|
+
const p = still ? 0 : (((t - i * 0.17) % 1.25) + 1.25) % 1.25 / 1.25;
|
|
339
|
+
const hop = p < 0.4 ? Math.sin(Math.PI * (p / 0.4)) : 0;
|
|
340
|
+
parts.push({
|
|
341
|
+
shape: 'dot3', d: circle(r), box: { x: -r, y: -r, w: 2 * r, h: 2 * r },
|
|
342
|
+
x: cx + (i - 1) * step * gd, y: cy - 0.16 * u * hop * gd, turn: 0, scale: gd * (1 + 0.12 * hop),
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return parts;
|
|
347
|
+
}
|
|
348
|
+
/** How much of its size the body keeps while it gives way to a mark: gone a little past half way. */
|
|
349
|
+
export function bodyScale(bang, dots) {
|
|
350
|
+
return 1 - smooth(clamp(bang + dots, 0, 1) / 0.55);
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=effects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.js","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AACxB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACnF,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxF,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE;IACtB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACpC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,C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C,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/eyes.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The outline of one eye for any look. The plain pill, the happy arc and the flat slit of a
|
|
3
|
+
* waiting bot are each walked as a closed outline from the top centre, clockwise, at even steps;
|
|
4
|
+
* mixing them point by point gives every shape in between, so a change of state or mood morphs
|
|
5
|
+
* the eyes instead of swapping them. The slit lies inside the room validation keeps for the arc.
|
|
6
|
+
*/
|
|
7
|
+
import type { EyeLook } from './motion.ts';
|
|
8
|
+
import type { Point } from './path.ts';
|
|
9
|
+
/** Where one eye is drawn this frame, in its face plane (viewBox units). */
|
|
10
|
+
export interface EyeSpot {
|
|
11
|
+
/** Centre, gaze included. */
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
/** Neutral size. */
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
/** Height of the pill after blink and squint, and how far that moves it down. */
|
|
18
|
+
open: number;
|
|
19
|
+
shift: number;
|
|
20
|
+
}
|
|
21
|
+
/** Whether a look is exactly the plain pill or exactly the happy arc: those are drawn as before. */
|
|
22
|
+
export declare function plainLook(look: EyeLook): 'pill' | 'arc' | null;
|
|
23
|
+
/** The outline of one eye, closed, clockwise from the top: the pill, the arc and the slit mixed by the look. */
|
|
24
|
+
export declare function eyeOutline(look: EyeLook, e: EyeSpot): Point[];
|
|
25
|
+
/** A smooth closed path through an outline: a quadratic per point, joined at the midpoints. Absolute M, Q and Z only. */
|
|
26
|
+
export declare function outlinePath(pts: Point[]): string;
|
|
27
|
+
/** The path of one eye for a look that is neither the plain pill nor the plain arc. */
|
|
28
|
+
export declare function eyePath(look: EyeLook, e: EyeSpot): string;
|
|
29
|
+
//# sourceMappingURL=eyes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eyes.d.ts","sourceRoot":"","sources":["../src/eyes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGvC,4EAA4E;AAC5E,MAAM,WAAW,OAAO;IACtB,6BAA6B;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,oBAAoB;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AA0FD,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAG9D;AAED,gHAAgH;AAChH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,CAY7D;AAOD,yHAAyH;AACzH,wBAAgB,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,MAAM,CAahD;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAEzD"}
|
package/dist/eyes.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { HAPPY_ARC } from './validate.js';
|
|
2
|
+
/** Points per outline. */
|
|
3
|
+
const STEPS = 40;
|
|
4
|
+
/** The slit: as long as the happy arc is wide, this thick (both as shares of the eye's width), tipped this far. */
|
|
5
|
+
const SLIT = { length: 1.9, thick: 0.5, tip: 0.2 };
|
|
6
|
+
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
7
|
+
/** `count` points at even steps along a closed polyline, the first one at its first point. */
|
|
8
|
+
function resample(pts, count) {
|
|
9
|
+
const n = pts.length;
|
|
10
|
+
const at = [0];
|
|
11
|
+
for (let i = 0; i < n; i++) {
|
|
12
|
+
const a = pts[i], b = pts[(i + 1) % n];
|
|
13
|
+
at.push(at[i] + Math.hypot(b[0] - a[0], b[1] - a[1]));
|
|
14
|
+
}
|
|
15
|
+
const total = at[n];
|
|
16
|
+
const out = [];
|
|
17
|
+
let i = 0;
|
|
18
|
+
for (let k = 0; k < count; k++) {
|
|
19
|
+
const s = (k / count) * total;
|
|
20
|
+
while (i < n - 1 && at[i + 1] < s)
|
|
21
|
+
i++;
|
|
22
|
+
const a = pts[i], b = pts[(i + 1) % n];
|
|
23
|
+
const u = at[i + 1] > at[i] ? (s - at[i]) / (at[i + 1] - at[i]) : 0;
|
|
24
|
+
out.push([a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u]);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** An arc of a circle as points, from angle `from` to `to` (radians, y down), ends included. */
|
|
29
|
+
function sweep(cx, cy, r, from, to, steps) {
|
|
30
|
+
const pts = [];
|
|
31
|
+
for (let i = 0; i <= steps; i++) {
|
|
32
|
+
const a = from + ((to - from) * i) / steps;
|
|
33
|
+
pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]);
|
|
34
|
+
}
|
|
35
|
+
return pts;
|
|
36
|
+
}
|
|
37
|
+
/** The pill: a stadium `w` wide and `h` tall about (cx, cy), from the top centre, clockwise. */
|
|
38
|
+
function pill(cx, cy, w, h) {
|
|
39
|
+
const r = Math.min(w, h) / 2;
|
|
40
|
+
const fx = w / 2 - r, fy = h / 2 - r;
|
|
41
|
+
const q = Math.PI / 2;
|
|
42
|
+
return [
|
|
43
|
+
[cx, cy - h / 2],
|
|
44
|
+
...sweep(cx + fx, cy - fy, r, -q, 0, 6),
|
|
45
|
+
...sweep(cx + fx, cy + fy, r, 0, q, 6),
|
|
46
|
+
...sweep(cx - fx, cy + fy, r, q, 2 * q, 6),
|
|
47
|
+
...sweep(cx - fx, cy - fy, r, 2 * q, 3 * q, 6),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
/** The happy arc as an outline: its stroke's two edges and round ends, from the top centre, clockwise. */
|
|
51
|
+
function arc(e) {
|
|
52
|
+
const hw = e.w * HAPPY_ARC.halfWidth, base = e.y + e.h * HAPPY_ARC.base, peak = e.y - e.h * HAPPY_ARC.peak;
|
|
53
|
+
const r = (e.w * HAPPY_ARC.stroke) / 2;
|
|
54
|
+
// The centre line and its upward normal at s (0 = left end, 1 = right end).
|
|
55
|
+
const at = (s) => {
|
|
56
|
+
const m = 1 - s;
|
|
57
|
+
const x = e.x + hw * (2 * s - 1), y = (m * m + s * s) * base + 2 * m * s * peak;
|
|
58
|
+
const tx = 2 * hw, ty = 2 * (2 * s - 1) * (base - peak);
|
|
59
|
+
const len = Math.hypot(tx, ty);
|
|
60
|
+
return { p: [x, y], n: [ty / len, -tx / len] };
|
|
61
|
+
};
|
|
62
|
+
const edge = (from, to, side) => {
|
|
63
|
+
const pts = [];
|
|
64
|
+
for (let i = 0; i <= 8; i++) {
|
|
65
|
+
const { p, n } = at(from + ((to - from) * i) / 8);
|
|
66
|
+
pts.push([p[0] + n[0] * r * side, p[1] + n[1] * r * side]);
|
|
67
|
+
}
|
|
68
|
+
return pts;
|
|
69
|
+
};
|
|
70
|
+
const end = (s) => {
|
|
71
|
+
const { p, n } = at(s);
|
|
72
|
+
const up = Math.atan2(n[1], n[0]);
|
|
73
|
+
// Round the end from the upper edge to the lower one, the long way round its tip.
|
|
74
|
+
return s === 1 ? sweep(p[0], p[1], r, up, up + Math.PI, 8) : sweep(p[0], p[1], r, up + Math.PI, up + 2 * Math.PI, 8);
|
|
75
|
+
};
|
|
76
|
+
return [...edge(0.5, 1, 1), ...end(1), ...edge(1, 0, -1), ...end(0), ...edge(0, 0.5, 1)];
|
|
77
|
+
}
|
|
78
|
+
/** The slit: a thin capsule lying almost flat, both eyes tipped the same way; a blink thins it. */
|
|
79
|
+
function slit(e) {
|
|
80
|
+
const length = e.w * SLIT.length, thick = e.w * SLIT.thick * clamp(e.open / e.h, 0.3, 1);
|
|
81
|
+
const cos = Math.cos(SLIT.tip), sin = Math.sin(SLIT.tip);
|
|
82
|
+
return pill(0, 0, length, thick).map(([x, y]) => [e.x + x * cos - y * sin, e.y + x * sin + y * cos]);
|
|
83
|
+
}
|
|
84
|
+
/** Whether a look is exactly the plain pill or exactly the happy arc: those are drawn as before. */
|
|
85
|
+
export function plainLook(look) {
|
|
86
|
+
if (look.arc >= 1)
|
|
87
|
+
return 'arc';
|
|
88
|
+
return look.arc <= 0 && look.slit <= 0 ? 'pill' : null;
|
|
89
|
+
}
|
|
90
|
+
/** The outline of one eye, closed, clockwise from the top: the pill, the arc and the slit mixed by the look. */
|
|
91
|
+
export function eyeOutline(look, e) {
|
|
92
|
+
const a = clamp(look.arc, 0, 1), s = clamp(look.slit, 0, 1 - a);
|
|
93
|
+
const shapes = [[1 - a - s, pill(e.x, e.y + e.shift, e.w, e.open)], [a, arc(e)], [s, slit(e)]];
|
|
94
|
+
const out = Array.from({ length: STEPS }, () => [0, 0]);
|
|
95
|
+
for (const [weight, shape] of shapes) {
|
|
96
|
+
if (weight <= 0)
|
|
97
|
+
continue;
|
|
98
|
+
resample(shape, STEPS).forEach(([x, y], i) => {
|
|
99
|
+
out[i][0] += x * weight;
|
|
100
|
+
out[i][1] += y * weight;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
const f = (n) => {
|
|
106
|
+
const r = Math.round(n * 100) / 100;
|
|
107
|
+
return (Object.is(r, -0) ? 0 : r).toString();
|
|
108
|
+
};
|
|
109
|
+
/** A smooth closed path through an outline: a quadratic per point, joined at the midpoints. Absolute M, Q and Z only. */
|
|
110
|
+
export function outlinePath(pts) {
|
|
111
|
+
const n = pts.length;
|
|
112
|
+
const mid = (i) => {
|
|
113
|
+
const a = pts[i % n], b = pts[(i + 1) % n];
|
|
114
|
+
return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
|
|
115
|
+
};
|
|
116
|
+
const start = mid(n - 1);
|
|
117
|
+
let d = `M${f(start[0])} ${f(start[1])}`;
|
|
118
|
+
for (let i = 0; i < n; i++) {
|
|
119
|
+
const m = mid(i);
|
|
120
|
+
d += `Q${f(pts[i][0])} ${f(pts[i][1])} ${f(m[0])} ${f(m[1])}`;
|
|
121
|
+
}
|
|
122
|
+
return `${d}Z`;
|
|
123
|
+
}
|
|
124
|
+
/** The path of one eye for a look that is neither the plain pill nor the plain arc. */
|
|
125
|
+
export function eyePath(look, e) {
|
|
126
|
+
return outlinePath(eyeOutline(look, e));
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=eyes.js.map
|