
Click on the image to see its parameters.
Tutorial: Dynamic Chaos Game Coloring Formula
Text and Images © 2014
Kerry Mitchell
Introduction
This is a coloring formula that is really a fractal formula--it is not intended for
use with Mandelbrots or Julias, but rather, combines the fractal calculation with
the coloring into one. It is best used with a Pixel fractal formula.
The basis for this is the Chaos Game, often used as introduction to chaos and fractals, and
typically used to generate the Sierpinski triangle.
Here is a
video of it in action.
Background
In the standard chaos game, three anchor points are chosen on a plane. These are the
corners of the Sierpinski triangle and are shown as the red, green, and blue dots in
the figure below.
To begin, a random point is chosen and drawn. Then, at each iteration, one of the
anchor points is chosen randomly. A new point is drawn, halfway between the old point
and the chosen anchor point. Repeat a gazillion times to get the triangle, which is
the attractor for this process. That's why, no matter what point you choose initially,
you'll always get this same picture.
The process is defined by:
- the anchor points (three in this case),
- how often each anchor point is used (randomly selected with each having the
same likelihood), and
- where the new point is relative to the old point and the anchor point (halfway
between them).
In the dynamic chaos game, the anchor points are not fixed, but can rotate around a
circle, a superellipse, a rose curve, a Lissajous curve, or slide back and forth along a segment. How fast
the anchor points move, the probability of a particular anchor being picked, and how
far along the line between the old point and the anchor the new point is, can all be set.
Below are examples showing the Sierpinksi triangle with the anchor points rotating slowly
around a circle, the triangle with the anchors rotating fast, and the triangle with the
anchor points sliding to and from the center. Click on an image to see its parameters.
Parameters
The parameters are in three groups: curve, anchor point, and general drawing.
Curve Parameters. These determine the curve along which the anchor points move. For
the "curve type," choose from "segment," "circle," "superellipse," "rose," and "Lissajous."
- segment: For the segment, the two endpoints will be set below. Here, pick the
"sliding type," how the anchor point accelerates along the line between the two
endpoints. The choices are: "cosine," "sine," "ramp," and "sawtooth."
- circle: Set the radius.
- superellipse: Set the horizontal and vertical axis lengths, and the power. The
power determines the shape:
- less than 1 gives an astroid,
- 1 gives a diamond,
- 2 gives a regular ellipse, and
- as the power gets large (say, more than 4), the superellipse comes closer
to a rectangle.
- rose: Set the amplitude and frequency for both the cosine and sine factors.
- lissajous: Set the amplitude and frequency for both the x and y variables.
Point Parameters
- # points: How many anchor points. You may use any whole number from 2 - 10. For
each point, set its parameters (depending on the curve type):
- segment: Set the two endpoints of the segment.
- circle, superellipse, and lissajous: Set the initialization. "Automatic"
distributes the points evenly around the curve, with point 1 being at 0 degrees
(right edge), and moving counterclockwise. To set the angular location yourself,
choose "manual."
- velocity: How fast the anchor point moves, and in what direction. For all the
rotation curve types (all but "segment"), positive values means counterclockwise
rotation and negative means clockwise. With the "segment" type, positive means
sliding initially from the first endpoint to the second and negative means initially
sliding from the second endpoint to the first.
- distance factor: Where the new iteration point is relative to the old point and the
anchor. Halfway between is 0.5. Zero is right at the anchor and 1 is right at the old
point.
- probability weight: How often, relatively, that this anchor is chosen. If all the
weights are the same, then each anchor will be equally likely to be chosen. To make
point 2 (say) twice as likely to be chosen as point 1, make point 2's weight twice
that of point 1.
Drawing Parameters
- sampling factor: Set higher for more iterations (longer rendering time) or lower for
fewer (shorter rendering time).
- transients: How many times to iterate before drawing a point. Use this to not draw
the first few points, in case your initial z value (below) is way outside of the
attractor.
- scaling: The image is colored by how often the iteration point lands on each pixel.
This parameter determines the relationship between hits and color index.
- linear: Each additional hit adds the same amount to the color index. If there
are a lot of hits (say, a large sampling factor), then this mode can be quite
noisy.
- logarithmic: The relationship between hits and index slows as the number of
hits grows. Great for reducing visual noise.
- hyperbolic tangent: Similar to logarithmic, but the color index will not wrap
around. Beyond some limit, all hits will be mapped to the same color index.
- pre-density: Like the "Color Density" setting, but applied before the scaling
function is used. Only available with the "linear," "logarithmic," and "hyperbolic
tangent" settings.
- average: The average of the anchor point numbers used resulting in hits on
that pixel. For example, if a pixel was hit three times, from anchor points
1, 2, and 6, then the average would be 3.
- which: The number of times the pixel was hit when the iteration used the
anchor point indicated by "which point." For example, if "which point" were 4,
then this mode would color by how many hits the pixel had when anchor point 4
was chosen.
- last: The index of the anchor used when this pixel was last hit.
- solid background: Check to use the "Solid Color" for the background. Otherwise,
color index 0 is used.
- initial seed: Initial seed value for the random number generator. Generally,
the value doesn't matter, but it will give slightly different results when changed.
- initial z: Initial z value. Generally, the value doesn't matter, but it will
give slightly different results when changed.
Hints
- This is one of those coloring formulas that does all the work. It is intended to
be used with a "Pixel" formula, like the one in lkm.ufm.
- Start with a relatively low sampling factor, say around 10, when designing your
image. Then, increase it to fill in the details.
- To use the "hyperbolic tangent" setting to best effect, clear the "Repeat Gradient"
box and have a gradient that has different beginning and ending colors, say black
at index 0 to white at 399.
- To reduce the grainy effect, average together several layers with only the
initial seed and/or the initial z changed.
Sample Image
Here’s how to make the image at the top of this page.
- Start a new fractal, with these characteristics:
- Formula: "Pixel" from lkm.ufm, with the default settings.
- Inside: none (default)
- Outside: "Dynamic Chaos Game" from lkm3.ucl, with the default settings.
Clear the “Repeat Gradient” box.
- Image: set the width to 600 pixels and the height to 600 pixels.
- Gradient: remove all the control points. Insert these:
- index 0: black (0 red, 0 green, 0 blue)
- index 100: dark red (127 red, 0 green, 0 blue)
- index 200: orange (255 red, 127 green, 0 blue)
- index 300: yellow (255 red, 255 green, 0 blue)
- index 399: white (255 red, 255 green, 255 blue)
- Location: Set the Center to -0.12/-0.02, the Magnification to 2, and the
Rotation Angle to -90.
Your image should look like a white off-center disk with a black hole in the middle
and black and yellow bits at the edge.
- On the Outside tab, set "curve type" to "lissajous." Set the "x frequency" to 5.05
and the "y frequency" to 2.95. (Having them not be exactly whole numbers gives some
interesting curves to the interior of the image.)
- Set the "# points" to 2:
- For point 1, leave the "initialization" at "automatic" and the "velocity" at 1.
Set the "distance factor" to 0.9 and leave the "probability weight" at 1.
- For point 2, leave the "initialization" at "automatic" and set the "velocity"
to -2. Set the "distance factor" to 0.9 and leave the "probability weight" at 1.
Having relatively large distance factors makes the image more cloudy.
- Set the "sampling factor" to 50 and the "scaling" to "hyperbolic tangent." Set the
"pre-density" to 0.1 and check the "solid background" box.
This layer should resemble the example image, but grainier. To fix that, let's
average together some more layers.
- Duplicate this layer three times. Each layer should have the "Normal" merge mode.
Change the "initial seed" and "initial z" on each layer so that they're all different.
- Set the opacities for the layers like this:
- Layer 1: 100%
- Layer 2: 50%
- Layer 3: 33%
- Layer 4: 25%
If you wish to add more layers, set their opacities to 100% ÷ the layer
number (so Layer 5 would have an opacity of 20%).
Your image should look like the example. If not, go snag the parameters from the
examples page.
Back
to Tutorials page
Up
to my home page