gitflarePublicPartly agent-ready40
shadow-fight-web-version
No description yet.
- LicenseApache-2.0
- LanguageJavaScript
- Last landed
132be7cOct 23, 2026
Make the player visible with a procedural 3D humanoid
132be7cimport test from 'node:test';import assert from 'node:assert/strict';import { clampToArena, frameCamera, inFrame, drawOrder, rimColor, contrastColor } from './render-utils.mjs'; test('clampToArena keeps fighters on stage', () => { assert.equal(clampToArena(-5, 9.6), 0.4); assert.equal(clampToArena(50, 9.6), 9.2); assert.equal(clampToArena(3, 9.6), 3);}); test('frameCamera keeps both fighters in frame at stage edges and narrow screens', () => { for (const aspect of [16 / 9, 1, 9 / 16]) { for (const xs of [[-3, 20], [0.4, 9.2], [4, 4.5], [9.2]]) { const { cx, distance } = frameCamera(xs, aspect, Math.PI / 4, 9.6); for (const x of xs) assert.ok(inFrame(clampToArena(x, 9.6), cx, distance, aspect), `${x} @ ${aspect}`); } }}); test('drawOrder draws background first and player last', () => { const o = drawOrder(3, 2, 0); assert.deepEqual(o.slice(0, 3).map((e) => e.kind), ['layer', 'layer', 'layer']); assert.deepEqual(o[o.length - 1], { kind: 'fighter', index: 0 }); assert.equal(o.length, 5);}); test('rim and body colours contrast with background', () => { const lum = (c) => 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]; for (const bg of [[0.1, 0.1, 0.15], [0.9, 0.9, 0.85]]) { assert.ok(Math.abs(lum(rimColor(bg)) - lum(bg)) > 0.4); const c = contrastColor(bg.slice(), bg); assert.ok(Math.abs(lum(c) - lum(bg)) >= 0.3); }});