The Fractal Flame
Beauty out of Chaos
Johan Karlsson
- Software developer
- I've been coding since the 90's
- JavaScript and Web since 2013
- Patterns, algorithms, animations, fractals
- Dwitter
- Shadertoy
- CodePen
Creative Coding
- Creating freely
- No requirements
- Expression
- Instant feedback
- Generative / algorithmic art
Why?
- Math and algorithms instead
of textboxes over data - Exploring
- The human machine cooperation
- Being surprised
- Relaxing
Mandelbrot Set
A Fractal
- Math...
- Self-similar
- Benoît Mandelbrot
beautiful, damn hard, increasingly useful. That's fractals.
- Benoît Mandelbrot
Julia Set
Koch Curve
A Fractal Flame
Affine Transformation
Affine Transform
(Wikipedia) "2D affine transformation matrix" by Cmglee - Own work. Licensed under CC BY-SA 3.0 via Commons
IFS - Iterated Function System
- A type of fractal
- Several transformations
- The Chaos Game algorithm
is a common way to compute
(draw) an IFS fractal
The fractal is made up of the union of several copies of itself, each copy being transformed by a function (hence "function system"). - Wikipedia
Sierpinski Triangle - IFS
HSL (HSB)
The Chaos Game
- Create n affine transformations, f1-fn
- Pick a random point (x, y)
-
Loop:
- Apply a random affine transformation to get a new point: (xk+1, yk+1) = fr(xk, yk)
- Plot the new point
Barnsley
Fern
A probability is assigned
to each transformation
Remember
Random IFS
Randomized:
- Number of transformations
- Each coefficient in each transformation
- The color of each transformation
The Fractal Flame
-
Scott Draves
-
Based on the Chaos Game plus:
-
In addition to affine transformations you choose a non-linear function
-
Each affine transformation gets a color associated
-
Using log-density display - a histogram is updated instead of plotting directly
-
Non-linear functions
Swirl
Tangent
Eyefish
The Fractal Flame Algorithm
-
User picks a non-linear function
-
Create n affine transformations, f1-fn
-
Create empty histogram h[width][height]
- Pick a random point (x, y)
The Fractal Flame Algorithm (cont.)
-
Loop (millions of iterations)
- Apply a random affine transformation OR non-linear function to get a new point: (xk+1, yk+1) = fr(xk, yk)
-
Update histogram color and frequency h[x][y]
h[x][y][color] = (h[x][y][color] + colorr) / 2
h[x][y][frequency]++
-
Draw histogram
-
h[x][y][color]
alpha = log(h[x][y][frequency]) / log(frequencymax)
-
Demo
More info
- The Coding Train by Dan Shiffman
- Coding Math by Keith Peters (bit101)
- Bullet Three
References
The Fractal Flame
By Johan Karlsson
The Fractal Flame
- 1,105