@plupin/character 0.0.0-stage → 0.2.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/canvas.d.ts +79 -0
- package/dist/canvas.js +315 -0
- package/dist/chunk-aa5nstet.js +39 -0
- package/dist/chunk-ae7gp5cc.js +101 -0
- package/dist/chunk-k5gwaq6t.js +315 -0
- package/dist/chunk-wpbgtn0y.js +179 -0
- package/dist/clip-bake.d.ts +48 -0
- package/dist/clip-bake.js +132 -0
- package/dist/emote.d.ts +23 -0
- package/dist/faces.d.ts +10 -0
- package/dist/faces.js +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +102 -0
- package/dist/listing.d.ts +195 -0
- package/dist/listing.js +753 -0
- package/dist/named-faces.d.ts +22 -0
- package/dist/plup2d.d.ts +29 -0
- package/dist/plup3d.d.ts +73 -0
- package/dist/png.d.ts +61 -0
- package/dist/pose.d.ts +43 -0
- package/dist/pose.js +18 -0
- package/dist/rig.d.ts +29 -0
- package/dist/skin-native.d.ts +252 -0
- package/dist/skin.d.ts +35 -0
- package/dist/three.d.ts +22 -0
- package/dist/three.js +581 -0
- package/package.json +58 -4
- package/README.md +0 -3
package/dist/canvas.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type NamedFace } from "./faces";
|
|
2
|
+
import { type PlupOptions2D } from "./plup2d";
|
|
3
|
+
export type { PlupOptions2D };
|
|
4
|
+
import { type ClipRef, type Pose } from "./pose";
|
|
5
|
+
import { type RigId } from "./rig";
|
|
6
|
+
import type { Rect } from "./skin";
|
|
7
|
+
import { type BodyScale, type CharacterLook, type SkinImage } from "./skin-native";
|
|
8
|
+
export type View2D = "front" | "side";
|
|
9
|
+
export interface Draw2DOptions {
|
|
10
|
+
/** Default `plup`: the mascot. The Roblox rigs (`r6`, `r15`) are for people who bring a Roblox avatar. */
|
|
11
|
+
rig?: RigId;
|
|
12
|
+
/** The named face Plup wears in 2D. */
|
|
13
|
+
face?: NamedFace;
|
|
14
|
+
look: CharacterLook;
|
|
15
|
+
/**
|
|
16
|
+
* The clamped proportions to draw: stature, per-part width and head size. Visual only, so the
|
|
17
|
+
* same clip drives every scale and `canonicalFootprint` stays what a game collides with.
|
|
18
|
+
*/
|
|
19
|
+
bodyScale?: Partial<BodyScale> | null;
|
|
20
|
+
/** Canvas position of the character's feet. */
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
/** Canvas pixels per stud. */
|
|
24
|
+
scale: number;
|
|
25
|
+
view?: View2D;
|
|
26
|
+
clip?: ClipRef;
|
|
27
|
+
seconds?: number;
|
|
28
|
+
/** Layered over the clip. */
|
|
29
|
+
pose?: Pose;
|
|
30
|
+
flip?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** A 2 x 3 canvas transform in canvas order: x' = a*x + c*y + e, y' = b*x + d*y + f. */
|
|
33
|
+
export type Matrix = readonly [number, number, number, number, number, number];
|
|
34
|
+
export type DrawPaint = {
|
|
35
|
+
kind: "fill";
|
|
36
|
+
color: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "image";
|
|
39
|
+
image: SkinImage;
|
|
40
|
+
source: Rect;
|
|
41
|
+
};
|
|
42
|
+
export interface DrawOp {
|
|
43
|
+
/** The bone this op paints. */
|
|
44
|
+
bone: string;
|
|
45
|
+
/** Canvas transform the op paints under, already composed from the rig and the pose. */
|
|
46
|
+
matrix: Matrix;
|
|
47
|
+
/**
|
|
48
|
+
* The part rect in bone-local space. Nothing an op paints lands outside it, which is what keeps
|
|
49
|
+
* a variant's silhouette inside its part and its bones the length the rig says.
|
|
50
|
+
*/
|
|
51
|
+
clip: Rect;
|
|
52
|
+
paint: DrawPaint;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The whole draw, as data: every rectangle a frame paints and under which transform. The 2D
|
|
56
|
+
* canvas renderer is the executor of this list, so a test that rasterises it sees exactly what a
|
|
57
|
+
* screen sees, and each op's clip rect is the ceiling a body variant cannot cross.
|
|
58
|
+
*/
|
|
59
|
+
export declare function planCharacter2D(options: Draw2DOptions): readonly DrawOp[];
|
|
60
|
+
/**
|
|
61
|
+
* Draws a character flat onto a 2D canvas: one call a frame, no scene and no WebGL. The same rig,
|
|
62
|
+
* clips, poses and skins as the 3D renderer.
|
|
63
|
+
*/
|
|
64
|
+
export declare function drawCharacter2D(context: CanvasRenderingContext2D, options: Draw2DOptions): void;
|
|
65
|
+
/**
|
|
66
|
+
* Maps a Roblox classic shirt/pants pair onto the native grid: the image a look passes as
|
|
67
|
+
* `native`. A classic template carries no head skin, so the head faces stay transparent and the
|
|
68
|
+
* rig's skin tone shows through, exactly as it does on Roblox.
|
|
69
|
+
*/
|
|
70
|
+
export declare function convertClassicToNative(images: {
|
|
71
|
+
shirt?: SkinImage | null;
|
|
72
|
+
pants?: SkinImage | null;
|
|
73
|
+
}): HTMLCanvasElement;
|
|
74
|
+
/**
|
|
75
|
+
* A named face (`emote.face`) drawn on a square canvas of `size` px, ready to pass as `look.face`
|
|
76
|
+
* to `createCharacter`. The stamp sits where the app's own face sits; the rest is transparent, so the
|
|
77
|
+
* body colour shows through.
|
|
78
|
+
*/
|
|
79
|
+
export declare function faceCanvas(face: NamedFace, size?: number): HTMLCanvasElement;
|
package/dist/canvas.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLASSIC_TO_NATIVE,
|
|
3
|
+
NATIVE_HEIGHT,
|
|
4
|
+
NATIVE_WIDTH,
|
|
5
|
+
boneSkin,
|
|
6
|
+
clampBodyScale,
|
|
7
|
+
nativePartOf,
|
|
8
|
+
scaleBone
|
|
9
|
+
} from "./chunk-k5gwaq6t.js";
|
|
10
|
+
import {
|
|
11
|
+
FACE_STAMP_PALETTE,
|
|
12
|
+
NAMED_FACES,
|
|
13
|
+
NAMED_FACE_STAMPS
|
|
14
|
+
} from "./chunk-aa5nstet.js";
|
|
15
|
+
import {
|
|
16
|
+
RIGS,
|
|
17
|
+
clipLift,
|
|
18
|
+
mergePoses,
|
|
19
|
+
resolvePose,
|
|
20
|
+
sampleClip
|
|
21
|
+
} from "./chunk-wpbgtn0y.js";
|
|
22
|
+
|
|
23
|
+
// src/plup2d.ts
|
|
24
|
+
var hex = (color) => {
|
|
25
|
+
const value = color.replace("#", "");
|
|
26
|
+
const full = value.length === 3 ? [...value].map((c) => c + c).join("") : value;
|
|
27
|
+
return [0, 2, 4].map((at) => Number.parseInt(full.slice(at, at + 2), 16));
|
|
28
|
+
};
|
|
29
|
+
var mix = (a, b, t) => {
|
|
30
|
+
const [r1, g1, b1] = hex(a);
|
|
31
|
+
const [r2, g2, b2] = hex(b);
|
|
32
|
+
const at = (x, y) => Math.round(x + (y - x) * t);
|
|
33
|
+
return `rgb(${at(r1, r2)},${at(g1, g2)},${at(b1, b2)})`;
|
|
34
|
+
};
|
|
35
|
+
var ORDER = ["LeftLeg", "RightLeg", "Body", "LeftArm", "RightArm"];
|
|
36
|
+
var scratch = null;
|
|
37
|
+
function roundRect(ctx, x, y, w, h, r) {
|
|
38
|
+
const radius = Math.min(r, w / 2, h / 2);
|
|
39
|
+
ctx.beginPath();
|
|
40
|
+
ctx.moveTo(x + radius, y);
|
|
41
|
+
ctx.arcTo(x + w, y, x + w, y + h, radius);
|
|
42
|
+
ctx.arcTo(x + w, y + h, x, y + h, radius);
|
|
43
|
+
ctx.arcTo(x, y + h, x, y, radius);
|
|
44
|
+
ctx.arcTo(x, y, x + w, y, radius);
|
|
45
|
+
ctx.closePath();
|
|
46
|
+
}
|
|
47
|
+
function bodyPath(ctx, x, y, w, h) {
|
|
48
|
+
const cx = x + w / 2;
|
|
49
|
+
ctx.beginPath();
|
|
50
|
+
ctx.moveTo(x + w * 0.04, y + h * 0.82);
|
|
51
|
+
ctx.bezierCurveTo(x - w * 0.02, y + h * 0.2, x + w * 0.2, y, cx, y);
|
|
52
|
+
ctx.bezierCurveTo(x + w * 0.8, y, x + w * 1.02, y + h * 0.2, x + w * 0.96, y + h * 0.82);
|
|
53
|
+
ctx.quadraticCurveTo(x + w * 0.96, y + h, x + w * 0.8, y + h);
|
|
54
|
+
ctx.lineTo(x + w * 0.2, y + h);
|
|
55
|
+
ctx.quadraticCurveTo(x + w * 0.04, y + h, x + w * 0.04, y + h * 0.82);
|
|
56
|
+
ctx.closePath();
|
|
57
|
+
}
|
|
58
|
+
function paintBone(ctx, op, color, ink, face) {
|
|
59
|
+
const { x, y, w, h } = op.clip;
|
|
60
|
+
ctx.save();
|
|
61
|
+
ctx.setTransform(...op.matrix);
|
|
62
|
+
ctx.lineJoin = "round";
|
|
63
|
+
ctx.lineWidth = 0.14;
|
|
64
|
+
if (op.bone === "Body") {
|
|
65
|
+
bodyPath(ctx, x, y, w, h);
|
|
66
|
+
ctx.fillStyle = color;
|
|
67
|
+
ctx.fill();
|
|
68
|
+
ctx.save();
|
|
69
|
+
ctx.clip();
|
|
70
|
+
ctx.fillStyle = mix(color, "#ffffff", 0.45);
|
|
71
|
+
ctx.fillRect(x, y + h * 0.66, w, h * 0.4);
|
|
72
|
+
ctx.fillStyle = mix(color, "#000000", 0.16);
|
|
73
|
+
ctx.beginPath();
|
|
74
|
+
ctx.ellipse(x + w * 1.02, y + h * 0.5, w * 0.22, h * 0.62, 0, 0, Math.PI * 2);
|
|
75
|
+
ctx.fill();
|
|
76
|
+
ctx.fillStyle = mix(color, "#ffffff", 0.7);
|
|
77
|
+
ctx.beginPath();
|
|
78
|
+
ctx.ellipse(x + w * 0.27, y + h * 0.2, w * 0.12, h * 0.07, -0.6, 0, Math.PI * 2);
|
|
79
|
+
ctx.fill();
|
|
80
|
+
ctx.restore();
|
|
81
|
+
bodyPath(ctx, x, y, w, h);
|
|
82
|
+
ctx.strokeStyle = ink;
|
|
83
|
+
ctx.stroke();
|
|
84
|
+
const stamp = faceCanvas(face, 32);
|
|
85
|
+
const faceW = w * 0.82;
|
|
86
|
+
ctx.imageSmoothingEnabled = false;
|
|
87
|
+
ctx.drawImage(stamp, 0, 0, 32, 16, x + (w - faceW) / 2, y + h * 0.2, faceW, faceW / 2);
|
|
88
|
+
} else {
|
|
89
|
+
const arm = op.bone.endsWith("Arm");
|
|
90
|
+
roundRect(ctx, x, y, w, h, arm ? w / 2 : w * 0.42);
|
|
91
|
+
ctx.fillStyle = arm ? color : mix(color, "#000000", 0.08);
|
|
92
|
+
ctx.fill();
|
|
93
|
+
ctx.strokeStyle = ink;
|
|
94
|
+
ctx.stroke();
|
|
95
|
+
}
|
|
96
|
+
ctx.restore();
|
|
97
|
+
}
|
|
98
|
+
function drawPlup2D(ctx, options) {
|
|
99
|
+
const {
|
|
100
|
+
color,
|
|
101
|
+
x,
|
|
102
|
+
y,
|
|
103
|
+
scale,
|
|
104
|
+
clip = "idle",
|
|
105
|
+
seconds = 0,
|
|
106
|
+
shadow = true,
|
|
107
|
+
squash,
|
|
108
|
+
flip = false
|
|
109
|
+
} = options;
|
|
110
|
+
const ppu = options.ppu ?? 12;
|
|
111
|
+
const face = options.face && NAMED_FACES.includes(options.face) ? options.face : "smug";
|
|
112
|
+
const ink = mix(color, "#161923", 0.72);
|
|
113
|
+
const width = Math.ceil((2.6 + 4.4) * ppu);
|
|
114
|
+
const height = Math.ceil((3.4 + 3.4 + 1.2) * ppu);
|
|
115
|
+
scratch ??= document.createElement("canvas");
|
|
116
|
+
if (scratch.width !== width || scratch.height !== height) {
|
|
117
|
+
scratch.width = width;
|
|
118
|
+
scratch.height = height;
|
|
119
|
+
}
|
|
120
|
+
const bctx = scratch.getContext("2d", { willReadFrequently: true });
|
|
121
|
+
if (!bctx)
|
|
122
|
+
return;
|
|
123
|
+
bctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
124
|
+
bctx.clearRect(0, 0, width, height);
|
|
125
|
+
const floor = height - 1.2 * ppu;
|
|
126
|
+
const ops = planCharacter2D({
|
|
127
|
+
rig: "plup",
|
|
128
|
+
look: { bodyColor: color },
|
|
129
|
+
x: width / 2,
|
|
130
|
+
y: floor,
|
|
131
|
+
scale: ppu,
|
|
132
|
+
view: "front",
|
|
133
|
+
clip,
|
|
134
|
+
seconds,
|
|
135
|
+
...options.pose ? { pose: options.pose } : {}
|
|
136
|
+
});
|
|
137
|
+
for (const bone of ORDER) {
|
|
138
|
+
const op = ops.find((candidate) => candidate.bone === bone && candidate.paint.kind === "fill");
|
|
139
|
+
if (op)
|
|
140
|
+
paintBone(bctx, op, color, ink, face);
|
|
141
|
+
}
|
|
142
|
+
const pixels = bctx.getImageData(0, 0, width, height);
|
|
143
|
+
for (let at = 3;at < pixels.data.length; at += 4)
|
|
144
|
+
pixels.data[at] = (pixels.data[at] ?? 0) > 120 ? 255 : 0;
|
|
145
|
+
bctx.putImageData(pixels, 0, 0);
|
|
146
|
+
const zoom = scale / ppu;
|
|
147
|
+
ctx.save();
|
|
148
|
+
ctx.imageSmoothingEnabled = false;
|
|
149
|
+
ctx.translate(x, y);
|
|
150
|
+
if (flip)
|
|
151
|
+
ctx.scale(-1, 1);
|
|
152
|
+
if (shadow) {
|
|
153
|
+
ctx.fillStyle = "rgba(10, 6, 24, 0.32)";
|
|
154
|
+
ctx.beginPath();
|
|
155
|
+
ctx.ellipse(0, 0, scale * 1.35, scale * 0.3, 0, 0, Math.PI * 2);
|
|
156
|
+
ctx.fill();
|
|
157
|
+
}
|
|
158
|
+
if (squash)
|
|
159
|
+
ctx.scale(squash.x, squash.y);
|
|
160
|
+
ctx.drawImage(scratch, -width / 2 * zoom, -floor * zoom, width * zoom, height * zoom);
|
|
161
|
+
ctx.restore();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/canvas.ts
|
|
165
|
+
var compose = (m, n) => [
|
|
166
|
+
m[0] * n[0] + m[2] * n[1],
|
|
167
|
+
m[1] * n[0] + m[3] * n[1],
|
|
168
|
+
m[0] * n[2] + m[2] * n[3],
|
|
169
|
+
m[1] * n[2] + m[3] * n[3],
|
|
170
|
+
m[0] * n[4] + m[2] * n[5] + m[4],
|
|
171
|
+
m[1] * n[4] + m[3] * n[5] + m[5]
|
|
172
|
+
];
|
|
173
|
+
var translate = (x, y) => [1, 0, 0, 1, x, y];
|
|
174
|
+
var scale = (x, y) => [x, 0, 0, y, 0, 0];
|
|
175
|
+
var rotate = (radians) => {
|
|
176
|
+
const cos = Math.cos(radians);
|
|
177
|
+
const sin = Math.sin(radians);
|
|
178
|
+
return [cos, sin, -sin, cos, 0, 0];
|
|
179
|
+
};
|
|
180
|
+
var boneColour = (bone, look) => bone === "Head" ? look.headColor ?? look.bodyColor : look.bodyColor;
|
|
181
|
+
function planCharacter2D(options) {
|
|
182
|
+
const {
|
|
183
|
+
rig: rigId = "plup",
|
|
184
|
+
look,
|
|
185
|
+
x,
|
|
186
|
+
y,
|
|
187
|
+
scale: size,
|
|
188
|
+
view = "front",
|
|
189
|
+
clip = "idle",
|
|
190
|
+
seconds = 0
|
|
191
|
+
} = options;
|
|
192
|
+
const rig = RIGS[rigId];
|
|
193
|
+
const body = clampBodyScale(options.bodyScale);
|
|
194
|
+
const pose = resolvePose(rigId, mergePoses(sampleClip(clip, seconds), options.pose ?? {}));
|
|
195
|
+
const lift = clipLift(clip, seconds) * body.stature;
|
|
196
|
+
const root = compose(translate(x, y - lift * size), scale(options.flip ? -size : size, size));
|
|
197
|
+
const children = (parent) => rig.bones.filter((bone) => bone.parent === parent);
|
|
198
|
+
const axis = view === "side" ? "x" : "z";
|
|
199
|
+
const face = view === "side" ? "right" : "front";
|
|
200
|
+
const ops = [];
|
|
201
|
+
const walk = (parent, parentMatrix) => {
|
|
202
|
+
for (const bone of children(parent)) {
|
|
203
|
+
const box = scaleBone(bone, nativePartOf(bone.name), bone.parent ? nativePartOf(bone.parent) : null, body);
|
|
204
|
+
const across = view === "side" ? box.joint[2] : box.joint[0];
|
|
205
|
+
const angle = -(pose.get(bone.name)?.[axis] ?? 0);
|
|
206
|
+
const matrix = compose(compose(parentMatrix, translate(across, -box.joint[1])), rotate(angle));
|
|
207
|
+
const width = view === "side" ? box.size[2] : box.size[0];
|
|
208
|
+
const centerAcross = view === "side" ? box.center[2] : box.center[0];
|
|
209
|
+
const part = {
|
|
210
|
+
x: centerAcross - width / 2,
|
|
211
|
+
y: -box.center[1] - box.size[1] / 2,
|
|
212
|
+
w: width,
|
|
213
|
+
h: box.size[1]
|
|
214
|
+
};
|
|
215
|
+
const skin = boneSkin(bone.name, face, look);
|
|
216
|
+
if (!skin?.redraw)
|
|
217
|
+
ops.push({
|
|
218
|
+
bone: bone.name,
|
|
219
|
+
matrix,
|
|
220
|
+
clip: part,
|
|
221
|
+
paint: { kind: "fill", color: boneColour(bone.name, look) }
|
|
222
|
+
});
|
|
223
|
+
if (skin)
|
|
224
|
+
ops.push({
|
|
225
|
+
bone: bone.name,
|
|
226
|
+
matrix,
|
|
227
|
+
clip: part,
|
|
228
|
+
paint: { kind: "image", image: skin.image, source: skin.source }
|
|
229
|
+
});
|
|
230
|
+
if (look.face && view === "front" && (bone.name === "Head" || bone.name === "Body"))
|
|
231
|
+
ops.push({
|
|
232
|
+
bone: bone.name,
|
|
233
|
+
matrix,
|
|
234
|
+
clip: part,
|
|
235
|
+
paint: { kind: "image", image: look.face, source: { x: 0, y: 0, w: 64, h: 64 } }
|
|
236
|
+
});
|
|
237
|
+
walk(bone.name, matrix);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
walk(null, root);
|
|
241
|
+
return ops;
|
|
242
|
+
}
|
|
243
|
+
function drawCharacter2D(context, options) {
|
|
244
|
+
if ((options.rig ?? "plup") === "plup" && !options.look.native && !options.look.variant) {
|
|
245
|
+
drawPlup2D(context, {
|
|
246
|
+
color: options.look.bodyColor,
|
|
247
|
+
...options.face ? { face: options.face } : {},
|
|
248
|
+
x: options.x,
|
|
249
|
+
y: options.y,
|
|
250
|
+
scale: options.scale,
|
|
251
|
+
...options.clip ? { clip: options.clip } : {},
|
|
252
|
+
...options.seconds === undefined ? {} : { seconds: options.seconds },
|
|
253
|
+
...options.pose ? { pose: options.pose } : {},
|
|
254
|
+
...options.flip ? { flip: true } : {}
|
|
255
|
+
});
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
context.save();
|
|
259
|
+
context.imageSmoothingEnabled = false;
|
|
260
|
+
for (const op of planCharacter2D(options)) {
|
|
261
|
+
context.save();
|
|
262
|
+
context.transform(...op.matrix);
|
|
263
|
+
context.beginPath();
|
|
264
|
+
context.rect(op.clip.x, op.clip.y, op.clip.w, op.clip.h);
|
|
265
|
+
context.clip();
|
|
266
|
+
if (op.paint.kind === "fill") {
|
|
267
|
+
context.fillStyle = op.paint.color;
|
|
268
|
+
context.fillRect(op.clip.x, op.clip.y, op.clip.w, op.clip.h);
|
|
269
|
+
} else
|
|
270
|
+
context.drawImage(op.paint.image, op.paint.source.x, op.paint.source.y, op.paint.source.w, op.paint.source.h, op.clip.x, op.clip.y, op.clip.w, op.clip.h);
|
|
271
|
+
context.restore();
|
|
272
|
+
}
|
|
273
|
+
context.restore();
|
|
274
|
+
}
|
|
275
|
+
function convertClassicToNative(images) {
|
|
276
|
+
const canvas = document.createElement("canvas");
|
|
277
|
+
canvas.width = NATIVE_WIDTH;
|
|
278
|
+
canvas.height = NATIVE_HEIGHT;
|
|
279
|
+
const context = canvas.getContext("2d");
|
|
280
|
+
if (context) {
|
|
281
|
+
context.imageSmoothingEnabled = false;
|
|
282
|
+
for (const op of CLASSIC_TO_NATIVE) {
|
|
283
|
+
const image = images[op.sheet];
|
|
284
|
+
if (!image)
|
|
285
|
+
continue;
|
|
286
|
+
context.drawImage(image, op.source.x, op.source.y, op.source.w, op.source.h, op.dest.x, op.dest.y, op.dest.w, op.dest.h);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return canvas;
|
|
290
|
+
}
|
|
291
|
+
function faceCanvas(face, size = 64) {
|
|
292
|
+
const canvas = document.createElement("canvas");
|
|
293
|
+
canvas.width = canvas.height = size;
|
|
294
|
+
const context = canvas.getContext("2d");
|
|
295
|
+
if (!context)
|
|
296
|
+
return canvas;
|
|
297
|
+
const cell = size / 8;
|
|
298
|
+
const top = (size - cell * 4) / 2;
|
|
299
|
+
NAMED_FACE_STAMPS[face].forEach((row, y) => {
|
|
300
|
+
for (const [x, key] of [...row].entries()) {
|
|
301
|
+
const color = FACE_STAMP_PALETTE[key];
|
|
302
|
+
if (!color)
|
|
303
|
+
continue;
|
|
304
|
+
context.fillStyle = color;
|
|
305
|
+
context.fillRect(x * cell, top + y * cell, cell, cell);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
return canvas;
|
|
309
|
+
}
|
|
310
|
+
export {
|
|
311
|
+
planCharacter2D,
|
|
312
|
+
faceCanvas,
|
|
313
|
+
drawCharacter2D,
|
|
314
|
+
convertClassicToNative
|
|
315
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/named-faces.ts
|
|
2
|
+
var NAMED_FACE_STAMPS = {
|
|
3
|
+
sparkle: [".ew..we.", ".ee..ee.", "p..mm..p", "........"],
|
|
4
|
+
shock: [".ee..ee.", ".ew..we.", "...mm...", "...mm..."],
|
|
5
|
+
yell: ["..e..e..", ".ew..we.", ".mmmmmm.", ".mttttm."],
|
|
6
|
+
pain: [".ee..ee.", "........", ".m.mm.m.", "..mmmm.."],
|
|
7
|
+
dead: ["www..www", "www..www", "..mmmm..", "........"],
|
|
8
|
+
rage: ["ee....ee", ".ee..ee.", ".mwwwwm.", "..mmmm.."],
|
|
9
|
+
speechless: ["........", ".e....e.", "........", "...mm..."],
|
|
10
|
+
idea: [".ee..ee.", ".ew..ew.", "..m..m..", "...mm..."],
|
|
11
|
+
smug: ["........", "eee..eee", "........", "..mmmm.."],
|
|
12
|
+
cry: ["eee..eee", "c......c", "c.mmmm.c", "..mttm.."],
|
|
13
|
+
smirk: [".ee..ee.", "........", "....mmm.", "........"],
|
|
14
|
+
tongue: ["........", ".ee..ee.", "...mm...", "...tt..."],
|
|
15
|
+
cool: ["eeeeeeee", ".ee..ee.", "..m..m..", "...mm..."],
|
|
16
|
+
serious: ["eee..eee", "ewe..ewe", "........", "..mmmm.."],
|
|
17
|
+
stars: [".y....y.", "yyy..yyy", "..mmmm..", "..mttm.."],
|
|
18
|
+
licik: [".ee..ee.", "........", ".mm..mm.", "..mmmm.."],
|
|
19
|
+
tidur: ["........", ".ee..ee.", "...mm...", "...mm..."],
|
|
20
|
+
teriak: ["..e..e..", ".e....e.", ".mmmmmm.", "..mttm.."],
|
|
21
|
+
ngomel: ["ee....ee", ".e....e.", "...mm...", "..m..m.."]
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/faces.ts
|
|
25
|
+
var NAMED_FACES = Object.keys(NAMED_FACE_STAMPS);
|
|
26
|
+
var FACE_STAMP_PALETTE = {
|
|
27
|
+
e: "#161923",
|
|
28
|
+
w: "#ffffff",
|
|
29
|
+
m: "#5a1f2a",
|
|
30
|
+
t: "#e8607a",
|
|
31
|
+
p: "#f08aa8",
|
|
32
|
+
y: "#f2d24b",
|
|
33
|
+
c: "#4cc9e2"
|
|
34
|
+
};
|
|
35
|
+
function isNamedFace(name) {
|
|
36
|
+
return Object.hasOwn(NAMED_FACE_STAMPS, name);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { NAMED_FACE_STAMPS, NAMED_FACES, FACE_STAMP_PALETTE, isNamedFace };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// src/emote.ts
|
|
2
|
+
var EMOTES = [
|
|
3
|
+
{
|
|
4
|
+
id: "emote-ngakak",
|
|
5
|
+
label: "Ngakak",
|
|
6
|
+
glyph: "(≧▽≦)",
|
|
7
|
+
face: "teriak",
|
|
8
|
+
clip: "jump",
|
|
9
|
+
sigmaPrice: 0
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: "emote-semangat",
|
|
13
|
+
label: "Semangat",
|
|
14
|
+
glyph: "٩(ˊᗜˋ)و",
|
|
15
|
+
face: "yell",
|
|
16
|
+
clip: "dance",
|
|
17
|
+
sigmaPrice: 0
|
|
18
|
+
},
|
|
19
|
+
{ id: "emote-keren", label: "Keren", glyph: "(⌐■_■)", face: "cool", clip: "idle", sigmaPrice: 0 },
|
|
20
|
+
{
|
|
21
|
+
id: "emote-marah",
|
|
22
|
+
label: "Marah",
|
|
23
|
+
glyph: "(╬ Ò﹏Ó)",
|
|
24
|
+
face: "rage",
|
|
25
|
+
clip: "idle",
|
|
26
|
+
sigmaPrice: 0
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "emote-nangis",
|
|
30
|
+
label: "Nangis",
|
|
31
|
+
glyph: "(╥﹏╥)",
|
|
32
|
+
face: "cry",
|
|
33
|
+
clip: "idle",
|
|
34
|
+
sigmaPrice: 0
|
|
35
|
+
},
|
|
36
|
+
{ id: "emote-kaget", label: "Kaget", glyph: "(⊙_⊙)", face: "shock", clip: "jump", sigmaPrice: 0 },
|
|
37
|
+
{
|
|
38
|
+
id: "emote-suka",
|
|
39
|
+
label: "Suka",
|
|
40
|
+
glyph: "(♡˙︶˙♡)",
|
|
41
|
+
face: "sparkle",
|
|
42
|
+
clip: "wave",
|
|
43
|
+
sigmaPrice: 0
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "emote-mantap",
|
|
47
|
+
label: "Mantap",
|
|
48
|
+
glyph: "(•̀ᴗ•́)و",
|
|
49
|
+
face: "smug",
|
|
50
|
+
clip: "wave",
|
|
51
|
+
sigmaPrice: 0
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "emote-meledek",
|
|
55
|
+
label: "Meledek",
|
|
56
|
+
glyph: "(^_-)",
|
|
57
|
+
face: "tongue",
|
|
58
|
+
clip: "wave",
|
|
59
|
+
sigmaPrice: 15
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "emote-ide",
|
|
63
|
+
label: "Ide Cemerlang",
|
|
64
|
+
glyph: "(!_!)",
|
|
65
|
+
face: "idea",
|
|
66
|
+
clip: "jump",
|
|
67
|
+
sigmaPrice: 20
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "emote-licik",
|
|
71
|
+
label: "Licik",
|
|
72
|
+
glyph: "(¬‿¬)",
|
|
73
|
+
face: "licik",
|
|
74
|
+
clip: "idle",
|
|
75
|
+
sigmaPrice: 25
|
|
76
|
+
},
|
|
77
|
+
{ id: "emote-tewas", label: "Tewas", glyph: "(x_x)", face: "dead", clip: "idle", sigmaPrice: 30 },
|
|
78
|
+
{
|
|
79
|
+
id: "emote-bintang",
|
|
80
|
+
label: "Mata Bintang",
|
|
81
|
+
glyph: "(*_*)",
|
|
82
|
+
face: "stars",
|
|
83
|
+
clip: "dance",
|
|
84
|
+
sigmaPrice: 40
|
|
85
|
+
},
|
|
86
|
+
{ id: "emote-aduh", label: "Aduh", glyph: "(>_<)", face: "pain", clip: "jump", sigmaPrice: 50 },
|
|
87
|
+
{
|
|
88
|
+
id: "emote-serius",
|
|
89
|
+
label: "Serius Banget",
|
|
90
|
+
glyph: "(-_-)",
|
|
91
|
+
face: "serious",
|
|
92
|
+
clip: "idle",
|
|
93
|
+
sigmaPrice: 60
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
function emoteOf(name) {
|
|
97
|
+
const id = name.startsWith("emote-") ? name : `emote-${name}`;
|
|
98
|
+
return EMOTES.find((emote) => emote.id === id);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { EMOTES, emoteOf };
|