Skip to content

Instantly share code, notes, and snippets.

@dend
Created December 11, 2020 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dend/722f9953eee1634c9d4ecf003efc735f to your computer and use it in GitHub Desktop.
Save dend/722f9953eee1634c9d4ecf003efc735f to your computer and use it in GitHub Desktop.
var list = document.getElementsByTagName("rect")
var color_strings = ['var(--color-calendar-graph-day-L4-bg)', 'var(--color-calendar-graph-day-L3-bg)', 'var(--color-calendar-graph-day-L2-bg)', 'var(--color-calendar-graph-day-L1-bg)']
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
async function demo() {
for (i = 0; i < 100000; i++) {
var current_rectangle = list[getRandomInt(0, list.length - 1)];
current_rectangle.setAttribute('fill', color_strings[getRandomInt(0, color_strings.length - 1)])
await sleep(getRandomInt(1, 12));
}
}
demo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment