color picker fixes, random default color

This commit is contained in:
jonaswinkler
2021-02-25 22:43:45 +01:00
parent 9f56fbfa1d
commit bae41cc50a
4 changed files with 25 additions and 9 deletions

View File

@@ -0,0 +1,12 @@
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
export function randomColor() {
let r = Math.floor(Math.random() * 150) + 50
let g = Math.floor(Math.random() * 150) + 50
let b = Math.floor(Math.random() * 150) + 50
return `#${componentToHex(r)}${componentToHex(g)}${componentToHex(b)}`
}