Creating generative art in haXe and OpenFrameworks

It has been some time since the start of building hxOpenFrameworks, the haXe binding to OpenFrameworks. Actually it is already around 80% complete several weeks ago. I was facing some GC problem on the use of ofSoundStream, but finally I’ve solved it with the help of Hugh. As a by-product, I’ve made a binding to RtAudio, a cross-platform real-time sound input/output API. However, I think I will wait till OF 007 and haXe 2.07 is released before really releasing hxOpenFrameworks.

In order to test it, I’ve been using it for some little projects. I decided to create (at least) one piece of generative art everyday… right, everyday starting from the 1st day of 2011. Quite similar to what Keith Peters did some time ago (art from code). The process is pretty fun once I had got used to start my day by coding some art.

Accidentally I found setCircleResolution a very interesting function to play with. It controls how a circle is approximated by drawing regular polygons. Below is circles with radius increasing and resolution(number of sides of regular polygon) decreasing.
"20110103_082211 by on_the_wings, on Flickr"

Sometimes the generating process is even more amazing than the final image.

sin/cos/tan are also interesting functions that often give you unexpected results. Below is a combination of sin and tan.
"20110109_094501 by on_the_wings, on Flickr"

Writing recursive/iterative code is the easiest way to produce complex graphics with few lines of code. Spiral forms are particularly attractive, as there is a point of focus.
"20110106_202323 by on_the_wings, on Flickr"

With some modifications, it looks like some kind of rose.
"20110107_080604 by on_the_wings, on Flickr"

Below is my favorite piece at the moment. I used physaxe for physics simulation. Thousands of particles(in fact, tiny circles) are shot from outside of the canvas, producing trails of blue. When they collides, some red will be drawn, which look like sparks. The generating process is recorded, you can find it on Youtube.
"20110113_2000 by on_the_wings, on Flickr"

Finally, all the codes of the above pieces are open source, can be found in the description of individual Flickr/Youtube page. I’ll post some more interesting ones next month.

PS. Nicolas Barradeau is producing a series of basics in generative art in his blog, which contains a lot of useful codes in AS3. Be sure to check it out if you’re interested in generating some art!

comments powered by Disqus