Hidden Sierpiński

Actionscript:
  1. var canvas:BitmapData=new BitmapData(255,255,false,0x000000);
  2. addChild(new Bitmap(canvas, "auto", true));
  3.  
  4. scaleX = scaleY = 1.5;
  5.  
  6. addEventListener(Event.ENTER_FRAME, onLoop);
  7. function onLoop(evt:Event):void {
  8.     for (var i:int  = 0; i<canvas.width * canvas.height; i++) {
  9.         var ox:int= i % canvas.width;
  10.         var oy:int= i / canvas.width;
  11.         var col =  (ox | oy) * mouseX % 255;
  12.         canvas.setPixel(ox, oy, col <<16 | col <<8 | col);
  13.     }
  14. }

Sometimes when I'm writing a program that does some pixel pushing I'll save the file and then start arbitrarily adding bitwise operations to it.... just to see what happens. Sierpinski-esque stuff occurs often. This will work in your timeline - move your mouse left and right to generate images like these:





This entry was posted in BitmapData, pixel manipulation, setPixel and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*