Skip to content

Instantly share code, notes, and snippets.

@robmiller
Created Apr 2, 2020
Embed
What would you like to do?
/* reveals koalastothemax.com without needing to move your mouse */
var mm = new Event("mousemove");
function rand(min, max) { return Math.ceil(Math.random() * (max - min) + min); }
function sorter(c1, c2) { if ( c1[0] > c2[0] ) { return -1; } if ( c1[0] < c2[0] ) { return 1; } return 0 }
function getBiggestCircle() {
var circles = [...document.querySelectorAll("#dots circle")].map(c => [c.getBBox().width, c]).sort(sorter);
return circles[0][1];
}
var times = 0;
d3.mouse = function() {
if ( times <= 100 && Math.random() <= 0.01 ) { times += 1; return [0, 0]; }
var bb = getBiggestCircle().getBBox();
var x = Math.ceil(bb.x + bb.height / 2);
var y = Math.ceil(bb.y + bb.height / 2);
var coords = [rand(x - 10, x + 10), rand(y - 10, y + 10)];
return coords;
}
setInterval(_ => document.body.dispatchEvent(mm), 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment