kd-forest
kd-forest copied to clipboard
An implementation of k-d forests
k-d forests
An implementation of k-d forests.
This code generates images containing every possible color, in the style of this Code Golf answer by József Fejes. Colors are placed on the image one by one, next to the closest pixel already filled in.
Images
The full 24-bit, 4096×4096 image is generated by default, which takes a while:
$ cargo run --release
Generating a 4096x4096 image (16777216 pixels)
100.00% | 159 kpx/s | max frontier size: 267592
To try it out quickly, generate an image with reduced bit depth:
$ cargo run --release -- -b19
Generating a 1024x512 image (524288 pixels)
100.00% | 285 kpx/s | max frontier size: 18719
There are many flags that control the order colors are placed, and how the location for each color is selected.
Pass --help
to see the available options.
Video
To make a video of the generation process, pass the -a
/--animate
flag, and pipe the output into ffmpeg
.
For example:
$ cargo run --release -- -b23 -w3840 -h2160 -a | ffmpeg -f image2pipe -r 60 -i - -c:v libx265 -x265-params lossless=1 kd-forest.mkv