Last Updated on: 11th January 2024, 05:01 pm
cbonsai – a bonsai tree generator, written in C using ncurses. It intelligently creates, colors, and positions a bonsai tree, and is entirely configurable via CLI options. There are 2 modes of operation: static, and live.
The tree is automatically loaded from the cache file! And, since infinite mode is automatically turned on, it will finish the cached tree and just keep generating more. When you quit cbonsai again, the tree is once again written to the cache file for next time.
Keep in mind that only the seed and number of branches are written to the cache file, so if you want to continue a previously generated tree, make sure you re-specify any other options you may have changed.
cbonsai starts by drawing the base onto the screen, which is basically just a static string of characters. To generate the actual tree, cbonsai uses a ~~bunch of if statements~~ homemade algorithm to decide how the tree should grow every step. Shoots to the left and right are generated as the main trunk grows. As any branch dies, it branches out into a bunch of leaves.
cbonsai has rules for which character and color it should use for each tiny branch piece, depending on things like what type of branch it is and what direction it’s facing.
The algorithm is tweaked to look best at the default size, so larger sized trees may not be as bonsai-like.