Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md (setup and step-by-step recipes) and a README in each main folder, with an index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to JSDoc @file blocks, define a three-level header template in website/AGENTS.md and check the header in tests/file-headers.test.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
/**
|
|
* @file Génère de vraies images bitmap unies, seul format accepté par les outils d'image.
|
|
*/
|
|
|
|
import { Buffer } from "node:buffer";
|
|
import { crc32, deflateSync } from "node:zlib";
|
|
|
|
function chunk(type, data) {
|
|
const length = Buffer.alloc(4);
|
|
length.writeUInt32BE(data.length);
|
|
const body = Buffer.concat([Buffer.from(type, "latin1"), data]);
|
|
const checksum = Buffer.alloc(4);
|
|
checksum.writeUInt32BE(crc32(body));
|
|
return Buffer.concat([length, body, checksum]);
|
|
}
|
|
|
|
export function solidPngDataUrl([red, green, blue], width = 640, height = 360) {
|
|
const header = Buffer.alloc(13);
|
|
header.writeUInt32BE(width, 0);
|
|
header.writeUInt32BE(height, 4);
|
|
header.set([8, 2, 0, 0, 0], 8);
|
|
const row = Buffer.alloc(1 + width * 3);
|
|
for (let x = 0; x < width; x += 1) row.set([red, green, blue], 1 + x * 3);
|
|
const png = Buffer.concat([
|
|
Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
|
|
chunk("IHDR", header),
|
|
chunk("IDAT", deflateSync(Buffer.concat(Array.from({ length: height }, () => row)))),
|
|
chunk("IEND", Buffer.alloc(0))
|
|
]);
|
|
return `data:image/png;base64,${png.toString("base64")}`;
|
|
}
|