Created
April 2, 2020 18:30
-
-
Save robmiller/f002d6dde363551fe67e8a04ca747b55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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