Settings → Appearance: upload an image and every page header draws it as the dot matrix instead of The Creation of Adam, with a clickable focus point and a switch back to the built-in painting. The browser turns the image into a brightness grid; only that grid is saved as a setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
873 B
TypeScript
20 lines
873 B
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { parseBackdrop } from "./backdrop";
|
|
|
|
const valid = { w: 10, h: 8, dots: "0123456789abcdef".repeat(5), focus: [0.3, 0.7] };
|
|
|
|
test("parseBackdrop keeps a valid grid", () => {
|
|
assert.deepEqual(parseBackdrop(valid), valid);
|
|
});
|
|
|
|
test("parseBackdrop rejects broken grids", () => {
|
|
assert.equal(parseBackdrop(null), null);
|
|
assert.equal(parseBackdrop({ ...valid, dots: valid.dots.slice(1) }), null);
|
|
assert.equal(parseBackdrop({ ...valid, dots: valid.dots.replace("a", "g") }), null);
|
|
assert.equal(parseBackdrop({ ...valid, w: 4, dots: "0".repeat(32) }), null);
|
|
assert.equal(parseBackdrop({ ...valid, w: 241, dots: "0".repeat(241 * 8) }), null);
|
|
assert.equal(parseBackdrop({ ...valid, focus: [0.5, 1.5] }), null);
|
|
assert.equal(parseBackdrop({ ...valid, focus: [0.5] }), null);
|
|
});
|