feat(animations): wire bonsai into renderer

Adds the `.bonsai` variant to the Animation enum and a matching arm in
main.zig's animation switch that reads the `bonsai_*` config fields and
constructs the widget. The example config.ini's animation comment list
is updated to mention the new option.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
CM Geldenhuys 2026-05-04 20:02:03 +02:00
commit 6c99e7f8bd
3 changed files with 24 additions and 0 deletions

View file

@ -25,6 +25,7 @@ allow_empty_password = true
# colormix -> Color mixing shader
# gameoflife -> John Conway's Game of Life
# dur_file -> .dur file format (https://github.com/cmang/durdraw/tree/master)
# bonsai -> Procedurally-generated ASCII bonsai tree (port of cbonsai)
animation = none
# Delay between each animation frame in milliseconds

View file

@ -7,6 +7,7 @@ pub const Animation = enum {
colormix,
gameoflife,
dur_file,
bonsai,
};
pub const DisplayServer = enum {

View file

@ -23,6 +23,7 @@ const IniParser = ly_core.IniParser;
const ini = ly_core.ini;
const Ini = ini.Ini;
const Bonsai = @import("animations/Bonsai.zig");
const Cascade = @import("animations/Cascade.zig");
const ColorMix = @import("animations/ColorMix.zig");
const Doom = @import("animations/Doom.zig");
@ -1089,6 +1090,27 @@ pub fn main(init: std.process.Init) !void {
);
animation = dur.widget();
},
.bonsai => {
var bonsai = try Bonsai.init(
state.allocator,
&state.buffer,
state.config.bonsai_base_type,
state.config.bonsai_life,
state.config.bonsai_multiplier,
state.config.bonsai_leaves,
state.config.bonsai_leaf_dark,
state.config.bonsai_leaf_bright,
state.config.bonsai_wood_dark,
state.config.bonsai_wood_bright,
state.config.bonsai_text_color,
state.config.bonsai_step_ms,
state.config.bonsai_finish_pause_ms,
&state.animate,
state.config.animation_timeout_sec,
state.config.animation_frame_delay,
);
animation = bonsai.widget();
},
}
defer if (animation) |a| a.deinit();