Wednesday, April 29, 2015

Glitch out with some binary art

((function(f){"use strict";var bdy=window.top.document.body;bdy.innerHTML="";bdy.style.backgroundRepeat="repeat";var c=document.createElement("canvas");var d=c.getContext('2d');var e="";c.width=f;c.height=f;var g=d.createImageData(f,f);var h=[f*f];var i=;var j=function(z){var a=g.data;for(var x=0;x<f;x++){for(var y=0;y<f;y++){var b=(x+y*f)*4;a[b+0]=(h[b].r*z)%255;a[b+1]=(h[b].g*z)%255;a[b+2]=(h[b].b*z)%255;a[b+3]=255}}d.putImageData(g,0,0);e=c.toDataURL();i.push('url('+e+')')};var k=0,dir=1;var l=function(){bdy.style.backgroundImage=i[k];k+=dir;if(k===f)dir=-1;if(k===0)dir=1};for(var x=0;x<f;x++){for(var y=0;y<f;y++){var m=(x+y*f)*4;h[m]={r:parseInt((x^y)),g:parseInt((x|y)),b:parseInt((x&y))}}}for(var z=0;z<f;z++){j(z)}setInterval(l,200)})(300))

/*Instructions: Open your browser dev tools and copy/paste the above javascript into the console and press enter. If you need help ask a friend. Glitch out and enjoy. I made the first version of the above in 1996 in C. Ever since then on the net I've gone by the handle binarymax. Now I wear a suit and tie when I go to meetings, but deep down I'm still edgy enough for the nickname. Peace, Love, Art, Code.*/


Max Irwin (aka binarymax)
max.l.irwin[AT]gmail.com
St Leonards On Sea, UK

No comments:

Post a Comment