13,151,791 members (58,384 online)
alternative version

#### Stats

37.6K views
26 bookmarked
Posted 31 Dec 2006

# Fractal Tree and Flake Controls

, 31 Dec 2006
 Rate this:
Implements a fractal christmas tree and fractal snowflakes.

## 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

A list of licenses authors might use can be found here

## Share

 Web Developer 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.

## You may also be interested in...

 First Prev Next
 Easing the processor time Isbjorn_x20-Nov-08 4:16 Isbjorn_x 20-Nov-08 4:16
 Re: Easing the processor time Bryan Ray31-May-09 14:43 Bryan Ray 31-May-09 14:43
 You're not the first person... Marc Clifton31-Dec-06 11:10 Marc Clifton 31-Dec-06 11:10
 Re: You're not the first person... Logical31-Dec-06 11:15 Logical 31-Dec-06 11:15
 Last Visit: 31-Dec-99 18:00     Last Update: 26-Sep-17 3:22 Refresh 1