A bot that generates a random fractal and posts it to Mastodon.
The bot renders a Julia set
via a distance-estimation method.
Each Julia set is determined by a complex function
stays bounded.
In order, the bot does the following:
- Read the complex parameter
$c$ from the command line (-c
), or sample it randomly. - Approximate the bounding box of the set via inverse iteration. This method yields a sequence of points on the boundary of the set from which the bounding box is computed.
- Scale the bounding box to 120% to add a slight margin.
- Select a color palette, depending on whether the set is connected or not.
A Julia set is connected if and only if iteration for
$z_0 = 0+0i$ stays bounded (i.e.$c$ is contained in the Mandelbrot set). - For each pixel in the final image, estimate the distance of the corresponding
complex point in the bounding box to the set.
For distances
$\leq 0$ , the point is assumed to lie inside the set and is colored black, otherwise a color is sampled from the palette. Color palettes are generated following Inigo Quilez' amazing tutorial. Rendering is parallelized usingrayon
. - Depending on the mode, save the image to disk or post it to Mastodon.
To interact with Mastodon,
megalodon
is used.