Fractal Explorer

One possible result:

Fractal gras

Fractal Explorer

Computer Graphics - 2D Fractal Grass

Introduction


In Computer Games one often needs 2D grass tiles. When one tries to create such a grass tile with usual methods one will probably fail. It will take a long time and even if there are more than 1 different grass tile the variation would not be big.

One possible solution for this problem are fractals. Think about it. What is a meadow when you look on it from a birds perspective. Basically lots of blades of grass, all looking a bit different due to the different angle to the sun. Nothing fractal about that one might think. But in fact a meadow can be simulated by fractals very well.

 

The Algorithm for 2D fractal grass


How can you tell a computer to put blades of grass all over a canvas? Well take the canvas, draw a green (random green!) line from middle-bottom to middle-top. Divide the canvas in four rectangles and repeat this steps.

After about 8 to 9 iterations the lines will become a plane. That of course depends on the size of the canvas. Because every line has a different color the effect of blades of grass in the sun is created. Creating such an effect manually would take ages.

Furthermore it is possible to create a meadow with a "wind direction". This is accomplished with the rotation of the lines. It is enough to rotate them by only one pixel to the left or the right. You can tell from the result in what direction the "wind blows".

This example has the aim to show you that even if the reality is not fractal it can sometimes be described using a fractal. Creating reality-like structures using fractals is a very important feature that you have to understand if you want to understand the power of fractals.