Click here to Skip to main content
Click here to Skip to main content

Fractal Tree and Flake Controls

, 31 Dec 2006
Rate this:
Please Sign up or sign in to vote.
Implements a fractal christmas tree and fractal snowflakes.
Fractal Tree and Flakes

Introduction

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:

  1. Snow Flake Fractal
  2. 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.

Tree Fractal

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 drawn branches.

To Do

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 …

  1. Drawing the tree eats up the CPU
  2. Tree can be “animated” (sliding it left to right or right to left)
  3. Some Snow Flakes seem to have an improper drawing pattern
  4. Create a screen saver

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Bryan Ray
Web Developer
United States United States
I've been working with C# since .NET Beta 1 and have been in the development scene since VB3.
 
I've always had a passion for development, technology, and computer as a whole. I consider myself one of the lucky few who actually love their job.
 
I've mostly been involed with web development in the corporate world, but I also work with Windows Forms development at home. Over the past 3 years or so the .NET applications I've developed have been backend maintenance applications. Transfering data, manipulating data, or doing some other back-end processes.

Comments and Discussions

 
GeneralEasing the processor time PinmemberIsbjorn_x20-Nov-08 5:16 
GeneralRe: Easing the processor time PinmemberBryan Ray31-May-09 15:43 
GeneralYou're not the first person... PinprotectorMarc Clifton31-Dec-06 12:10 
GeneralRe: You're not the first person... PinmemberLogical31-Dec-06 12:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1411023.1 | Last Updated 31 Dec 2006
Article Copyright 2006 by Bryan Ray
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid