Art via Programming: Circles
So far, the basic algorithms of the art generating programs I've presented were in the following form:
for i = 1 to SomeNumber for j = 1 to SomeOtherNumber Determine StartPoint; Determine EndPoint; Draw a line or fill the region between StartPoint and EndPoint; next j next i
My latest program, circles has a different basic algorithm:
for i = 1 to StageWidth for j = 1 to StageHeight DetermineColorToPlot(i,j); SetPixel(i,j) next j next i
Looks like a simple algorithm, but those looks can be deceiving. It's that DetermineColorToPlot subroutine that can be a source of all sorts of headaches. Sometimes the routine holds a simple sine wave equation or it just reads data from a file. Other times it's much more complex: computing partial derivatives, Laplace's equation or quadratic equations. Fractals are displayed using this basic algorithm with the DetermineColorToPlotsubroutine incorporating another loop that recalculates an equation until some pretermined end condition is met.
For my first attempt at this new algorithm, I decided to do something basic: the radius of a circle (x^2 + y^2). As I expected, I got a bunch of concentric circles. Pretty boring. So I tweeked the equation until I got this:
color = (((j - 200.0) / 200.0)^2 / 200 + ((i - 200.0) / 200.0)^2) / 2^n
Where n is a number I entered myself. I first tried the program with n = 0 and the results were remarkable:
Wow. Totally unexpected. It got better when I increased the value of n. Here's circles with n = 2:
n = 4:
n = 7:
And n = 10:
Before too long I made a movie of the results:
I thought I was done with the program until I realized I forgot about values of n that are less than zero. Here's what I got with n = -40:
And n = -48:
Both images reminded me of the sand paintings made by Tibetan monks or Navajo Indians.
Before long I figured out the limits of the program. The screen goes totally black with n = -65 and lower or n = 21 and higher. I also quickly created an animation and I was pleased by the results. It reminded me of the big bang. The problem with the animation was it incorporated over 90 frames and my first animation was over 4 Megabytes in size! So you have several options to view the movie:
Big Bang - tiny (150 X 150 - 504 Kb)
Big Bang - medium (200 X 200 - 994 Kb)
Big Bang - big (400 X 400 - 4624 Kb)
Circles was created with Flash 8 Professional and you can run the program yourself (as long as you have the latest Flash player - version 8 or later). Here it is. The program itself isn't very big (64 Kb or so) but it does suck up a great deal of CPU for a short period of time. On my laptop (a 1.6 GHz Sempron) it takes about 15 or 20 seconds to produce the graphic. Give it a try and let me know what you think.
EDIT: Here's a new version of the program. Slightly different controls and a new control that allow you to select different equations. For more info, see my comments for this post.
6 Comments
Recommended Comments