Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { png } from "https://esm.town/v/andreterron/png";
export let women_and_power = png({
width: 256,
height: 256,
depth: 256,
}, (p) => {
const w = p.width, h = p.height;
const black = p.color(0, 0, 0, 255);
const white = p.color(255, 255, 255, 255);
function triangle(x: number, y: number) {
return Math.min(x, 1 - x) < y ? 0 : 1;
}
function fract(v: number) {
return v - Math.floor(v);
}
for (let y = 0; y < h; y += 1) {
for (let x = 0; x < w; x += 1) {
const s = Math.max(w, h);
const u = (x - (w / 2)) / s;
const v = (y - (h / 2)) / s;
const a = (Math.atan2(v, u) / Math.PI + 1) / 2;
const r = Math.sqrt(u * u + v * v) / 5;
const size = 32;
const uv = { x: a, y: r * 2 };
const i = Math.floor(uv.y * size) / size;
const color = 1 -
triangle(fract((uv.x - i) * size / 2), fract((uv.y - i) * size / 2));
const fragColor = color * (r > 0.0315 ? 1 : 0);
let index = p.index(x, y);
p.buffer[index] = [black, white][fragColor];
}
}
});
andreterron-women_and_power.web.val.run
October 23, 2023