Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { png } from "https://esm.town/v/andreterron/png";
export let random_colors = png({
width: 256,
height: 256,
depth: 256,
}, (p) => {
const w = p.width, h = p.height;
for (let i = 0; i < 256; i++) {
p.color(
Math.floor(Math.random() * 256),
Math.floor(Math.random() * 256),
Math.floor(Math.random() * 256),
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));
}
}
});
andreterron-random_colors.web.val.run
October 23, 2023