1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { png } from "https://esm.town/v/andreterron/png";
export let gradient = png({
width: 256,
height: 256,
depth: 256,
}, (p) => {
const w = p.width, h = p.height;
for (let i = 0; i < 256; i++) {
p.color(i, i, i, 255);
}
for (let y = 0; y < h; y += 1) {
for (let x = 0; x < w; x += 1) {
let index = p.index(x, y);
let t = (y + x) / (w + h - 2);
p.buffer[index] = String.fromCharCode(Math.floor(t * 255));
}
}
});