BitmapData Trails

Actionscript:
  1. [SWF(width=400, height=400, backgroundColor=0xCCCCCC, frameRate=30)]
  2.  
  3. var canvas:BitmapData = new BitmapData(400, 400, true, 0xCCCCCC);
  4. var eraser:BitmapData = new BitmapData(400, 400, true, 0x22CCCCCC);
  5. addChild(new Bitmap(canvas));
  6.  
  7. var circle:Shape = Shape(addChild(new Shape()));
  8. with (circle.graphics) beginFill(0x000000), drawCircle(0,0,20);
  9.  
  10. addEventListener(Event.ENTER_FRAME, onLoop);
  11.  
  12. function onLoop(evt:Event):void {
  13.     canvas.copyPixels(eraser, eraser.rect, new Point(0,0), null, null, true);
  14.     circle.x = mouseX;
  15.     circle.y = mouseY;
  16.    
  17.     canvas.draw(circle, circle.transform.matrix);
  18. }

Create trails by slowly erasing the background with copyPixels(). The first time I ever saw this technique was back when setpixel.com contained a bunch of great director experiments by Charles Foreman (creator of iminlikewithyou.com).

At some point last semester I showed iminlikewithyou hamster battle to my undergrad students towards the end of class.... probably one of the funniest moments of that class.

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

One Trackback

  1. By Weekly Shared Items - 16. January, 2009 « toxin 2.0 on January 15, 2009 at 11:27 pm

    [...] BitmapData Trails [...]

Post a Comment

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

*
*