home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
f
/
fractal112
/
!Fractal
/
Help
/
CellFill
< prev
next >
Wrap
Text File
|
1996-10-09
|
4KB
|
69 lines
CellFill: A Space Filling Cellular Automata
========
This function is a bona-fide flood fill algorithm based on a cellular
automata. It creates an amazing textured pattern that is beautiful in its
own right, or which may be combined with other fractals to fill in the
background eg. L-Systems. The initial fill points (live cells) can be
specified from the menu or set by the mouse. Each cell then grows randomly
in each direction until there are no adjoining unfilled cells. The strange
pattern results from using different colours depending in which direction
the new cell was filled.
An unfilled cell is one in the colour at the initial cell position. By using
mouse selection you can specify where the initial point is and thus the
colour to be filled.
The textures created can look like terrains, crumpled paper, bark, metal
foil, rock faces etc, depending on the colours and initial pattern. Try
different display palettes and the palette adjust facility. See the
MandyGold and Pop_Fill scripts for ideas. Note that the L-System fill calls
this function, so the following settings take effect there as well.
Data Items: The first 4 items specify the fill colour when converting an
empty (black) cell. The directions are relative to the cell being processed.
The Die colour specifies the value to be added to the cell that created a
new cell (-255 to 255, 0 for no change). The Draw Colour is the value to use
when using mouse selection. All colour values are physical colour numbers
(0-255) - use !EditPal to see what they look like.
Menu Items: The From submenu allows the setting of the initial fill points -
the corners or centre of the image. Alternatively Mouse Select allows you to
choose your own start points - see below. The Presets submenu leads to a
selection of preset colour values to get you going - the colours assume you
are using the Default palette.
Mouse Select: When on this allows you to specify the initial fill cells. It
may be combined with the preset cells. Press Redraw then press Select at the
points where you want to fill from - the point will be temporarily set to
the Draw Colour to show it has been selected. To end selection, press Menu,
and the shape will be drawn. To create terrains draw lines corresponding to
where you want the ridges. To create a volcano, draw a circle. If you press
Adjust then the point is drawn but does not become an active cell. This
allows you to draw barriers to enclose or alter the fill pattern.
Hints On Colouring: A good way to think of the colour schema is to imagine a
point of light coming from one side. Set this side to the brightest colour,
the opposite side to the darkest, and the two perpendicular sides to
in-between shades. For the preset colours, the light comes from top right.
Set the Draw Colour to one of the fill colours so that your outline shape
merges with the fill colour.
By setting a fill colour to the initial cell colour (eg. 0) you effectively
stop growth in that direction, which can lead to other interesting effects
Algorithm: A set of initial points are chosen as the live cells. A cell is
then chosen at random from this set and the adjacent cells inspected. If not
set (colour=initial cell colour) then the cell is coloured depending whether
it is above, below, left or right of the chosen cell. These new cells are
added to the set of live cells. The original cell is then killed, changing
its colour by the 'Die colour' value. The process is repeated until all
cells are dead.
It is possible to extend this algorithm to handle all 8 surrounding cells
rather than 4, the result being a much smoother display especially when
using shading colours. I've stuck to 4 because it is easier to choose 4
suitable colours.
My thanks to Jean Van Mourik for this algorithm.
Nb. This function works best in modes with square pixels, eg. Mode 21 or 13.