Monorepo for Aesthetic.Computer
aesthetic.computer
1import assert from 'node:assert/strict';
2
3// Minimal ImageData polyfill so graph.mjs can initialize in Node.
4if (typeof globalThis.ImageData === 'undefined') {
5 globalThis.ImageData = class ImageData {
6 constructor(width, height) {
7 this.width = width;
8 this.height = height;
9 this.data = new Uint8ClampedArray(width * height * 4);
10 }
11 };
12}
13
14const graph = await import('../system/public/aesthetic.computer/lib/graph.mjs');
15const { findColor } = graph;
16
17function assertColor(args, expected, message) {
18 const actual = findColor(...args);
19 assert.deepEqual(actual, expected, message);
20}
21
22assertColor(['white'], [255, 255, 255, 255], 'white defaults to opaque');
23assertColor(['white', 32], [255, 255, 255, 32], 'white with numeric alpha');
24assertColor(["'white"], [255, 255, 255, 255], "KidLisp single-quote prefix");
25assertColor([' "gray" '], [128, 128, 128, 255], 'Quoted gray string trims correctly');
26assertColor(['`black`'], [0, 0, 0, 255], 'Backtick wrapped color resolves');
27assertColor(['|gray|'], [128, 128, 128, 255], 'Pipe wrapped color resolves');
28assertColor(['Gray', 96], [128, 128, 128, 96], 'Mixed-case names normalize');
29assertColor([[12, 34, 56, 78]], [12, 34, 56, 78], 'Direct RGBA array passes through');
30assertColor([[12, 34, 56], 200], [12, 34, 56, 200], 'RGB array with explicit alpha extends correctly');
31assertColor([[12, 34, 56, 90], 0.5], [12, 34, 56, 128], 'Fractional alpha overrides array alpha via computeAlpha');
32
33console.log('✅ findColor normalization smoke tests passed');