1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export let zipColor = async (
color: string | {
r: number;
g: number;
b: number;
},
) => {
const size = 6;
const step = 255 / 5;
const { default: Color } = await import("npm:color");
const full = Color(color).alpha(1);
return full
.rgb()
.array()
.map((n) => Math.round(n / step))
.reduce((num, v) => num * size + v, 0);
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023