Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 35 | 2x 2x 2x 12x 2x 12x 12x 3x 3x 1x 1x | import { Color as THREEColor } from "three";
export default class Color {
static randomColor(asNumber = false) {
const letters = "0123456789ABCDEF".split("");
let color = "";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return asNumber ? Number(`0x${color}`) : `#${color}`;
}
static componentToHex(c) {
const hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
static gbToHex(r, g, b) {
return "0x" + Color.componentToHex(r) + Color.componentToHex(g) + Color.componentToHex(b);
}
static getIntValueFromHex(hex) {
return parseInt(hex, 16);
}
constructor(color) {
// TODO: rename this property to be `value`
this.color = new THREEColor(color);
}
getColor() {
return this.color;
}
}
|