Generative Art

written on 12 Feb 2014 by Andrew Dai

A last year I got particularly bored and delved into the world of generative art. I hacked together some admittedly crappy code in Java and got some pretty cool results. In hindsight I realize that I probably should’ve used existing frameworks such as cinder, Processing, or openFrameworks rather than build an entirely new project.

Circular Patterns

Fractals and Fractal Landscapes

Fractals are cool. I hacked together a fairly simplistic set of Java programs that recursively altered lines to make interesting patterns. Due to the bad programming, there are severe limitations on the level of detail.

Circular Patterns

Fractal landscapes use recursive processes to generate detailed and realistic textures. GameProgrammer.com has a good article on the details of the algorithms in use. Based heavily on the recursive processes of fractals, fractal landscape algorithms add in a little (or a lot) of randomness at each step, generating a more natural form. Here the “heights” of each pixel/location are mapped to a color value ranging from white to blue making cloud patterns

fractal clouds a small 17x17 grid to show detail

fractal clouds a much more detailed 513x513 grid

3 Dimensions!

After working in 2 dimensions, the natural next step is adding depth. Naive and bored (a fatal combination) I set out to code a 3 dimensional visualization with perspective. Rather than use existing libraries I decided (once a again) to write my own code - a habit I seek to break.

I decided that I would try to rotate a wireframe cube (solving the hidden surface problem was beyond the scope of what I wanted to do). First was the orthogonal view. After working out the rotation math (and discovering rotation matrices by luck), I quickly hacked together an orthogonal 3D view. You can easily make a 3D mapping without perspective by just dropping the 3rd coordinate (depth).

Perspective was much harder. You have to define a camera viewpoint in 3-space and from there, map the 3D world onto a 2D plane that represents the computer screen. I did this very simply by figuring out where a line from the eye to a point in space intersected with the plane and drawing that point on the screen. A couple hours were devoted to manually adjusting the variables to properly size and scale the perspective.

3d Cube perspective the dot in the center is the origin and the magenta lines form the back of the cube

All the code can be found on my Github. Soon to be documented…