mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
Add customizable foreground color to CMatrix (#652)
* Final fixes, adding fg_ini as field * Capital B changed to lowercase
This commit is contained in:
@@ -34,8 +34,9 @@ dots: []Dot,
|
||||
lines: []Line,
|
||||
frame: u64,
|
||||
count: u64,
|
||||
fg_ini: u16,
|
||||
|
||||
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Matrix {
|
||||
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, fg_ini: u16) !Matrix {
|
||||
const dots = try allocator.alloc(Dot, terminal_buffer.width * (terminal_buffer.height + 1));
|
||||
const lines = try allocator.alloc(Line, terminal_buffer.width);
|
||||
|
||||
@@ -48,6 +49,7 @@ pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Matrix {
|
||||
.lines = lines,
|
||||
.frame = 3,
|
||||
.count = 0,
|
||||
.fg_ini = fg_ini,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -145,7 +147,8 @@ pub fn draw(self: *Matrix) void {
|
||||
var y: u64 = 1;
|
||||
while (y <= self.terminal_buffer.height) : (y += 1) {
|
||||
const dot = self.dots[buf_width * y + x];
|
||||
var fg: u16 = @intCast(termbox.TB_GREEN);
|
||||
|
||||
var fg: u16 = self.fg_ini;
|
||||
|
||||
if (dot.value == -1 or dot.value == ' ') {
|
||||
_ = termbox.tb_set_cell(@intCast(x), @intCast(y - 1), ' ', fg, termbox.TB_DEFAULT);
|
||||
|
||||
@@ -16,6 +16,7 @@ clock: ?[:0]const u8 = null,
|
||||
console_dev: [:0]const u8 = "/dev/console",
|
||||
default_input: Input = .login,
|
||||
fg: u8 = 8,
|
||||
cmatrix_fg: u8 = 3,
|
||||
hide_borders: bool = false,
|
||||
hide_key_hints: bool = false,
|
||||
initial_info_text: ?[]const u8 = null,
|
||||
|
||||
@@ -230,7 +230,7 @@ pub fn main() !void {
|
||||
switch (config.animation) {
|
||||
.none => {},
|
||||
.doom => doom = try Doom.init(allocator, &buffer),
|
||||
.matrix => matrix = try Matrix.init(allocator, &buffer),
|
||||
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg),
|
||||
}
|
||||
defer {
|
||||
switch (config.animation) {
|
||||
|
||||
Reference in New Issue
Block a user