Tag Archives: flash

Auto create polygon AS3

Made a Flash on Wonderfl the other day.

My friend studying for his PhD at Georgia Tech in architecture called me regarding a problem. He said,

“I need to program something to create a polygon from points. Right now, the points are not being drawn in the right order so lines are being overlapped. How do I have the program draw them in the right order?”

So I came up with a theory of how to do it. The idea is that you find the average point between the points, and from that point you find the arc tangent to each of the points and order the points based on their angle to the center. This idea would only work in 2D, but I’m sure there is a general way to do it for all dimensions.

Here is the code written in actionscript. You can click to add a point and ctrl+click to delete a point. I put it on wonderfl because I am thinking some people could fork some more interesting things from it.

Auto create Polygon – wonderfl build flash online

Picture of Pictures

For my Experimental Digital Media class at Georgia Tech.

Click here to view
(Must have Flash Player 10)

The Internet has provided a new means of data expression. I decided to play with the idea of machine aesthetics by developing an application that creates images of images.

I first saw this effect a long time ago on a poster advertisement for the Truman show. I always wondered how they made the effect of compiling images together to form, when looked at a certain distance, an image.  The program I made this week creates the effect by downloading Flickr images.

The algorithm is very straightforward (I also mention some ideas for expansion on the Flash). Basically the program downloads Flickr images either by the most recent, based on a search term, or from a username’s public photos via the as3flickrlib. While downloading, the application calculates and caches each photos average RGB color average (the main reason why my algorithm is fast). The program, based on the user’s supplied number of rows and columns, calculates the average RGB color of each divided cell and finds the image with the average color that has the closest 3D distance to the cell’s average color. The effect is pretty cool. I offer the ability to have a very high resolution (which basically expands the original image before running the algorithm to near the max of Flash Player 10’s bitmapData’s limit). The picture effect is  best seen with the highest resolution.

Lastly, thanks to Flash Player 10, saving images is added. I use the JPGEncoder from as3corelib. Unfortunately, the JPGEncoder was too slow as its algorithm is synchronous. Upon Googling “Asynchronous JPG Encoder,” I found a cool Asynchrnous JPG Encoder class by SwitchOnTheCode.com. While I have crtiticisms on the class’s asynchronous technique choice, the class does what it says it does.

Anyway, if there is enough support, I may release the class as open source on Google Code. I think there are a lot of ways to alter the algorithm to produce different kinds of image results.