Skip to content

Instantly share code, notes, and snippets.

@timmc
Last active February 22, 2022 23:02
Show Gist options
  • Save timmc/fa9ca14503580b5abc29d7d95303d2b2 to your computer and use it in GitHub Desktop.
Save timmc/fa9ca14503580b5abc29d7d95303d2b2 to your computer and use it in GitHub Desktop.
var ants = [
'<span style="filter: brightness(0%) saturate(0%)">🐜</span>', // black
'<span style="filter: brightness(220%) saturate(600%) hue-rotate(150deg)">🐜</span>', // red
'<span style="filter: brightness(470%) saturate(1000%) hue-rotate(244deg)">🐜</span>', // yellow
];
function one_ant() {
return ants[Math.floor(Math.random() * 2.2)]; // small chance of yellow
}
function some_ants() {
var answer = "";
var i = Math.floor(Math.random() * 12 + 3);
while (i--) {
answer += one_ant();
}
return answer;
}
document.querySelectorAll('#guesses tr td:nth-of-type(2)').forEach(el => el.innerHTML = some_ants());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment