Archive for September, 2008

Swim - Fast Drawing

Saturday, September 13th, 2008

Using copyPixels to draw is very fast. If your code is set up correctly you can draw thousands of small graphics to the screen - this would be impossible using sprites, shapes etc…

Over the next couple of weeks I’ll be posting some of the sketches I created while developing a small library for handling this kind of drawing. This first one is a texture made up of 500 oscillating transparent circles that are attracted to the mouse…




Click either of the above images to see the flash version

Abstract Curtain

Friday, September 12th, 2008



Click the above image to view the flash version

This uses a BitmapData technique that I first encountered in Director Imaging Lingo. Try this code out:

Actionscript:
  1. stage.frameRate = 31;
  2. var canvas:BitmapData = new BitmapData(500,500, true, 0xFF000000);
  3. // transparent black overlay
  4. var overlay:BitmapData = new BitmapData(500,500,true, 0x11000000);
  5. addChild(new Bitmap(canvas));
  6.  
  7. var brush:Shape = new Shape();
  8. brush.graphics.beginFill(0xFFFFFF,0.5);
  9. brush.graphics.drawCircle(0,0,20);
  10.  
  11. addEventListener(Event.ENTER_FRAME, onLoop);
  12. function onLoop(evt:Event):void {
  13.     brush.x = mouseX;
  14.     brush.y = mouseY;
  15.     canvas.draw(brush, brush.transform.matrix);
  16.     // draw canvas to itself with offset
  17.     canvas.copyPixels(canvas, canvas.rect, new Point(0,2), null, null, true);
  18.     // draw transparent black overlay
  19.     canvas.copyPixels(overlay, canvas.rect, new Point(0,0), null, null, true);
  20. }

I'm always thinking about good assignments for an experimental visual programming class: "Create an abstract form that resembles a curtain."

Plant Assignment

Friday, September 12th, 2008

Sometimes I’ll give myself programming assignments… these are generally assignments I would give if I were teaching some kind of experimental or visual programming class…. All my classes are currently geared toward more commercial aspects of flash. Anyway, the assignment was… “Take 20 minutes to write a program that draws some kind of plant.”

I started off thinking about doing a recursive function to create branches, but settled on a random walk instead:


Click the above image to see the flash version

I’ve always liked to use sharpen on images - the only problem is that the pixelation around the edges is a little harsh - in the future I may add anti-aliasing to the edges.