Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@robmiller
Created April 2, 2020 18:30
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 robmiller/f002d6dde363551fe67e8a04ca747b55 to your computer and use it in GitHub Desktop.
Save robmiller/f002d6dde363551fe67e8a04ca747b55 to your computer and use it in GitHub Desktop.
/* 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