@holtjs/craft 0.0.0-stage → 0.1.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/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import { a as encodePngRgba, c as pixel_exports, i as derivePixelRamp, l as rgbToHex, n as compilePixelGrid, o as mixRgb, r as derivePaletteVariants, s as parseHexRgb, t as PixelCanvas } from "./pixel-D3jgByB5.js";
2
+ import { $ as quatFromEuler, A as RIG_CAMERA_ELEV_DEG, B as RIG_SIN_E, C as evaluateRigClip, D as validateRigPixelSprite, E as validateRigCosmetic, F as RIG_DUO_VIEW, G as mat4Invert, H as createRigState, I as RIG_EASE_MODES, J as mat4TransformPoint, K as mat4Mul, L as RIG_EYE_MODES, M as RIG_CELL_SIZE, N as RIG_COSMETIC_SLOTS, O as validateRigPrimitiveList, P as RIG_COS_E, Q as quatFromAxisAngle, R as RIG_LIMITS, S as RIG_PRIMITIVE_SHAPES, T as validateRigClip, U as getBodySockets, V as RIG_SOCKET_NAMES, W as mat4Compose, X as projectSocket2D, Y as projectAllSockets2D, Z as projectWorldPoint2D, _ as RIG_BODY_CATEGORIES, a as compositeSpriteRgba, at as RIG_BODIES, b as validateRigCustomBody, c as renderCosmeticSprite, ct as RIG_BODY_KEYS, d as renderRigClipStrip, et as quatFromUnitVectors, f as renderRigPose, g as evaluateBuiltinPose, h as BUILTIN_ANIM_FRAMES, i as DEFAULT_RIG_COLORS, it as updateRigMatrices, j as RIG_CAMERA_GROUND_Y, k as RIG_BONE_NAMES, l as renderDecorPropSheet, lt as RIG_BODY_TAIL_STYLES, n as bakeDirectionalCharacterSheet, nt as quatMul, o as renderBodyAnimStrip, ot as RIG_BODY_ATTACH_BONES, q as mat4TransformDir, r as rig3d_exports, rt as reachArm, s as renderBodyRestPreview, st as RIG_BODY_EYE_STYLES, t as GRAVEYARD_PRESETS, tt as quatIdentity, u as renderDecorPropSprite, ut as rigBodyKeyFromIndex, v as RIG_DECOR_GROUPS, w as rigClipFrameCount, x as validateRigDecorProp, y as compileCustomBodySpec, z as RIG_MODEL_SCALE } from "./rig3d-C3i7UL88.js";
3
+ import { a as computeBlob47Index, i as bakePixelDualGridSheet, n as bakeNormalMapRgba, o as computeDualGridMask, r as bakePixelBlob47Sheet, s as tilemap_exports, t as BLOB47_CANONICAL_MASKS } from "./tilemap-BFH4_JLe.js";
4
+ import { i as writeRgbaToCanvas, n as packSpriteAtlas, r as registerAtlasOnStage, t as atlas_exports } from "./atlas-Pc12eQsg.js";
5
+ import { n as renderContactSheet, t as inspect_exports } from "./inspect-NzY8Ac1j.js";
6
+ // src/index.ts
7
+ const Craft = {
8
+ ...rig3d_exports,
9
+ ...pixel_exports,
10
+ ...tilemap_exports,
11
+ ...atlas_exports,
12
+ ...inspect_exports
13
+ };
14
+ export { BLOB47_CANONICAL_MASKS, BUILTIN_ANIM_FRAMES, Craft, Craft as default, DEFAULT_RIG_COLORS, GRAVEYARD_PRESETS, PixelCanvas, RIG_BODIES, RIG_BODY_ATTACH_BONES, RIG_BODY_CATEGORIES, RIG_BODY_EYE_STYLES, RIG_BODY_KEYS, RIG_BODY_TAIL_STYLES, RIG_BONE_NAMES, RIG_CAMERA_ELEV_DEG, RIG_CAMERA_GROUND_Y, RIG_CELL_SIZE, RIG_COSMETIC_SLOTS, RIG_COS_E, RIG_DECOR_GROUPS, RIG_DUO_VIEW, RIG_EASE_MODES, RIG_EYE_MODES, RIG_LIMITS, RIG_MODEL_SCALE, RIG_PRIMITIVE_SHAPES, RIG_SIN_E, RIG_SOCKET_NAMES, bakeDirectionalCharacterSheet, bakeNormalMapRgba, bakePixelBlob47Sheet, bakePixelDualGridSheet, compileCustomBodySpec, compilePixelGrid, compositeSpriteRgba, computeBlob47Index, computeDualGridMask, createRigState, derivePaletteVariants, derivePixelRamp, encodePngRgba, evaluateBuiltinPose, evaluateRigClip, getBodySockets, mat4Compose, mat4Invert, mat4Mul, mat4TransformDir, mat4TransformPoint, mixRgb, packSpriteAtlas, parseHexRgb, projectAllSockets2D, projectSocket2D, projectWorldPoint2D, quatFromAxisAngle, quatFromEuler, quatFromUnitVectors, quatIdentity, quatMul, reachArm, registerAtlasOnStage, renderBodyAnimStrip, renderBodyRestPreview, renderContactSheet, renderCosmeticSprite, renderDecorPropSheet, renderDecorPropSprite, renderRigClipStrip, renderRigPose, rgbToHex, rigBodyKeyFromIndex, rigClipFrameCount, updateRigMatrices, validateRigClip, validateRigCosmetic, validateRigCustomBody, validateRigDecorProp, validateRigPixelSprite, validateRigPrimitiveList, writeRgbaToCanvas };
@@ -0,0 +1,466 @@
1
+ import { a as encodePngRgba, t as PixelCanvas, u as __exportAll } from "./pixel-D3jgByB5.js";
2
+ // src/inspect.ts
3
+ var inspect_exports = /* @__PURE__ */ __exportAll({ renderContactSheet: () => renderContactSheet });
4
+ const GLYPHS_3X5 = {
5
+ A: [
6
+ 2,
7
+ 5,
8
+ 7,
9
+ 5,
10
+ 5
11
+ ],
12
+ B: [
13
+ 6,
14
+ 5,
15
+ 6,
16
+ 5,
17
+ 6
18
+ ],
19
+ C: [
20
+ 3,
21
+ 4,
22
+ 4,
23
+ 4,
24
+ 3
25
+ ],
26
+ D: [
27
+ 6,
28
+ 5,
29
+ 5,
30
+ 5,
31
+ 6
32
+ ],
33
+ E: [
34
+ 7,
35
+ 4,
36
+ 6,
37
+ 4,
38
+ 7
39
+ ],
40
+ F: [
41
+ 7,
42
+ 4,
43
+ 6,
44
+ 4,
45
+ 4
46
+ ],
47
+ G: [
48
+ 3,
49
+ 4,
50
+ 5,
51
+ 5,
52
+ 3
53
+ ],
54
+ H: [
55
+ 5,
56
+ 5,
57
+ 7,
58
+ 5,
59
+ 5
60
+ ],
61
+ I: [
62
+ 7,
63
+ 2,
64
+ 2,
65
+ 2,
66
+ 7
67
+ ],
68
+ J: [
69
+ 1,
70
+ 1,
71
+ 1,
72
+ 5,
73
+ 2
74
+ ],
75
+ K: [
76
+ 5,
77
+ 5,
78
+ 6,
79
+ 5,
80
+ 5
81
+ ],
82
+ L: [
83
+ 4,
84
+ 4,
85
+ 4,
86
+ 4,
87
+ 7
88
+ ],
89
+ M: [
90
+ 5,
91
+ 7,
92
+ 7,
93
+ 5,
94
+ 5
95
+ ],
96
+ N: [
97
+ 6,
98
+ 5,
99
+ 5,
100
+ 5,
101
+ 5
102
+ ],
103
+ O: [
104
+ 2,
105
+ 5,
106
+ 5,
107
+ 5,
108
+ 2
109
+ ],
110
+ P: [
111
+ 6,
112
+ 5,
113
+ 6,
114
+ 4,
115
+ 4
116
+ ],
117
+ Q: [
118
+ 2,
119
+ 5,
120
+ 5,
121
+ 7,
122
+ 3
123
+ ],
124
+ R: [
125
+ 6,
126
+ 5,
127
+ 6,
128
+ 5,
129
+ 5
130
+ ],
131
+ S: [
132
+ 3,
133
+ 4,
134
+ 2,
135
+ 1,
136
+ 6
137
+ ],
138
+ T: [
139
+ 7,
140
+ 2,
141
+ 2,
142
+ 2,
143
+ 2
144
+ ],
145
+ U: [
146
+ 5,
147
+ 5,
148
+ 5,
149
+ 5,
150
+ 7
151
+ ],
152
+ V: [
153
+ 5,
154
+ 5,
155
+ 5,
156
+ 5,
157
+ 2
158
+ ],
159
+ W: [
160
+ 5,
161
+ 5,
162
+ 7,
163
+ 7,
164
+ 5
165
+ ],
166
+ X: [
167
+ 5,
168
+ 5,
169
+ 2,
170
+ 5,
171
+ 5
172
+ ],
173
+ Y: [
174
+ 5,
175
+ 5,
176
+ 2,
177
+ 2,
178
+ 2
179
+ ],
180
+ Z: [
181
+ 7,
182
+ 1,
183
+ 2,
184
+ 4,
185
+ 7
186
+ ],
187
+ "0": [
188
+ 7,
189
+ 5,
190
+ 5,
191
+ 5,
192
+ 7
193
+ ],
194
+ "1": [
195
+ 2,
196
+ 6,
197
+ 2,
198
+ 2,
199
+ 7
200
+ ],
201
+ "2": [
202
+ 6,
203
+ 1,
204
+ 2,
205
+ 4,
206
+ 7
207
+ ],
208
+ "3": [
209
+ 6,
210
+ 1,
211
+ 2,
212
+ 1,
213
+ 6
214
+ ],
215
+ "4": [
216
+ 5,
217
+ 5,
218
+ 7,
219
+ 1,
220
+ 1
221
+ ],
222
+ "5": [
223
+ 7,
224
+ 4,
225
+ 6,
226
+ 1,
227
+ 6
228
+ ],
229
+ "6": [
230
+ 3,
231
+ 4,
232
+ 6,
233
+ 5,
234
+ 2
235
+ ],
236
+ "7": [
237
+ 7,
238
+ 1,
239
+ 2,
240
+ 2,
241
+ 2
242
+ ],
243
+ "8": [
244
+ 2,
245
+ 5,
246
+ 2,
247
+ 5,
248
+ 2
249
+ ],
250
+ "9": [
251
+ 2,
252
+ 5,
253
+ 3,
254
+ 1,
255
+ 6
256
+ ],
257
+ ":": [
258
+ 0,
259
+ 2,
260
+ 0,
261
+ 2,
262
+ 0
263
+ ],
264
+ "-": [
265
+ 0,
266
+ 0,
267
+ 7,
268
+ 0,
269
+ 0
270
+ ],
271
+ "_": [
272
+ 0,
273
+ 0,
274
+ 0,
275
+ 0,
276
+ 7
277
+ ],
278
+ ".": [
279
+ 0,
280
+ 0,
281
+ 0,
282
+ 0,
283
+ 2
284
+ ],
285
+ "/": [
286
+ 1,
287
+ 1,
288
+ 2,
289
+ 4,
290
+ 4
291
+ ],
292
+ "(": [
293
+ 2,
294
+ 4,
295
+ 4,
296
+ 4,
297
+ 2
298
+ ],
299
+ ")": [
300
+ 2,
301
+ 1,
302
+ 1,
303
+ 1,
304
+ 2
305
+ ],
306
+ "+": [
307
+ 0,
308
+ 2,
309
+ 7,
310
+ 2,
311
+ 0
312
+ ]
313
+ };
314
+ function drawBitmapText(canvas, text, x, y, color, fontScale = 2) {
315
+ let cx = Math.floor(x);
316
+ const up = text.toUpperCase();
317
+ for (let i = 0; i < up.length; i++) {
318
+ const ch = up[i];
319
+ if (ch === " ") {
320
+ cx += 4 * fontScale;
321
+ continue;
322
+ }
323
+ const rows = GLYPHS_3X5[ch] ?? GLYPHS_3X5["-"];
324
+ for (let r = 0; r < 5; r++) {
325
+ const bits = rows[r];
326
+ for (let c = 0; c < 3; c++) if (bits >> 2 - c & 1) canvas.fillRect(cx + c * fontScale, y + r * fontScale, fontScale, fontScale, color);
327
+ }
328
+ cx += 4 * fontScale;
329
+ }
330
+ }
331
+ /**
332
+ * Render a multi-card 4x nearest-neighbor pixel-art inspection sheet onto a dark checkerboard backdrop
333
+ * with crisp bitmap labels, dimensions, cell boundaries, ground baselines, and socket markers.
334
+ */
335
+ function renderContactSheet(items, opts = {}) {
336
+ const scale = Math.max(1, Math.min(12, Math.floor(opts.scale ?? 4)));
337
+ const cols = Math.max(1, Math.min(items.length || 1, Math.floor(opts.columns ?? 3)));
338
+ const rows = Math.max(1, Math.ceil(items.length / cols));
339
+ const checker = Math.max(4, Math.floor(opts.checkerSize ?? 8));
340
+ const headerH = 22;
341
+ const gap = 14;
342
+ const outerPad = 16;
343
+ const titleBarH = opts.title ? 28 : 0;
344
+ const colW = new Array(cols).fill(120);
345
+ const rowH = new Array(rows).fill(80);
346
+ items.forEach((it, idx) => {
347
+ const c = idx % cols;
348
+ const r = Math.floor(idx / cols);
349
+ const sw = it.sprite.width * scale + 24;
350
+ const sh = it.sprite.height * scale + headerH + 24;
351
+ const minLabelW = (it.label.length + 8) * 8 + 24;
352
+ colW[c] = Math.max(colW[c], sw, minLabelW);
353
+ rowH[r] = Math.max(rowH[r], sh);
354
+ });
355
+ const totalW = 32 + colW.reduce((a, b) => a + b, 0) + gap * (cols - 1);
356
+ const totalH = 32 + titleBarH + rowH.reduce((a, b) => a + b, 0) + gap * (rows - 1);
357
+ const sheet = new PixelCanvas(totalW, totalH);
358
+ sheet.clear([
359
+ 17,
360
+ 20,
361
+ 28
362
+ ], 255);
363
+ if (opts.title) drawBitmapText(sheet, opts.title, outerPad, 20, [
364
+ 166,
365
+ 226,
366
+ 54
367
+ ], 2);
368
+ let yCursor = outerPad + titleBarH;
369
+ for (let r = 0; r < rows; r++) {
370
+ let xCursor = outerPad;
371
+ for (let c = 0; c < cols; c++) {
372
+ const idx = r * cols + c;
373
+ const cw = colW[c], ch = rowH[r];
374
+ if (idx < items.length) {
375
+ const it = items[idx];
376
+ sheet.fillRect(xCursor, yCursor, cw, ch, [
377
+ 26,
378
+ 31,
379
+ 44
380
+ ]);
381
+ sheet.strokeRect(xCursor, yCursor, cw, ch, [
382
+ 56,
383
+ 66,
384
+ 90
385
+ ]);
386
+ drawBitmapText(sheet, `${it.label} (${it.sprite.width}X${it.sprite.height})`, xCursor + 8, yCursor + 7, [
387
+ 226,
388
+ 232,
389
+ 240
390
+ ], 2);
391
+ const viewW = it.sprite.width * scale;
392
+ const viewH = it.sprite.height * scale;
393
+ const vx = xCursor + Math.floor((cw - viewW) * .5);
394
+ const vy = yCursor + headerH + Math.floor((ch - headerH - viewH) * .5);
395
+ for (let py = 0; py < viewH; py++) for (let px = 0; px < viewW; px++) {
396
+ const dark = (px / checker | 0) + (py / checker | 0) & 1;
397
+ sheet.setPixel(vx + px, vy + py, dark ? [
398
+ 30,
399
+ 35,
400
+ 48
401
+ ] : [
402
+ 40,
403
+ 47,
404
+ 64
405
+ ], 255);
406
+ }
407
+ const sp = it.sprite;
408
+ for (let sy = 0; sy < sp.height; sy++) for (let sx = 0; sx < sp.width; sx++) {
409
+ const o = (sy * sp.width + sx) * 4;
410
+ const a = sp.rgba[o + 3];
411
+ if (a === 0) continue;
412
+ const rgb = [
413
+ sp.rgba[o],
414
+ sp.rgba[o + 1],
415
+ sp.rgba[o + 2]
416
+ ];
417
+ sheet.fillRect(vx + sx * scale, vy + sy * scale, scale, scale, rgb, a);
418
+ }
419
+ if (it.cellW && it.cellW < sp.width) for (let gx = it.cellW; gx < sp.width; gx += it.cellW) sheet.fillRect(vx + gx * scale, vy, 1, viewH, [
420
+ 100,
421
+ 116,
422
+ 139
423
+ ], 130);
424
+ if (it.cellH && it.cellH < sp.height) for (let gy = it.cellH; gy < sp.height; gy += it.cellH) sheet.fillRect(vx, vy + gy * scale, viewW, 1, [
425
+ 100,
426
+ 116,
427
+ 139
428
+ ], 130);
429
+ if (it.baseY !== void 0) {
430
+ const by = vy + Math.round(it.baseY * scale);
431
+ sheet.fillRect(vx, by, viewW, 1, [
432
+ 56,
433
+ 189,
434
+ 248
435
+ ], 160);
436
+ }
437
+ if (it.markers?.length) for (const m of it.markers) {
438
+ const mx = vx + Math.round(m.x * scale);
439
+ const my = vy + Math.round(m.y * scale);
440
+ const mc = m.color ?? [
441
+ 250,
442
+ 204,
443
+ 21
444
+ ];
445
+ sheet.fillRect(mx - 3, my, 7, 1, mc, 235);
446
+ sheet.fillRect(mx, my - 3, 1, 7, mc, 235);
447
+ }
448
+ sheet.strokeRect(vx - 1, vy - 1, viewW + 2, viewH + 2, [
449
+ 71,
450
+ 85,
451
+ 105
452
+ ]);
453
+ }
454
+ xCursor += cw + gap;
455
+ }
456
+ yCursor += rowH[r] + gap;
457
+ }
458
+ return {
459
+ width: sheet.width,
460
+ height: sheet.height,
461
+ scale,
462
+ rgba: sheet.rgba,
463
+ png: encodePngRgba(sheet.width, sheet.height, sheet.rgba)
464
+ };
465
+ }
466
+ export { renderContactSheet as n, inspect_exports as t };
@@ -0,0 +1,36 @@
1
+ import { PixelSpriteLike, Rgb } from "./pixel.js";
2
+ export interface InspectMarker {
3
+ readonly x: number;
4
+ readonly y: number;
5
+ readonly color?: Rgb | string;
6
+ }
7
+ export interface ContactSheetItem {
8
+ readonly label: string;
9
+ readonly sprite: PixelSpriteLike;
10
+ /** Optional frame grid overlay (e.g. `cellW: 32, cellH: 32` for animation strips or tilesets). */
11
+ readonly cellW?: number;
12
+ readonly cellH?: number;
13
+ /** Optional ground baseline Y in unscaled sprite pixels. */
14
+ readonly baseY?: number;
15
+ /** Optional socket or pivot markers in unscaled sprite pixels. */
16
+ readonly markers?: readonly InspectMarker[];
17
+ }
18
+ export interface ContactSheetOptions {
19
+ /** Integer nearest-neighbor zoom factor (default `4` -> crisp 4x pixels with zero blur). */
20
+ readonly scale?: number;
21
+ readonly columns?: number;
22
+ readonly checkerSize?: number;
23
+ readonly title?: string;
24
+ }
25
+ export interface ContactSheetResult {
26
+ readonly width: number;
27
+ readonly height: number;
28
+ readonly scale: number;
29
+ readonly rgba: Uint8ClampedArray;
30
+ readonly png: Uint8Array;
31
+ }
32
+ /**
33
+ * Render a multi-card 4x nearest-neighbor pixel-art inspection sheet onto a dark checkerboard backdrop
34
+ * with crisp bitmap labels, dimensions, cell boundaries, ground baselines, and socket markers.
35
+ */
36
+ export declare function renderContactSheet(items: readonly ContactSheetItem[], opts?: ContactSheetOptions): ContactSheetResult;
@@ -0,0 +1 @@
1
+ export { n as renderContactSheet } from "./inspect-NzY8Ac1j.js";