NAME

Math::Fractal::DLA - Diffusion Limited Aggregation (DLA) Generator

SYNOPSIS

use Math::Fractal::DLA;
$fractal = new Math::Fractal::DLA;

# Dynamic loading of the subclass Math::Fractal::DLA::TYPE
$fractal->setType( TYPE ); 

# Open the log file FILE
$fractal->debug( debug => 1, logfile => FILE );

# Add a message to the log file
$fractal->addLogMessage( MESSAGE );
 
# Global settings
$fractal->setSize(width => 200, height => 200);
$fractal->setPoints(5000);
$fractal->setFile( FILENAME );
 
# Color settings
$fractal->setBackground(r => 255, g => 255, b => 255);
$fractal->setColors(5);
$fractal->setBaseColor(base_r => 10, base_g => 100, base_b => 100, add_r => 50, add_g => 0, add_b => 0);

# Write the generated fractal to a file
$fractal->writeFile();

# Or return it
$fractal->getFractal();

DESCRIPTION

Math::Fractal::DLA is a Diffusion Limited Aggregation (DLA) fractal generator

OVERVIEW

The Diffusion Limited Aggregation (DLA) fractal belongs to the group of stochastic fractals.

It was invented by the two physicists T.A. Witten and L.M. Sander in 1981. The fractal is created by single particles which move randomly towards an target area. By hitting the area the particle becomes a part of it and the fractal grows.

Math::Fractal::DLA is just the framework for subclasses like Math::Fractal::DLA::Explode and doesn't implement any methods for fractal generation. To generate a fractal, you have to create a Math::Fractal::DLA object and load the subclass by calling the method setType. Otherwise you have to use an object from a subclass directly without calling the method setType. For the specific methods of the subclasses, take a look at their perldoc.

CONSTRUCTOR

new

This is the constructor for Math::Fractal::DLA

No parameters are required

METHODS

debug ( debug => 1, logfile => FILENAME )

Activates the debug mode

The debug information will be appended to FILENAME

addLogMessage ( MESSAGE )

Adds MESSAGE to the log file

loadFile ( FILENAME )

Loads an existing image in JPG- or PNG-format and uses it as background image

setSize ( width => WIDTH, height => HEIGHT )

Sets the size of the image

setPoints ( NUMBER )

Sets the number of points that will be used for the fractal

setFile ( FILENAME )

Sets the output file. Supported file formats are JPG and PNG

writeFile

Writes the fractal to the file specified by the method setFile

getFractal

Returns the fractal

COLOR SETTINGS

All colors are specified with their RGB-values which range from 0 to 255.

setBackground ( r => RED, g => GREEN, b => BLUE )

Sets the background color for the image.

setColors ( NUMBER )

Sets the number of colors which will be used.

setBaseColor ( base_r => RED, base_g => GREEN, base_b => BLUE, add_r => RED, add_g => GREEN, add_b => BLUE )

Starting with the base color, defined by base_r, base_g, base_b, the values of add_r, add_g and add_b will be added after each interval (number of points / colors). The values of add_r, add_g and add_b may be less than zero.

Example:

You want to use 5 colors in your fractal with a base color of base_r => 10, base_g => 100, base_b => 100 and the add values of add_r => 50, add_g => 0, add_b => 0:

$fractal->setColors(5); $fractal->setBaseColor(base_r => 10, base_g => 100, base_b => 100, add_r => 50, add_g => 0, add_b => 0);

As result the following colors will be used to draw the fractal:

(r,g,b): (10,100,100), (60,100,100), (110,100,100), (160,100,100), (210,100,100)

AUTHOR

Wolfgang Gruber, w.gruber@urldirect.at

SEE ALSO

Lincoln D. Stein's GD module

COPYRIGHT

Copyright (c) 2002 by Wolfgang Gruber. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.