2017-06-16 21:33:34 +00:00
|
|
|
<script>
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
function generatePalette(amount) {
|
|
|
|
var result = [];
|
|
|
|
var hueStep = 360 / amount;
|
|
|
|
for (var i = 0; i < amount; ++i)
|
|
|
|
result.push('hsl(' + (hueStep * i) + ', 100%, 90%)');
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
var palette = generatePalette(100);
|
2017-06-16 23:00:36 +00:00
|
|
|
for (var i = 0; i < 200; ++i) {
|
2017-06-16 21:33:34 +00:00
|
|
|
var box = document.createElement('div');
|
|
|
|
box.classList.add('box');
|
|
|
|
box.style.setProperty('background-color', palette[i % palette.length]);
|
2017-06-16 23:00:36 +00:00
|
|
|
var x = i;
|
|
|
|
do {
|
|
|
|
var digit = x % 10;
|
|
|
|
x = (x / 10)|0;
|
|
|
|
var img = document.createElement('img');
|
|
|
|
img.src = `./digits/${digit}.png`;
|
|
|
|
box.insertBefore(img, box.firstChild);
|
|
|
|
} while (x);
|
2017-06-16 21:33:34 +00:00
|
|
|
document.body.appendChild(box);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.box {
|
|
|
|
font-family: arial;
|
2017-06-16 23:00:36 +00:00
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2017-06-16 21:33:34 +00:00
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
width: 50px;
|
|
|
|
height: 50px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: 1px solid darkgray;
|
|
|
|
}
|
|
|
|
</style>
|