Jump to content
Sign in to follow this  
RSS Bot

ubikuberalles' Blog - Art via Programming: Circles

Recommended Posts

So far, the basic algorithms of the art generating programs I've presented were in the following form:

 

CODE

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:

 

CODE

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:

CODEcolor = ((j - 200.0) / 200.0)^2 / 200 + (i - 200.0)^2 / 200.0)) / 2^n

Where n is a number I entered myself. I first tried the program with n = 0 and the results were remarkable:

 

circles00.jpg

 

Wow. Totally unexpected. It got better when I increased the value of n. Here's circles with n = 2:

 

circles02.jpg

 

n = 4:

 

circles04.jpg

 

n = 7:

 

circles07.jpg

 

And n = 10:

 

circles10.jpg

 

 

Before too long I made a movie of the results:

 

circles.gif

 

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:

 

circles-40.jpg

 

And n = -48:

 

circles-48.jpg

 

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.

 

http://www.atariage.com/forums/index.php?a...;showentry=2893

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...