Sierpinski’s triangle

I had always wanted to program the chaos game,… I know, it is a stupid thing…

Well here is it:
I used Opengl in C# with the Tao Framework. Most of the opengl in my code is from the nehe tutorials.

You can put as many points as you want, but be careful with your memory, they are stored in an arraylist (the C# equivalent to a Java, C and many other languages vectors)

The insteresting part are this 4 lines of code:
//the three vertices of triangle
oglw.mainvertex.Add(new obvertex(5f,13f));
oglw.mainvertex.Add(new obvertex(-15f,-15f));
oglw.mainvertex.Add(new obvertex(15f, -11f));
//starting point
oglw.obvertexArr.Add(new obvertex(0f,0f));

Change the values to see what happen
Features:Zoom in and out: i o keys
panning: arrow keys
turn off the axes: c key

Sierpinsky's triangle

Binary here
Source here (Visual C# Express 2005)
Source here SharpDevelop project

Posted on October 12, 2005 at 10:28 pm by Isaias · Permalink
In: Software

Leave a Reply