@plupin/character 0.3.0 → 0.4.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/dist/anime-face.d.ts +17 -17
- package/dist/anime-face.js +1 -1
- package/dist/blob.d.ts +49 -11
- package/dist/blob.js +29 -1
- package/dist/body-presets.d.ts +105 -37
- package/dist/canvas.js +22 -3
- package/dist/{chunk-g1c0wdcj.js → chunk-7ry0n8cw.js} +386 -2
- package/dist/{chunk-sa2r1cxz.js → chunk-ew73g2v7.js} +13 -7
- package/dist/chunk-ewkkvpte.js +448 -0
- package/dist/{chunk-60p135hw.js → chunk-kf7f1tdx.js} +113 -9
- package/dist/{chunk-kber92gm.js → chunk-nx2wbkfn.js} +8 -2
- package/dist/{chunk-yd5zzkkg.js → chunk-rqenm9tn.js} +175 -1
- package/dist/chunk-vy9w8as2.js +196 -0
- package/dist/clips.d.ts +1 -1
- package/dist/index.js +5 -43
- package/dist/listing.js +39 -13
- package/dist/plup3d.d.ts +9 -58
- package/dist/png.d.ts +4 -3
- package/dist/pose.js +1 -1
- package/dist/skin-map.d.ts +3 -2
- package/dist/skin-map.js +3 -1
- package/dist/skin-native.d.ts +26 -8
- package/dist/three.d.ts +8 -1
- package/dist/three.js +1298 -404
- package/dist/wear3d.d.ts +19 -0
- package/dist/wearables.d.ts +114 -10
- package/dist/wearables.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-09c5tps4.js +0 -337
- package/dist/chunk-dpb0rnw9.js +0 -37
package/dist/wear3d.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ export interface PaintOptions {
|
|
|
25
25
|
inner?: string;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
export interface BodyZones {
|
|
29
|
+
bottomY: number;
|
|
30
|
+
hipY: number;
|
|
31
|
+
waistY: number;
|
|
32
|
+
bustY: number;
|
|
33
|
+
shoulderY: number;
|
|
34
|
+
neckY: number;
|
|
35
|
+
}
|
|
28
36
|
export interface WearKit {
|
|
29
37
|
/** A toon material in this colour, optionally patterned, two-sided, lined or glinting. */
|
|
30
38
|
paint: (color: string, options?: PaintOptions) => Material;
|
|
@@ -32,6 +40,17 @@ export interface WearKit {
|
|
|
32
40
|
ink: Material;
|
|
33
41
|
/** The body's half-width at a height (its silhouette), so a coat fits a muscular or a curvy body. */
|
|
34
42
|
radiusAt: (y: number) => number;
|
|
43
|
+
/** Directional (x, z) point on the torso/body surface at height `y` and angle `phi`, lifted by `grow`. */
|
|
44
|
+
surfaceAt?: (y: number, phi: number, grow?: number) => {
|
|
45
|
+
x: number;
|
|
46
|
+
z: number;
|
|
47
|
+
};
|
|
48
|
+
/** Vertical anatomical anchors (differs between classic round Plup and stylized anime figure). */
|
|
49
|
+
zones?: BodyZones;
|
|
50
|
+
/** True when mounted on the stylized anime figure (dedicated head + sculpted torso). */
|
|
51
|
+
isFigure?: boolean;
|
|
52
|
+
/** Optional custom hair colour override. */
|
|
53
|
+
hairColor?: string;
|
|
35
54
|
}
|
|
36
55
|
/** What the body is doing this frame, for the clothes to react to (units and radians per second). */
|
|
37
56
|
export interface WearMotion {
|
package/dist/wearables.d.ts
CHANGED
|
@@ -22,19 +22,67 @@ type Entry = {
|
|
|
22
22
|
view?: number;
|
|
23
23
|
};
|
|
24
24
|
export declare const WEARABLES: {
|
|
25
|
+
readonly "wolf-cut": {
|
|
26
|
+
readonly slot: "hair";
|
|
27
|
+
readonly name: "Wolf Cut";
|
|
28
|
+
readonly rarity: "epic";
|
|
29
|
+
readonly sigmaPrice: 120;
|
|
30
|
+
readonly volume: 0.09;
|
|
31
|
+
readonly view: -0.35;
|
|
32
|
+
};
|
|
33
|
+
readonly "curtain-ikemen": {
|
|
34
|
+
readonly slot: "hair";
|
|
35
|
+
readonly name: "Curtain Flow";
|
|
36
|
+
readonly rarity: "rare";
|
|
37
|
+
readonly sigmaPrice: 85;
|
|
38
|
+
readonly volume: 0.08;
|
|
39
|
+
readonly view: -0.25;
|
|
40
|
+
};
|
|
41
|
+
readonly "messy-fluff": {
|
|
42
|
+
readonly slot: "hair";
|
|
43
|
+
readonly name: "Messy Fluff";
|
|
44
|
+
readonly rarity: "rare";
|
|
45
|
+
readonly sigmaPrice: 80;
|
|
46
|
+
readonly volume: 0.1;
|
|
47
|
+
readonly view: -0.3;
|
|
48
|
+
};
|
|
49
|
+
readonly "silky-layers": {
|
|
50
|
+
readonly slot: "hair";
|
|
51
|
+
readonly name: "Silky Layers";
|
|
52
|
+
readonly rarity: "epic";
|
|
53
|
+
readonly sigmaPrice: 130;
|
|
54
|
+
readonly volume: 0.07;
|
|
55
|
+
readonly view: -0.45;
|
|
56
|
+
};
|
|
57
|
+
readonly "ojou-curls": {
|
|
58
|
+
readonly slot: "hair";
|
|
59
|
+
readonly name: "Ribbon Curls";
|
|
60
|
+
readonly rarity: "epic";
|
|
61
|
+
readonly sigmaPrice: 125;
|
|
62
|
+
readonly volume: 0.08;
|
|
63
|
+
readonly view: -0.35;
|
|
64
|
+
};
|
|
65
|
+
readonly "side-braid": {
|
|
66
|
+
readonly slot: "hair";
|
|
67
|
+
readonly name: "Side Braid";
|
|
68
|
+
readonly rarity: "rare";
|
|
69
|
+
readonly sigmaPrice: 90;
|
|
70
|
+
readonly volume: 0.07;
|
|
71
|
+
readonly view: -0.4;
|
|
72
|
+
};
|
|
25
73
|
readonly "fluffy-bob": {
|
|
26
74
|
readonly slot: "hair";
|
|
27
75
|
readonly name: "Fluffy Bob";
|
|
28
76
|
readonly rarity: "common";
|
|
29
77
|
readonly sigmaPrice: 40;
|
|
30
|
-
readonly volume: 0.
|
|
78
|
+
readonly volume: 0.07;
|
|
31
79
|
};
|
|
32
80
|
readonly "twin-tails": {
|
|
33
81
|
readonly slot: "hair";
|
|
34
82
|
readonly name: "Twin Tails";
|
|
35
83
|
readonly rarity: "rare";
|
|
36
84
|
readonly sigmaPrice: 70;
|
|
37
|
-
readonly volume: 0.
|
|
85
|
+
readonly volume: 0.06;
|
|
38
86
|
};
|
|
39
87
|
readonly "spiky-hero": {
|
|
40
88
|
readonly slot: "hair";
|
|
@@ -62,16 +110,16 @@ export declare const WEARABLES: {
|
|
|
62
110
|
readonly name: "Long Waves";
|
|
63
111
|
readonly rarity: "epic";
|
|
64
112
|
readonly sigmaPrice: 110;
|
|
65
|
-
readonly volume: 0.
|
|
66
|
-
readonly view: -0.
|
|
113
|
+
readonly volume: 0.06;
|
|
114
|
+
readonly view: -0.8;
|
|
67
115
|
};
|
|
68
116
|
readonly ponytail: {
|
|
69
117
|
readonly slot: "hair";
|
|
70
118
|
readonly name: "Ponytail";
|
|
71
119
|
readonly rarity: "common";
|
|
72
120
|
readonly sigmaPrice: 45;
|
|
73
|
-
readonly volume: 0.
|
|
74
|
-
readonly view: -1.
|
|
121
|
+
readonly volume: 0.06;
|
|
122
|
+
readonly view: -1.1;
|
|
75
123
|
};
|
|
76
124
|
readonly mohawk: {
|
|
77
125
|
readonly slot: "hair";
|
|
@@ -86,15 +134,15 @@ export declare const WEARABLES: {
|
|
|
86
134
|
readonly name: "Space Buns";
|
|
87
135
|
readonly rarity: "rare";
|
|
88
136
|
readonly sigmaPrice: 60;
|
|
89
|
-
readonly volume: 0.
|
|
137
|
+
readonly volume: 0.07;
|
|
90
138
|
};
|
|
91
139
|
readonly "hime-cut": {
|
|
92
140
|
readonly slot: "hair";
|
|
93
141
|
readonly name: "Hime Cut";
|
|
94
142
|
readonly rarity: "epic";
|
|
95
143
|
readonly sigmaPrice: 120;
|
|
96
|
-
readonly volume: 0.
|
|
97
|
-
readonly view: -0.
|
|
144
|
+
readonly volume: 0.07;
|
|
145
|
+
readonly view: -0.5;
|
|
98
146
|
};
|
|
99
147
|
readonly "bunny-ears": {
|
|
100
148
|
readonly slot: "hat";
|
|
@@ -138,6 +186,62 @@ export declare const WEARABLES: {
|
|
|
138
186
|
readonly rarity: "common";
|
|
139
187
|
readonly sigmaPrice: 30;
|
|
140
188
|
};
|
|
189
|
+
readonly "ribbon-dress": {
|
|
190
|
+
readonly slot: "accessory";
|
|
191
|
+
readonly name: "Ribbon Dress";
|
|
192
|
+
readonly rarity: "epic";
|
|
193
|
+
readonly sigmaPrice: 135;
|
|
194
|
+
readonly view: -0.35;
|
|
195
|
+
};
|
|
196
|
+
readonly "crop-hoodie": {
|
|
197
|
+
readonly slot: "accessory";
|
|
198
|
+
readonly name: "Cropped Hoodie";
|
|
199
|
+
readonly rarity: "rare";
|
|
200
|
+
readonly sigmaPrice: 85;
|
|
201
|
+
readonly view: -0.3;
|
|
202
|
+
};
|
|
203
|
+
readonly "idol-set": {
|
|
204
|
+
readonly slot: "accessory";
|
|
205
|
+
readonly name: "Star Idol";
|
|
206
|
+
readonly rarity: "epic";
|
|
207
|
+
readonly sigmaPrice: 145;
|
|
208
|
+
readonly view: -0.3;
|
|
209
|
+
};
|
|
210
|
+
readonly "street-jacket": {
|
|
211
|
+
readonly slot: "accessory";
|
|
212
|
+
readonly name: "Street Jacket";
|
|
213
|
+
readonly rarity: "epic";
|
|
214
|
+
readonly sigmaPrice: 130;
|
|
215
|
+
readonly view: -0.35;
|
|
216
|
+
};
|
|
217
|
+
readonly "blazer-coat": {
|
|
218
|
+
readonly slot: "accessory";
|
|
219
|
+
readonly name: "Academy Blazer";
|
|
220
|
+
readonly rarity: "rare";
|
|
221
|
+
readonly sigmaPrice: 95;
|
|
222
|
+
readonly view: -0.3;
|
|
223
|
+
};
|
|
224
|
+
readonly "brawler-vest": {
|
|
225
|
+
readonly slot: "accessory";
|
|
226
|
+
readonly name: "Brawler Tank";
|
|
227
|
+
readonly rarity: "rare";
|
|
228
|
+
readonly sigmaPrice: 75;
|
|
229
|
+
readonly view: -0.3;
|
|
230
|
+
};
|
|
231
|
+
readonly "martial-gi": {
|
|
232
|
+
readonly slot: "accessory";
|
|
233
|
+
readonly name: "Fighter Gi";
|
|
234
|
+
readonly rarity: "rare";
|
|
235
|
+
readonly sigmaPrice: 90;
|
|
236
|
+
readonly view: -0.35;
|
|
237
|
+
};
|
|
238
|
+
readonly "chibi-overalls": {
|
|
239
|
+
readonly slot: "accessory";
|
|
240
|
+
readonly name: "Chibi Overalls";
|
|
241
|
+
readonly rarity: "rare";
|
|
242
|
+
readonly sigmaPrice: 70;
|
|
243
|
+
readonly view: -0.25;
|
|
244
|
+
};
|
|
141
245
|
readonly "pleated-skirt": {
|
|
142
246
|
readonly slot: "accessory";
|
|
143
247
|
readonly name: "Pleated Skirt";
|
|
@@ -195,7 +299,7 @@ export declare function wearableItems(): {
|
|
|
195
299
|
rarity: "common" | "rare" | "epic";
|
|
196
300
|
sigmaPrice: number;
|
|
197
301
|
assetConfig: {
|
|
198
|
-
wear: "fluffy-bob" | "twin-tails" | "spiky-hero" | "afro" | "swoosh-quiff" | "long-waves" | "ponytail" | "mohawk" | "space-buns" | "hime-cut" | "bunny-ears" | "cat-ears" | "top-hat" | "crown" | "party-hat" | "halo" | "bow" | "pleated-skirt" | "tuxedo" | "hero-cape" | "scarf" | "sunglasses";
|
|
302
|
+
wear: "wolf-cut" | "curtain-ikemen" | "messy-fluff" | "silky-layers" | "ojou-curls" | "side-braid" | "fluffy-bob" | "twin-tails" | "spiky-hero" | "afro" | "swoosh-quiff" | "long-waves" | "ponytail" | "mohawk" | "space-buns" | "hime-cut" | "bunny-ears" | "cat-ears" | "top-hat" | "crown" | "party-hat" | "halo" | "bow" | "ribbon-dress" | "crop-hoodie" | "idol-set" | "street-jacket" | "blazer-coat" | "brawler-vest" | "martial-gi" | "chibi-overalls" | "pleated-skirt" | "tuxedo" | "hero-cape" | "scarf" | "sunglasses";
|
|
199
303
|
};
|
|
200
304
|
}[];
|
|
201
305
|
/** The turn a still picture of this wearable is taken at: three-quarters, or from behind for a cape. */
|
package/dist/wearables.js
CHANGED
package/package.json
CHANGED
package/dist/chunk-09c5tps4.js
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
// src/anime-face.ts
|
|
2
|
-
var ANIME_FACE_SIZE = { width: 512, height: 256 };
|
|
3
|
-
var ANIME_FACE_UV = { u0: 0.07, u1: 0.43, v0: 0.37, v1: 0.7 };
|
|
4
|
-
var PARTS = {
|
|
5
|
-
idle: { eyes: "open", mouth: "smile", brows: "calm", blush: 0.55 },
|
|
6
|
-
blink: { eyes: "closed", mouth: "smile", brows: "calm", blush: 0.55 },
|
|
7
|
-
happy: { eyes: "happy", mouth: "open", brows: "up", blush: 0.8 },
|
|
8
|
-
surprised: { eyes: "wide", mouth: "o", brows: "up", blush: 0.4 },
|
|
9
|
-
sad: { eyes: "sad", mouth: "frown", brows: "sad", blush: 0.3 },
|
|
10
|
-
wee: { eyes: "happy", mouth: "o", brows: "up", blush: 0.9 },
|
|
11
|
-
sparkle: { eyes: "stars", mouth: "open", brows: "up", blush: 0.9 },
|
|
12
|
-
shock: { eyes: "wide", mouth: "o", brows: "up", blush: 0.2 },
|
|
13
|
-
yell: { eyes: "angry", mouth: "yell", brows: "angry", blush: 0.3 },
|
|
14
|
-
pain: { eyes: "closed", mouth: "frown", brows: "sad", blush: 0.2 },
|
|
15
|
-
dead: { eyes: "dead", mouth: "flat", brows: "none", blush: 0 },
|
|
16
|
-
rage: { eyes: "angry", mouth: "grin", brows: "angry", blush: 0.2 },
|
|
17
|
-
speechless: { eyes: "half", mouth: "flat", brows: "calm", blush: 0.2 },
|
|
18
|
-
idea: { eyes: "wide", mouth: "smile", brows: "up", blush: 0.5 },
|
|
19
|
-
smug: { eyes: "half", mouth: "cat", brows: "calm", blush: 0.6 },
|
|
20
|
-
cry: { eyes: "cry", mouth: "frown", brows: "sad", blush: 0.5, tears: true },
|
|
21
|
-
smirk: { eyes: "wink", mouth: "smirk", brows: "calm", blush: 0.6 },
|
|
22
|
-
tongue: { eyes: "wink", mouth: "tongue", brows: "up", blush: 0.7 },
|
|
23
|
-
cool: { eyes: "half", mouth: "smirk", brows: "calm", blush: 0.2 },
|
|
24
|
-
serious: { eyes: "angry", mouth: "flat", brows: "angry", blush: 0 },
|
|
25
|
-
stars: { eyes: "stars", mouth: "grin", brows: "up", blush: 0.9 },
|
|
26
|
-
licik: { eyes: "half", mouth: "grin", brows: "angry", blush: 0.3 },
|
|
27
|
-
tidur: { eyes: "closed", mouth: "o", brows: "calm", blush: 0.5 },
|
|
28
|
-
teriak: { eyes: "angry", mouth: "yell", brows: "angry", blush: 0.3 },
|
|
29
|
-
ngomel: { eyes: "angry", mouth: "frown", brows: "angry", blush: 0.3 }
|
|
30
|
-
};
|
|
31
|
-
var INK = "#1d1430";
|
|
32
|
-
var LASH = "#24152e";
|
|
33
|
-
function animeFaceParts(face) {
|
|
34
|
-
return PARTS[face] ?? PARTS.idle ?? { eyes: "open", mouth: "smile", brows: "calm", blush: 0.5 };
|
|
35
|
-
}
|
|
36
|
-
var W = ANIME_FACE_SIZE.width;
|
|
37
|
-
var H = ANIME_FACE_SIZE.height;
|
|
38
|
-
var EYE_Y = 112;
|
|
39
|
-
var EYE_X = 88;
|
|
40
|
-
var EYE_W = 74;
|
|
41
|
-
var EYE_H = 100;
|
|
42
|
-
var MOUTH_Y = 192;
|
|
43
|
-
var ANIME_EYE_LINE = EYE_Y / H;
|
|
44
|
-
var mix = (a, b, t) => {
|
|
45
|
-
const ch = (hex, i) => Number.parseInt(hex.slice(1 + i * 2, 3 + i * 2), 16);
|
|
46
|
-
return `#${[0, 1, 2].map((i) => Math.round(ch(a, i) + (ch(b, i) - ch(a, i)) * t).toString(16).padStart(2, "0")).join("")}`;
|
|
47
|
-
};
|
|
48
|
-
function ellipse(ctx, x, y, rx, ry) {
|
|
49
|
-
ctx.beginPath();
|
|
50
|
-
ctx.ellipse(x, y, Math.max(0.5, rx), Math.max(0.5, ry), 0, 0, Math.PI * 2);
|
|
51
|
-
}
|
|
52
|
-
function eyeShape(ctx, x, y, side) {
|
|
53
|
-
const w = EYE_W / 2;
|
|
54
|
-
const h = EYE_H / 2;
|
|
55
|
-
ctx.beginPath();
|
|
56
|
-
ctx.moveTo(x - w, y - h * 0.25);
|
|
57
|
-
ctx.bezierCurveTo(x - w * 0.9, y - h * 1.05, x + w * 0.9, y - h * 1.12 - side * 2, x + w, y - h * 0.3);
|
|
58
|
-
ctx.bezierCurveTo(x + w * 1.05, y + h * 0.75, x + w * 0.5, y + h, x, y + h);
|
|
59
|
-
ctx.bezierCurveTo(x - w * 0.55, y + h, x - w * 1.05, y + h * 0.7, x - w, y - h * 0.25);
|
|
60
|
-
ctx.closePath();
|
|
61
|
-
}
|
|
62
|
-
function lashes(ctx, x, y, side, lift = 0) {
|
|
63
|
-
const w = EYE_W / 2;
|
|
64
|
-
const h = EYE_H / 2;
|
|
65
|
-
const outer = side;
|
|
66
|
-
ctx.fillStyle = LASH;
|
|
67
|
-
ctx.beginPath();
|
|
68
|
-
ctx.moveTo(x - outer * w * 1.02, y - h * 0.2 + lift);
|
|
69
|
-
ctx.bezierCurveTo(x - outer * w * 0.9, y - h * 1.12 + lift, x + outer * w * 0.85, y - h * 1.2 + lift, x + outer * w * 1.22, y - h * 0.62 + lift);
|
|
70
|
-
ctx.lineTo(x + outer * w * 1.42, y - h * 0.72 + lift);
|
|
71
|
-
ctx.lineTo(x + outer * w * 1.08, y - h * 0.3 + lift);
|
|
72
|
-
ctx.bezierCurveTo(x + outer * w * 0.8, y - h * 0.92 + lift, x - outer * w * 0.8, y - h * 0.86 + lift, x - outer * w * 1.02, y - h * 0.2 + lift);
|
|
73
|
-
ctx.closePath();
|
|
74
|
-
ctx.fill();
|
|
75
|
-
}
|
|
76
|
-
function lowerLash(ctx, x, y, side) {
|
|
77
|
-
const w = EYE_W / 2;
|
|
78
|
-
const h = EYE_H / 2;
|
|
79
|
-
ctx.strokeStyle = LASH;
|
|
80
|
-
ctx.lineWidth = 3;
|
|
81
|
-
ctx.lineCap = "round";
|
|
82
|
-
ctx.beginPath();
|
|
83
|
-
ctx.moveTo(x + side * w * 0.95, y + h * 0.35);
|
|
84
|
-
ctx.quadraticCurveTo(x + side * w * 0.6, y + h * 0.95, x + side * w * 0.05, y + h * 1);
|
|
85
|
-
ctx.stroke();
|
|
86
|
-
}
|
|
87
|
-
function openEye(ctx, x, y, side, iris, { pupil = 1, wet = false, catchlights = 2, squint = 0 } = {}) {
|
|
88
|
-
ctx.save();
|
|
89
|
-
eyeShape(ctx, x, y, side);
|
|
90
|
-
ctx.fillStyle = "#fffaff";
|
|
91
|
-
ctx.fill();
|
|
92
|
-
ctx.clip();
|
|
93
|
-
const ix = x + side * 2;
|
|
94
|
-
const iy = y + 6;
|
|
95
|
-
const irx = EYE_W * 0.4;
|
|
96
|
-
const iry = EYE_H * 0.47;
|
|
97
|
-
const gradient = ctx.createLinearGradient(0, iy - iry, 0, iy + iry);
|
|
98
|
-
gradient.addColorStop(0, mix(iris, "#100818", 0.55));
|
|
99
|
-
gradient.addColorStop(0.55, iris);
|
|
100
|
-
gradient.addColorStop(1, mix(iris, "#ffffff", 0.55));
|
|
101
|
-
ellipse(ctx, ix, iy, irx, iry);
|
|
102
|
-
ctx.fillStyle = gradient;
|
|
103
|
-
ctx.fill();
|
|
104
|
-
ctx.lineWidth = 3;
|
|
105
|
-
ctx.strokeStyle = mix(iris, "#100818", 0.6);
|
|
106
|
-
ctx.stroke();
|
|
107
|
-
ellipse(ctx, ix, iy + 2, irx * 0.42 * pupil, iry * 0.46 * pupil);
|
|
108
|
-
ctx.fillStyle = mix(iris, "#0a0410", 0.8);
|
|
109
|
-
ctx.fill();
|
|
110
|
-
ellipse(ctx, ix, iy + iry * 0.5, irx * 0.6, iry * 0.28);
|
|
111
|
-
ctx.fillStyle = `${mix(iris, "#ffffff", 0.7)}88`;
|
|
112
|
-
ctx.fill();
|
|
113
|
-
ctx.fillStyle = "rgba(40, 20, 70, 0.35)";
|
|
114
|
-
ctx.fillRect(x - EYE_W, y - EYE_H, EYE_W * 2, EYE_H * 0.42 + squint);
|
|
115
|
-
ctx.restore();
|
|
116
|
-
ctx.fillStyle = "#ffffff";
|
|
117
|
-
if (catchlights > 0) {
|
|
118
|
-
ellipse(ctx, ix - side * irx * 0.4, iy - iry * 0.4, irx * 0.34, iry * 0.26);
|
|
119
|
-
ctx.fill();
|
|
120
|
-
}
|
|
121
|
-
if (catchlights > 1) {
|
|
122
|
-
ellipse(ctx, ix + side * irx * 0.42, iy + iry * 0.38, irx * 0.14, iry * 0.1);
|
|
123
|
-
ctx.fill();
|
|
124
|
-
}
|
|
125
|
-
if (wet) {
|
|
126
|
-
ctx.globalAlpha = 0.8;
|
|
127
|
-
ellipse(ctx, ix, iy + iry * 0.62, irx * 0.75, iry * 0.12);
|
|
128
|
-
ctx.fill();
|
|
129
|
-
ctx.globalAlpha = 1;
|
|
130
|
-
}
|
|
131
|
-
lashes(ctx, x, y, side, squint);
|
|
132
|
-
lowerLash(ctx, x, y, side);
|
|
133
|
-
}
|
|
134
|
-
function closedEye(ctx, x, y, side, happy) {
|
|
135
|
-
const w = EYE_W / 2;
|
|
136
|
-
ctx.strokeStyle = LASH;
|
|
137
|
-
ctx.lineWidth = 7;
|
|
138
|
-
ctx.lineCap = "round";
|
|
139
|
-
ctx.beginPath();
|
|
140
|
-
if (happy) {
|
|
141
|
-
ctx.moveTo(x - w, y + 10);
|
|
142
|
-
ctx.quadraticCurveTo(x, y - 26, x + w, y + 10);
|
|
143
|
-
} else {
|
|
144
|
-
ctx.moveTo(x - w, y + 2);
|
|
145
|
-
ctx.quadraticCurveTo(x, y + 22, x + w, y + 2);
|
|
146
|
-
ctx.moveTo(x + side * w, y + 2);
|
|
147
|
-
ctx.lineTo(x + side * w * 1.3, y - 6);
|
|
148
|
-
}
|
|
149
|
-
ctx.stroke();
|
|
150
|
-
}
|
|
151
|
-
function star(ctx, x, y, r, color) {
|
|
152
|
-
ctx.beginPath();
|
|
153
|
-
for (let i = 0;i < 10; i += 1) {
|
|
154
|
-
const a = i / 10 * Math.PI * 2 - Math.PI / 2;
|
|
155
|
-
const k = i % 2 ? r * 0.45 : r;
|
|
156
|
-
ctx.lineTo(x + Math.cos(a) * k, y + Math.sin(a) * k);
|
|
157
|
-
}
|
|
158
|
-
ctx.closePath();
|
|
159
|
-
ctx.fillStyle = color;
|
|
160
|
-
ctx.fill();
|
|
161
|
-
}
|
|
162
|
-
function eye(ctx, side, parts, iris) {
|
|
163
|
-
const x = W / 2 + side * EYE_X;
|
|
164
|
-
const y = EYE_Y;
|
|
165
|
-
switch (parts.eyes) {
|
|
166
|
-
case "closed":
|
|
167
|
-
return closedEye(ctx, x, y, side, false);
|
|
168
|
-
case "happy":
|
|
169
|
-
return closedEye(ctx, x, y, side, true);
|
|
170
|
-
case "wink":
|
|
171
|
-
return side > 0 ? closedEye(ctx, x, y, side, true) : openEye(ctx, x, y, side, iris);
|
|
172
|
-
case "wide":
|
|
173
|
-
return openEye(ctx, x, y, side, iris, { pupil: 0.45, catchlights: 1 });
|
|
174
|
-
case "sad":
|
|
175
|
-
case "cry":
|
|
176
|
-
return openEye(ctx, x, y, side, iris, { wet: true, pupil: 1.1 });
|
|
177
|
-
case "half":
|
|
178
|
-
openEye(ctx, x, y, side, iris, { squint: 26 });
|
|
179
|
-
return;
|
|
180
|
-
case "angry":
|
|
181
|
-
openEye(ctx, x, y, side, iris, { catchlights: 0, squint: 14, pupil: 0.7 });
|
|
182
|
-
return;
|
|
183
|
-
case "stars":
|
|
184
|
-
openEye(ctx, x, y, side, iris, { catchlights: 0 });
|
|
185
|
-
star(ctx, x + side * 2, y + 6, 22, "#fff4a8");
|
|
186
|
-
return;
|
|
187
|
-
case "dead": {
|
|
188
|
-
ctx.strokeStyle = LASH;
|
|
189
|
-
ctx.lineWidth = 7;
|
|
190
|
-
ctx.lineCap = "round";
|
|
191
|
-
ctx.beginPath();
|
|
192
|
-
ctx.moveTo(x - 20, y - 20);
|
|
193
|
-
ctx.lineTo(x + 20, y + 20);
|
|
194
|
-
ctx.moveTo(x + 20, y - 20);
|
|
195
|
-
ctx.lineTo(x - 20, y + 20);
|
|
196
|
-
ctx.stroke();
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
default:
|
|
200
|
-
openEye(ctx, x, y, side, iris);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function brow(ctx, side, brows) {
|
|
204
|
-
if (brows === "none")
|
|
205
|
-
return;
|
|
206
|
-
const x = W / 2 + side * EYE_X;
|
|
207
|
-
const y = EYE_Y - EYE_H * 0.72;
|
|
208
|
-
const tilt = brows === "angry" ? 16 : brows === "sad" ? -12 : 0;
|
|
209
|
-
const lift = brows === "up" ? -6 : 0;
|
|
210
|
-
ctx.strokeStyle = mix(LASH, "#ffffff", 0.15);
|
|
211
|
-
ctx.lineWidth = 4;
|
|
212
|
-
ctx.lineCap = "round";
|
|
213
|
-
ctx.beginPath();
|
|
214
|
-
ctx.moveTo(x - side * 22, y + lift + tilt);
|
|
215
|
-
ctx.quadraticCurveTo(x, y + lift - 6, x + side * 22, y + lift - tilt * 0.2);
|
|
216
|
-
ctx.stroke();
|
|
217
|
-
}
|
|
218
|
-
function mouth(ctx, shape) {
|
|
219
|
-
const x = W / 2;
|
|
220
|
-
const y = MOUTH_Y;
|
|
221
|
-
ctx.strokeStyle = INK;
|
|
222
|
-
ctx.lineWidth = 4;
|
|
223
|
-
ctx.lineCap = "round";
|
|
224
|
-
ctx.lineJoin = "round";
|
|
225
|
-
const fillOpen = (w, h, round = false) => {
|
|
226
|
-
ctx.beginPath();
|
|
227
|
-
if (round)
|
|
228
|
-
ctx.ellipse(x, y + h / 2, w, h / 2 + 2, 0, 0, Math.PI * 2);
|
|
229
|
-
else {
|
|
230
|
-
ctx.moveTo(x - w, y);
|
|
231
|
-
ctx.quadraticCurveTo(x, y + h * 2, x + w, y);
|
|
232
|
-
ctx.closePath();
|
|
233
|
-
}
|
|
234
|
-
ctx.fillStyle = "#8a2a3e";
|
|
235
|
-
ctx.fill();
|
|
236
|
-
ctx.stroke();
|
|
237
|
-
ctx.save();
|
|
238
|
-
ctx.clip();
|
|
239
|
-
ellipse(ctx, x, y + h * 1.05, w * 0.6, h * 0.5);
|
|
240
|
-
ctx.fillStyle = "#f07a95";
|
|
241
|
-
ctx.fill();
|
|
242
|
-
ctx.restore();
|
|
243
|
-
};
|
|
244
|
-
ctx.beginPath();
|
|
245
|
-
switch (shape) {
|
|
246
|
-
case "smile":
|
|
247
|
-
ctx.moveTo(x - 10, y);
|
|
248
|
-
ctx.quadraticCurveTo(x, y + 8, x + 10, y);
|
|
249
|
-
ctx.stroke();
|
|
250
|
-
return;
|
|
251
|
-
case "cat":
|
|
252
|
-
ctx.moveTo(x - 14, y - 2);
|
|
253
|
-
ctx.quadraticCurveTo(x - 7, y + 9, x, y);
|
|
254
|
-
ctx.quadraticCurveTo(x + 7, y + 9, x + 14, y - 2);
|
|
255
|
-
ctx.stroke();
|
|
256
|
-
return;
|
|
257
|
-
case "open":
|
|
258
|
-
return fillOpen(13, 11);
|
|
259
|
-
case "grin":
|
|
260
|
-
return fillOpen(18, 12);
|
|
261
|
-
case "yell":
|
|
262
|
-
return fillOpen(16, 22, true);
|
|
263
|
-
case "o":
|
|
264
|
-
return fillOpen(8, 14, true);
|
|
265
|
-
case "frown":
|
|
266
|
-
ctx.moveTo(x - 10, y + 6);
|
|
267
|
-
ctx.quadraticCurveTo(x, y - 3, x + 10, y + 6);
|
|
268
|
-
ctx.stroke();
|
|
269
|
-
return;
|
|
270
|
-
case "smirk":
|
|
271
|
-
ctx.moveTo(x - 8, y + 3);
|
|
272
|
-
ctx.quadraticCurveTo(x + 6, y + 6, x + 14, y - 4);
|
|
273
|
-
ctx.stroke();
|
|
274
|
-
return;
|
|
275
|
-
case "tongue":
|
|
276
|
-
ctx.moveTo(x - 12, y);
|
|
277
|
-
ctx.quadraticCurveTo(x, y + 8, x + 12, y);
|
|
278
|
-
ctx.stroke();
|
|
279
|
-
ellipse(ctx, x + 4, y + 8, 7, 8);
|
|
280
|
-
ctx.fillStyle = "#f07a95";
|
|
281
|
-
ctx.fill();
|
|
282
|
-
ctx.stroke();
|
|
283
|
-
return;
|
|
284
|
-
default:
|
|
285
|
-
ctx.moveTo(x - 9, y + 2);
|
|
286
|
-
ctx.lineTo(x + 9, y + 2);
|
|
287
|
-
ctx.stroke();
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function blush(ctx, amount) {
|
|
291
|
-
if (amount <= 0)
|
|
292
|
-
return;
|
|
293
|
-
for (const side of [-1, 1]) {
|
|
294
|
-
const x = W / 2 + side * (EYE_X + 14);
|
|
295
|
-
const y = EYE_Y + EYE_H * 0.72;
|
|
296
|
-
const glow = ctx.createRadialGradient(x, y, 2, x, y, 34);
|
|
297
|
-
glow.addColorStop(0, `rgba(255, 120, 150, ${0.55 * amount})`);
|
|
298
|
-
glow.addColorStop(1, "rgba(255, 120, 150, 0)");
|
|
299
|
-
ctx.fillStyle = glow;
|
|
300
|
-
ctx.fillRect(x - 40, y - 26, 80, 52);
|
|
301
|
-
ctx.strokeStyle = `rgba(230, 80, 120, ${0.7 * amount})`;
|
|
302
|
-
ctx.lineWidth = 2.5;
|
|
303
|
-
ctx.lineCap = "round";
|
|
304
|
-
for (let i = -1;i <= 1; i += 1) {
|
|
305
|
-
ctx.beginPath();
|
|
306
|
-
ctx.moveTo(x + i * 10 - 3, y + 5);
|
|
307
|
-
ctx.lineTo(x + i * 10 + 4, y - 5);
|
|
308
|
-
ctx.stroke();
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function tears(ctx) {
|
|
313
|
-
for (const side of [-1, 1]) {
|
|
314
|
-
const x = W / 2 + side * (EYE_X - 8);
|
|
315
|
-
const y = EYE_Y + EYE_H * 0.5;
|
|
316
|
-
ctx.fillStyle = "rgba(140, 220, 255, 0.85)";
|
|
317
|
-
ctx.beginPath();
|
|
318
|
-
ctx.moveTo(x, y);
|
|
319
|
-
ctx.quadraticCurveTo(x + side * 10, y + 30, x, y + 44);
|
|
320
|
-
ctx.quadraticCurveTo(x - side * 8, y + 30, x, y);
|
|
321
|
-
ctx.fill();
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function drawAnimeFace(ctx, face, iris = "#6a4cff") {
|
|
325
|
-
ctx.clearRect(0, 0, W, H);
|
|
326
|
-
const parts = animeFaceParts(face);
|
|
327
|
-
blush(ctx, parts.blush);
|
|
328
|
-
for (const side of [-1, 1]) {
|
|
329
|
-
eye(ctx, side, parts, iris);
|
|
330
|
-
brow(ctx, side, parts.brows);
|
|
331
|
-
}
|
|
332
|
-
if (parts.tears)
|
|
333
|
-
tears(ctx);
|
|
334
|
-
mouth(ctx, parts.mouth);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export { ANIME_FACE_SIZE, ANIME_FACE_UV, animeFaceParts, ANIME_EYE_LINE, drawAnimeFace };
|
package/dist/chunk-dpb0rnw9.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/blob.ts
|
|
2
|
-
import { SphereGeometry } from "three";
|
|
3
|
-
var BLOB_RADIUS = { x: 0.6, y: 0.56, z: 0.58 };
|
|
4
|
-
var BLOB_HEIGHT = BLOB_RADIUS.y * (1 + 0.62 + (1 - 0.62) * 0.3);
|
|
5
|
-
var ROUND = { shoulders: 1, waist: 1, hips: 1 };
|
|
6
|
-
var bump = (at, centre, spread) => Math.exp(-(((at - centre) / spread) ** 2));
|
|
7
|
-
function silhouetteAt(unitY, silhouette = ROUND) {
|
|
8
|
-
const shoulders = bump(unitY, -0.2, 0.2);
|
|
9
|
-
const waist = bump(unitY, -0.42, 0.12);
|
|
10
|
-
const hips = bump(unitY, -0.58, 0.14);
|
|
11
|
-
const rest = 0.35;
|
|
12
|
-
return (rest + shoulders * silhouette.shoulders + waist * silhouette.waist + hips * silhouette.hips) / (rest + shoulders + waist + hips);
|
|
13
|
-
}
|
|
14
|
-
var BLOB_SEAT = BLOB_RADIUS.y * (0.62 + (1 - 0.62) * 0.3);
|
|
15
|
-
function blobRadiusAt(y, silhouette = ROUND) {
|
|
16
|
-
const unit = Math.max(-0.62, Math.min(1, (y - BLOB_SEAT) / BLOB_RADIUS.y));
|
|
17
|
-
return Math.sqrt(Math.max(0, 1 - unit * unit)) * (1 + 0.16 * -unit) * BLOB_RADIUS.x * silhouetteAt(unit, silhouette);
|
|
18
|
-
}
|
|
19
|
-
function buildBlobGeometry(silhouette = ROUND) {
|
|
20
|
-
const geometry = new SphereGeometry(1, 40, 28);
|
|
21
|
-
const position = geometry.attributes.position;
|
|
22
|
-
let minY = Number.POSITIVE_INFINITY;
|
|
23
|
-
for (let i = 0;i < position.count; i += 1) {
|
|
24
|
-
let y = position.getY(i);
|
|
25
|
-
const spread = (1 + 0.16 * -y) * silhouetteAt(y, silhouette);
|
|
26
|
-
if (y < -0.62)
|
|
27
|
-
y = -0.62 + (y + 0.62) * 0.3;
|
|
28
|
-
position.setXYZ(i, position.getX(i) * spread * BLOB_RADIUS.x, y * BLOB_RADIUS.y, position.getZ(i) * spread * BLOB_RADIUS.z);
|
|
29
|
-
minY = Math.min(minY, y * BLOB_RADIUS.y);
|
|
30
|
-
}
|
|
31
|
-
geometry.translate(0, -minY, 0);
|
|
32
|
-
geometry.computeBoundingBox();
|
|
33
|
-
geometry.computeVertexNormals();
|
|
34
|
-
return geometry;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { BLOB_RADIUS, BLOB_HEIGHT, ROUND, silhouetteAt, BLOB_SEAT, blobRadiusAt, buildBlobGeometry };
|