Skip to content

Instantly share code, notes, and snippets.

@spite
Created August 17, 2014 11:39
Show Gist options
  • Save spite/23b083024ad7cc1fad17 to your computer and use it in GitHub Desktop.
Save spite/23b083024ad7cc1fad17 to your computer and use it in GitHub Desktop.
Play http://colorrun.pl/ forever
var ctx1 = document.getElementById( 'color-1' ).getContext( '2d' ),
ctx2 = document.getElementById( 'color-2' ).getContext( '2d' );
function simulateClick( target ) {
var evt = document.createEvent("Events");
evt.initEvent("click", true, true);
target.dispatchEvent(evt);
}
setInterval( function() {
if( ctx1.fillStyle.indexOf( 'rgba' ) === -1 ) simulateClick( ctx1.canvas );
if( ctx2.fillStyle.indexOf( 'rgba' ) === -1 ) simulateClick( ctx2.canvas );
}, 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment