Page
Library
Module
Module type
Parameter
Class
Class type
Source
Fractals defined by iterated function systems, drawn with the chaos game — in a graphics window, or into a PNG file with no display needed.
An iterated function system is a handful of affine maps, each contracting. Applied over and over to a point, in an order drawn at random, they trace out a single figure — the attractor of the system — no matter where one starts. A whole fern is four such maps:
let barnsley =
{ po = {x= -2.25; y= -0.50};
sz = {x= 5.00; y= 11.00};
lt = [{pb= 0.84; kf= [| 0.85; 0.04; 0.00; -0.04; 0.85; 1.60|] };
{pb= 0.91; kf= [|-0.15; 0.28; 0.00; 0.26; 0.24; 0.44|] };
{pb= 0.98; kf= [| 0.20; -0.26; 0.00; 0.23; 0.22; 1.60|] };
{pb= 1.00; kf= [| 0.00; 0.00; 0.00; 0.00; 0.16; 0.00|] }] }Everything is in a single module, Ifs_fractals.
utop # open Ifs_fractals;;
utop # show barnsley 200_000;; (* draw it, wait for a key *)
utop # save_png ~color:true lace 300_000 "lace.png";;Sixteen systems are predefined, listed in Ifs_fractals.all, and more can be read from Fractint .ifs files with Ifs_fractals.load_fractint, including the three-dimensional ones, which are projected from a direction of your choosing.
The same from a shell:
$ ifs-fractals --list
$ ifs-fractals barnsley
$ ifs-fractals -o lace.png -s 800x800 -c lace
$ ifs-fractals -f classics.ifs -v 30,20 3dfern