Skip to content

Instantly share code, notes, and snippets.

@crossproduct
Last active August 29, 2015 14:23
Show Gist options
  • Save crossproduct/ad1004de20f498664fa3 to your computer and use it in GitHub Desktop.
Save crossproduct/ad1004de20f498664fa3 to your computer and use it in GitHub Desktop.
I love me some Nyan Cat! ... And I wanted a quick way to make this --> https://dl.dropboxusercontent.com/u/6213850/WebGL/nyanCat/nyan.html into screensaver of sorts to run fullscreen in a browser window with some dynamic camera motion, so wrote a little javascript snippet to run in console to achieve just that. Tweak to your hearts consent...
setInterval(function() {
var w = document.querySelector("body").offsetWidth;
var h = document.querySelector("body").offsetHeight;
var c = {x: w/2, y: h/2};
var tolerance = (w < h ? w/8 : h/8);
var dx = c.x + (Math.random() * tolerance) * (Math.random() > 0.5 ? 1 : -1);
var dy = c.y + (Math.random() * tolerance) * (Math.random() > 0.5 ? 1 : -1);
var event = new MouseEvent("mousemove");
event.initMouseEvent("mousemove", true, true, window, 0, 0, 0,dx, dy, false, false, false, false, 0, null);
document.dispatchEvent(event);
}, 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment