Close Show/hide page

Archive for September, 2007

Particle Field

Monday, September 24th, 2007
Thumbnail - Click me

A matrix of vectors acting upon a field of particles. Reminiscent of falling water or snow, slightly. Click and drag to ‘draw’ vectors on the field to influence the movement of particles.

For me, the idea comes from Charles Forman’s blog post in Setpixel from 2004, “Snow is fun.” Which is incredibly great. And done in Processing.

Source code:

- Actionscript 3 class

- Full project (Flash 9/AS3)

Licensed under a Creative Commons Attribution 3.0 License.

SimpleFlvWriter.as - AS3 Class to Create FLV’s

Saturday, September 8th, 2007

An Actionscript 3 class for use with Adobe AIR to create uncompressed Macromedia Flash Video (FLV) files to the local filesystem. It will add proper onMetaData info as well. It’s very simple to use.

Example usage:

var myWriter:SimpleFlvWriter = SimpleFlvWriter.getInstance();
myWriter.createFile(myFile, 320,240, 30, 120);
myWriter.saveFrame( myBitmapData1 );
myWriter.saveFrame( myBitmapData2 );
myWriter.saveFrame( myBitmapData3 ); // ... etc.
myWriter.closeFile();

See the comment blocks in the source for more info. It doesn’t support audio.

This comes out of the app I made a little while ago, Webcam DVR. I’m posting the class file now because the app is fresh in my mind, as I just updated it to make it compatible with the current AIR runtime to enter it into the Adobe AIR Developer Derby.

Download Webcam DVR for AIR, updated for the beta AIR runtime (See the previous Webcam DVR post for usage notes).

Licensed under a Creative Commons Attribution 3.0 License.

Seam Carving in AS3, with source

Sunday, September 2nd, 2007
Thumbnail - Click me

Seam carving — the recently unveiled technique by Shai Avidan and Ariel Shamir to intelligently resize images (YouTube; white paper) — really captured my imagination when I came across it last night, as it has for many others.

Like Hector Yee (whose writeup was very useful), I decided — geek that I am — to try my hand at an implementation of it just for the hell of it. But in Actionscript 3.

The attached demo only resizes images vertically, not horizontally. I wish I could have, but didn’t bother including a dynamic image loader. It’s also, well, very pokey, but the code is readable and the output seems accurate. If you can stand the wait, press [M] a few times to load up the seam calculation queue.

But the most valuable thing about this demo is its publicly available source code under a Creative Commons license:

Static utility class | App class | Project ZIP file

So if you’re so inclined, please improve, extend, optimize, and/or port this code. I’m not planning on doing any further work on it. Just let me know if you find the code useful, and share your work.

If you’re interested in a more fully-realized online demo of seam carving, someone’s done it up in Java here.

Update: Additionally, as it turns out, Patrick Swieskowski has already put up an online seam carving Flash demo here.

Version: 0.8

Licensed under a Creative Commons Attribution 3.0 License.