Fraczal is a command-line program that generates images of the Mandelbrot set. Its current differentiating feature is its support for user-defined sequential color palettes in the HCL color space.
The name comes from the terms fractal, a shape or process containing fine recurring structure, and quetzal, a colorful bird found in Mexico and Central America.
The HCL color space is a color model that has been recommended for data visualization in such papers as Escaping RGBland, Somewhere Over the Rainbow and colorspace, in which it’s presented as a more intuitive alternative to the well-known RGB, HSL and HSV models. It is thought to provide an accurate model of human color vision and is a perceptually uniform color space (all neighboring pairs of colors appear equally distinct). We care about this because we want changes in color to represent changes in data accurately.
To remain consistent with the scientific literature, we use the term “HCL color space” to refer to the CIELCh(uv) or polar L*, u*, v* color space, a cylindrical transformation of the CIE 1976 L*, u*, v* (CIELUV) color space.
Fraczal is pre-release software and must be built from source.
Rust 1.63 or newer
git clone https://github.com/ok-ryoko/fraczal
cd fraczal
cargo build --release
After following the installation instructions, running the following command in the root of this repository should generate a 1280-by-720 24-bit PNG image of the Mandelbrot set colored using Fabio Crameri’s Lajolla palette.
./target/release/fraczal \
-W=1280 \
-H=720 \
--upper-left='-2 + 0.5i' \
--cheight=1 \
-p=assets/palettes/Lajolla.json
The bounding box corresponding to this image extends from −2 + 0.5i to about −0.2 − 0.5i in the complex plane. By default, the aspect ratio of the bounding box is equal to the aspect ratio of the image dimensions (in this example, 1280/720 or 16/9), meaning that we need to provide only the desired height of the bounding box. This ensures that distortion-free images are generated.
The width of the output image in pixels
The height of the output image in pixels
The location of the upper-left corner of the bounding box in the complex plane in the form 'a + bi'
The height of the bounding box in the complex plane
The path to a JSON file containing a palette definition
The aspect ratio of the bounding box in the complex plane (defaults to the ratio of the width and height of the output image)
The maximum number of iterations to allow per point in the complex plane (defaults to 1000
)
The path to the output image (defaults to a .png file in the current directory named after the Unix epoch when the program started writing the image to disk)
Reverse the palette
Fraczal supports only sequential color palettes. The lightness in a sequential color palette changes monotonically. Sequential palettes are therefore a natural choice for escape-time coloring strategies, which rely on a monotonically increasing, non-negative quantity (the escape time).
The HCL color space is ideal for sequential palette discovery because it is perceptually uniform. Fraczal includes 70 such sequential palettes. These are available in the assets/palettes directory and have been adapted from the colorspace R package.
Fraczal implements the palette selection strategy described in the colorspace paper. Palettes are defined as JSON files like so:
{
"name": "Viridis",
"start": { "h": 300, "C": 40, "L": 15 },
"end": { "h": 70, "C": 95, "L": 90 },
"powerC": 1.0,
"powerL": 1.1
}
start
and end
are the endpoints of the palette, supplied as CIELCh(uv) coordinates:
-
h
is the hue,$h_{uv}$ , an angle in degrees; -
C
is the chroma,$C_{uv}^*$ , a real number greater than or equal to 0, and -
L
is the lightness,$L^*$ , a real number between 0 and 100 (inclusive).
Fraczal doesn’t enforce the constraints on C
and L
—they are purely logical. Values that don’t respect the constraints may lead to unexpected results.
powerC
and powerL
are real numbers that determine whether C
and L
, respectively, change linearly. C
and L
change linearly if their respective power is equal to 1; they otherwise change nonlinearly.
h
always changes linearly.
Some palettes have a Cmax
field that imposes an upper limit on C
. We would set this field when we want C
to take a “triangular” trajectory, increasing to Cmax
before decreasing.
Please take time to read the code of conduct before reaching out for support or making a contribution.
If you’re encountering unexpected or undesirable program behavior, check the issue tracker to see whether your problem has already been reported. If not, please consider taking time to create a bug report and make the community aware of the problem.
If you have questions about using the program or participating in the community around the program, consider starting a discussion.
Ryoko is accepting contributions in the form of bug reports and feature suggestions. You can contribute by opening an issue and filling out the appropriate template.
You will soon be able to work on Fraczal and open pull requests.
Fraczal is free and open source software licensed under the MIT license.
The color
module draws on information from the following sources:
- C. Poynton, Digital Video and HDTV: Algorithms and Interfaces. San Francisco, CA, USA: Morgan Kaufmann, 2003, ch. 21–23, pp. 219, 225–227, 230, 251 and 267, doi: 10.1016/B978-1-55860-792-7.X5061-7
- J. Schanda, Colorimetry: Understanding the CIE System, J. Schanda, Ed. Hoboken, NJ, USA: John Wiley & Sons, 2007, ch. 3, p 61
The palettes
submodule is based on foundational work by the developers (Ross Ihaka et al.) of the colorspace R package:
- A. Zeileis, J. C. Fisher, K. Hornik, R. Ihaka, C. D. McWhite, P. Murrell, R. Stauffer and C. O. Wilke, “colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes,” Journal of Statistical Software, vol. 96, no. 1, Nov. 2020, doi: 10.18637/jss.v096.i01
Open Source Guides, the GitHub documentation and the github/docs repository have been instrumental in preparing this repository for community contributions.