4 ms·
I find the whole idea quite amusing... Reminds me a little of the demo scene back in the day. I put this together with that in mind, simple but I wanted to keep
by aarongough 17y ago
I find the whole idea quite amusing... Reminds me a little of the demo scene back in the day. I put this together with that in mind, simple but I wanted to keep the code neat (JavaScript):
EDIT: Realized I should add an online preview, the animation starts 6 seconds after the page loads... http://aarongough.com/hello_world.html http://aarongough.com/hello_world.html
function floatPixel ( pixelFilled, pixelSize )
{
this.render = function ()
{
if( thisObj.pixelFilled ) thisObj.pixel.style.background = "black";
if( !thisObj.pixelFilled ) thisObj.pixel.style.background = "white";
}
this.animate = function()
{
thisObj.pixelFilled = true;
thisObj.render();
}
var thisObj = this;
this.pixelFilled = pixelFilled;
this.pixelSize = pixelSize;
this.pixel = document.createElement("div");
this.pixel.style.height = this.pixelSize + "px";
this.pixel.style.width = this.pixelSize + "px";
this.pixel.style.cssFloat = "left";
this.render();
this.timer = setTimeout( this.animate, Math.floor( Math.random() * 15000 + 6000 ));
document.getElementById("pixel_container").appendChild( this.pixel );
}
document.body.style.background = "black";
document.body.style.textAlign = "center";
var pixelContainer = document.createElement("div");
pixelContainer.id = "pixel_container";
pixelContainer.style.height = "50px";
pixelContainer.style.width = "900px";
pixelContainer.style.margin = "200px auto";
pixelContainer.style.position = "relative";
document.body.appendChild( pixelContainer );
var pixelData = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000100011111000100000001000000011111000000100010001111100011110000100000001110000010000000000000000100010001000000010000000100000001000100000010001000100010001000100010000000100100001000000000000000011111000111110001000000010000000100010000001000100010001000111100001000000010001000100000000000000001000100010000000100000001000000010001000000101010001000100010001000100000001001000000000000000000000100010001111100011111000111110001111100000011011000111110001000100011111000111000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
for( x = 0; x < pixelData.length; x++ )
{
new floatPixel( parseInt(pixelData.slice(x, x + 1)), 9 );
}