Created
January 10, 2020 22:09
-
-
Save ivarvong/2184c3573c7a27b21abfcde16d64741e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<body> | |
<h1 style="font-size: 100px;"></h1> | |
<script src="https://d3js.org/d3-color.v1.min.js"></script> | |
<script> | |
const $h1 = document.querySelector('h1') | |
function random(l) { | |
const a = parseInt((Math.random() - 0.5) * 256) | |
const b = parseInt((Math.random() - 0.5) * 256) | |
return d3.lab(l, a, b) | |
} | |
function set() { | |
const l = parseInt(Math.random() * 100) | |
const color1 = random(l).formatRgb() | |
const color2 = random(l).formatRgb() | |
$h1.innerText = `${color1}\n${color2}` | |
document.body.style.color = color1 | |
document.body.style.backgroundColor = color2 | |
} | |
set() | |
// setInterval(set, 250) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment