BitmapData Trails

[SWF(width=400, height=400, backgroundColor=0xCCCCCC, frameRate=30)]

var canvas:BitmapData = new BitmapData(400, 400, true, 0xCCCCCC);
var eraser:BitmapData = new BitmapData(400, 400, true, 0x22CCCCCC);
addChild(new Bitmap(canvas));

var circle:Shape = Shape(addChild(new Shape()));
with (circle.graphics) beginFill(0x000000), drawCircle(0,0,20);

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
	canvas.copyPixels(eraser, eraser.rect, new Point(0,0), null, null, true);
	circle.x = mouseX;
	circle.y = mouseY;
	
	canvas.draw(circle, circle.transform.matrix);
}

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.

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *