This is officially my first article on CodeProject. I've been a avid reader for some time now and I just thought I'd give it a shot.
Before I begin I'd like to state that a majority of the code in this application is taken from two other articles found here on CodeProject:
Both Tomas and Marc are great developers and contribute a lot to the CP. I just wanted to make sure credit is given where credit is due.
If you would like more detail on this application then please check out those articles first.
That being said ... while Marc's Fractal Christmas Tree is a great fractal algorithm a lot of the code
was very difficult to understand, debug, and follow. This is partly due to the way he generates his forms using
his extremely interesting AAL (Application Automation Layer) Framework and because he comes from a strong C++ background
which, in my opinion, distorts a lot of the "cleanliness" to his C# code.
Anyways ... I just decided to simplify the application and put more focus on the fractal tree algorithm. I also moved the code in to a custom user control allowing users to simply drag and drop a tree control on to a form.
What is a fractal?
Wikipedia defines a fractal as, "a rough or fragmented geometric shape that can be subdivided in parts, each of which is (at least approximately) a reduced/size copy of the whole."
What does this mean to a developer? Basically it means that fractals are generated using recursion. This application uses two types of fractal algorithms:
- Snow Flake Fractal
- Tree Fractal
Snow Flake Fractal
The snow flake fractal is fairly simple (although some of the math can get confusing if you didn’t pay attention in
geometry and/or algebra). The drawing operation is performed on the line connecting the center of the snowflake with
its edge and then on new lines created in first step.
The tree fractal is even simpler than the Snow Flake Fractal. Basically, it draws one central line (stem) and then
divides that and places a “left branch” and a “right branch” … then uses recursion to do the same thing on the newly
This application still has a few flaws that I haven’t had time to debug yet. Here’s a list of things that I know
need to be worked on …
- Drawing the tree eats up the CPU
- Tree can be “animated” (sliding it left to right or right to left)
- Some Snow Flakes seem to have an improper drawing pattern
- Create a screen saver