Jump to content
  • entries
    33
  • comments
    78
  • views
    61,909

Art via Programming: The CircleLine program


ubikuberalles

1,252 views

When I finished the Visual Basic version of the Pattern program sometime back in the late nineties, my interest in creating art via programming waned considerably. I'm not sure why, I ran out of ideas or inspiration, I guess. Last year I took a Flash class at CNM and I learned how to program Actionscript. This inspired me to create more graphics programs.

 

The first idea that came to mind harkened back to my days in the ninth grade. Whenever I was bored in my mathmatics class (which was often) I would grab some paper, a pencil, a protractor and draw some geometric figures. What I would typically do is draw a circle, place dots evenly around the circle (every 20 or 30 degrees or so) and then draw lines between all the dots. I liked the effect it produced and experimented with different angles beween the dots and with different colored pens.

 

I never kept any of those drawings but the memory of them was clear to me last year when I came up with a computerized version of the drawings. Even though I had just leared Actionscript, I decided to create the program with Visual Basic.

 

Here's the interface you see when you first start the program:

 

circle-line-input.jpg

 

The input is simple, you just enter the number of points you want plotted. Even though the opening screen used the word "Spirograph" it really isn't a spirograph program and that's why I called the program CircleLine.

 

Here's the output of the program when you enter 8 for the number of points:

 

circle-line08.jpg

 

Pretty basic but the output gets more intricate with more points. Here's a plot with 30 points:

 

circle-line30.jpg

 

A nice intricate pattern but it looks flat and it wasn't long before I added color to the program. Here's the same 30 point circle with color:

 

circle-line30-color.jpg

 

Much nicer. Here's another circle in color with only 16 points:

 

circle-line16-color.jpg

 

After 60 points, the circles become somewhat meaningless. A solid circle in fact. Here's a mono-colored circle with 90 points:

 

circle-line90.jpg

 

However, with color the result is remarkably different:

 

circle-line90-color.jpg

 

As you can see a lot of aliasing is going on here. One thing I didn't mention about the Pattern program were the moire patterns I got from some of the patterns in the program (especially in the linebox pattern). The moire patterns differed greatly depending on the graphics screens on which they were displayed. For example, the ReGIS and VT241 terminals showed very distinct and remarkable moire patterns. Not so much on my PC and the .jpg files I created.

 

Another thing I did with the Pattern program that I didn't mention was create a timer that would rotate the colors of the drawings. I decided to do the same with the CircleLine program. Here's a movie of the 90 point circle with the colors rotating:

 

circle-line-movie.gif

 

Kinda looks like a sonicgram. Of what, exactly, I don't know.

 

Out of curiousity I wanted to see what a 360 point circle would look like:

 

circle-line360-color.jpg

 

Meh. The only thing of interest is how the lines radiate out of the far right. I'm sure that has something to do with how I'm drawing the lines. I'm currently investigating using a different method of drawing the lines and I'm hoping to get different results.

 

It's fun creating these programs even though the drawings are somewhat basic. I've written a couple programs after finishing the CircleLine program and I'll post the results shortly.

 

By the way, my 9th grade math teacher noticed that I was bored and transferred me to an Algebra class. It was a good move on her part because I found Algebra much more interesting. So much so that I stopped drawing those geometric designs (I went back to those drawings in the 10th grade during my very boring Geometry class).

</lj-cut>

9 Comments


Recommended Comments

Fractal patterns and the Mandelbrot set are something I plan to work on in the near future. I wrote a program for my Atari ST some twenty years ago and the patterns it generated were pretty cool. I started making a bunch of images with the program with the intent of creating a movie. It took at least an hour for the computer to make each frame. Unfortunately I can't find the image files or even the source code for it. This means I'll have to start all over again from scratch.

 

Currently I am reading a book on Chaos Theory and fractal patterns and it's giving me all sorts of ideas about what programs to write. I'm still working on some non-fractal patterns and so it may be a little while before I display any fractal art.

 

Stay tuned, I have more art-generating programs to show off.

Link to comment

Sounds cool; computer generated art has always been interesting to me, even though I'm a terrible artist, and have no interest in ever becoming an artist. But I like looking at it.

 

An interesting variation on your circle-line program would be to vary the points. The way you're implementing it now, all the intervals are equal (I assume, although you didn't show an example with a number of points not divisible by 360). There's a (semi-) famous logic puzzle that goes something like this:

 

There's a circular table with 13 chairs (I don't remember the exact number), each numbered 1-13, going clockwise (like a clock). You want to sit in the chair numbered 1. The way you decided where you will sit is by skipping every other chair. So the first time around, if you choose to start at chair 1, you can't sit in any of the even-numbered chairs. i.e.

 

1 2 3 4 5 6 7 8 9 10 11 12 13

 

Now you're on chair 13, but you still have to skip every other chair, so you cross out chair 1, bypass chair 2 (it's already gone), and now you're on chair 3. After the second iteration, it would look like this:

 

1 2 3 4 5 6 7 8 9 10 11 12 13

 

Keep repeating this process of skipping every other chair until only one chair is left (in the example I just made up, the last chair would be 11). Which chair do you start at so that chair #1 is the last chair left?

 

Obviously, the solution is irrelevant, but I was thinking what if you selected the points on the circle like that? Instead of evenly spacing them out, you choose an interval (in degrees?) that you start with, and place points like that until the entire circle is filled.

 

For example, if you choose your interval to be 7, then you'd place a point at 1, 8, 15, 22, 29, etc. until all points on the perimeter of the circle were filled (assuming each point on the perimeter of the circle was numbered 1-360). I don't know if it would make any difference, but I think each generated circle would look different depending on the interval you chose (after you added color, of course).

 

Anyway, your pictures made me think of that puzzle. I'm not sure if I related it in a coherent fashion, though...

Link to comment
Obviously, the solution is irrelevant, but I was thinking what if you selected the points on the circle like that? Instead of evenly spacing them out, you choose an interval (in degrees?) that you start with, and place points like that until the entire circle is filled.

 

All right, here's a puzzle for you: suppose you're going to want to place some number of points around a circle, but you don't know in advance how many. All points must be placed the same distance around the circle, starting from a certain point, and you want to maximize the distance between the two closest points.

 

If you place the points e.g. every 80 degrees, then your first few nine would be at 0, 80, 160, 240, 320, 40, 120, 200, and 280 but then you'd hit the starting point, so 80 degrees would be no good if you had more than nine points. Using 80.01 degrees instead would let you go a lot longer before you hit the same point twice, but your tenth point would be very close to the first.

 

Is there any spacing that can be chosen so that for any n, the distance between the two closest points is at least 1/2.5n times the circumference of the circle?

 

Hint: the answer is found in nature.

Link to comment

 

Is there any spacing that can be chosen so that for any n, the distance between the two closest points is at least 1/2.5n times the circumference of the circle?

 

Hint: the answer is found in nature.

 

Would that have any relation to the Golden Ratio?

Link to comment

So, my other post got me curious, so I went ahead and created a program to do whatever gibberish I said earlier. Except I'm pretty sure I made a trigonometric mistake somewhere, but I like the results, so I don't really care.

 

Here's a few examples:

 

Interval: 30

circlesCAO2FJVE.png

 

Interval: 15

circlesCALQLK1O.png

 

Interval: 187

circlesCAQG18D5.png

 

Interval: 111

circlesCA1O49Q1.png

 

You get the idea. If you want to play around with it, just change the interval, color and radius variables in the URL.

Here's the source code if anyone's interested: circlesource.php.

 

Edit: My error was actually a group theory error, not a trig error. Fixed version is here: circles 2. It's quite a bit slower, but the differences are pretty evident, e.g. interval 115 circles 2 and interval 115 circles.

Link to comment

Wow. I am loving the responses to this blog entry! You guys are giving me some great ideas for modifications to my CircleLine program. I had moved CircleLine in the "completed" folder but now it's back in the development folder and may stay there a while.

 

First of all, thanks HeckYesIDid for posting your code on the circular chairs problem. I was trying to figure out how to implement that problem in my CircleLine program but I was getting nowhere. It turns out, after examining your code, that my approach to making the lines around the circle is completely different from yours. I noticed that you found out, like I did, that mistakes can sometime yield pleasing results.

 

The way mine works is I calculate the angle between each point by dividing 360 by the number of points. I then calculate the x and y positions of the points and store them in two arrays (an X array and a Y array). Using those arrays, drawing lines between the points becomes trivial.

 

Here's a portion of the main line drawing routine showing the filling of the arrays and the drawing of the lines:

 

	' Fill the array with the points to plot
For i = 1 To NumPoints
	CurAngle = DeltaAngle * CDbl(i - 1) * conPi / 180#
	PlotX(i) = CenterX + Radius * Cos(CurAngle)
	PlotY(i) = CenterY + Radius * Sin(CurAngle)
		
	' Plot a reference dot on the circle
	frmCircleLine.Circle (PlotX(i), PlotY(i)), 50
Next i
	
' Now draw lines connecting the dots
ColorNumber = StartColor
For i = 1 To NumPoints - 1
	For j = i + 1 To NumPoints
		If NumColors > 1 Then
			frmCircleLine.ForeColor = RGB(RedPalette(ColorNumber), GreenPalette(ColorNumber), Bluepalette(ColorNumber))
		
			' Change the line color
			ColorNumber = ColorNumber + 1
			If ColorNumber > MaxColors Then
				ColorNumber = 0
			End If
		End If
		frmCircleLine.Line (PlotX(i), PlotY(i))-(PlotX(j), PlotY(j))
	Next j
Next i

 

As you can see, it doesn't matter if the number of points are evenly divisible by 360: the points will always be evenly distributed across the circle. The only real difference between even and odd number of points in the circle is that you have a black void in the center of the odd-number circle (when there are more than 30 points to plot - not so noticeable when there are less than 30 points).

 

My initial approach to the circular chair problem was to fill the PlotX and PlotY arrays by skipping each second cell until I met the end conditions (therefore the index of the array represented the angle in degrees). However, I would have had to radically change the linedrawing loops and figure out how to not plot the empty cells. I was also using radians instead of degrees, making it even more complicated. It didn't occur to me to use the modulas operator (whatever it is in Visual Basic).

 

Using random colors is a good idea. I created an array and stored a predefined palette in the array. Using random colors would give the program more variety.

 

@supercat: I have no idea what the answer is to your question. The golden ratio, like mezrabad said, would be my first guess. Mandebrot's book, The Fractal Geometry of Nature mentions all sorts of ratios (although 1.26 shows up a lot in his book).

 

BTW, if anyone is interested in the source code for any of these art programs of mine, PM me your E-mail address and I'll send you a zip of all the relevant files.

 

I have a couple other ideas for the CircleLine program. For example, instead of plotting the points on the perimeter of the circle, I could plot them in the interior. I could do this by attenuating the radius with a sine wave or other function (e^x or adding the cos and sin functions comes to mind). I'm guessing here, but the sin function will probably generate a small spiral pattern.

 

I am sometimes amazed how such simple code can generate complicated results.

Link to comment
@supercat: I have no idea what the answer is to your question. The golden ratio, like mezrabad said, would be my first guess. Mandebrot's book, The Fractal Geometry of Nature mentions all sorts of ratios (although 1.26 shows up a lot in his book).

 

The Golden Ratio is indeed magical in this way. Some plants' arrangements of branches tend to tend toward this golden-mean behavior, probably because it minimizes the amount of shading of the lower branches by upper ones.

Link to comment

Here's the main difference in my circles2.php program from circles:

 

$i = 0;
$order = 0;
while ($i != 360)
{
 $i %= 360;
 $order++;
 $i += $interval;
}
 
$i = 0;
while ($i != 360)
{
 $i %= 360;
 for ($j = 0; $j < $order; $j++)
 {
[draw the line with a random color, etc.]   
 }
 $i += $interval;
}

 

The only difference was the number of lines drawn from each point. As you can see (maybe), it depends on the order of the interval in the additive group Z[360]. To figure out the order of an element in this group, you just keep adding it to itself, until it equals 0 mod 360. I think there's an actual formula, or something for figuring that out, but I haven't taken group theory for a few years. What this also does is make all elements with equal order look the same. For example, if your interval is n, then 360-n will look exactly the same.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...