mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
Allow changing matrix animation min/max codepoints (closes #615)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -77,6 +77,14 @@ clock = null
|
|||||||
# CMatrix animation foreground color id
|
# CMatrix animation foreground color id
|
||||||
cmatrix_fg = 0x0000FF00
|
cmatrix_fg = 0x0000FF00
|
||||||
|
|
||||||
|
# CMatrix animation minimum codepoint. It uses a 16-bit integer
|
||||||
|
# For Japanese characters for example, you can use 0x3000 here
|
||||||
|
cmatrix_min_codepoint = 0x21
|
||||||
|
|
||||||
|
# CMatrix animation maximum codepoint. It uses a 16-bit integer
|
||||||
|
# For Japanese characters for example, you can use 0x30FF here
|
||||||
|
cmatrix_max_codepoint = 0x7B
|
||||||
|
|
||||||
# Color mixing animation first color id
|
# Color mixing animation first color id
|
||||||
colormix_col1 = 0x00FF0000
|
colormix_col1 = 0x00FF0000
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ const termbox = interop.termbox;
|
|||||||
|
|
||||||
pub const FRAME_DELAY: usize = 8;
|
pub const FRAME_DELAY: usize = 8;
|
||||||
|
|
||||||
// Allowed codepoints
|
|
||||||
pub const MIN_CODEPOINT: u16 = 33;
|
|
||||||
pub const MAX_CODEPOINT: u16 = 123 - MIN_CODEPOINT;
|
|
||||||
|
|
||||||
// Characters change mid-scroll
|
// Characters change mid-scroll
|
||||||
pub const MID_SCROLL_CHANGE = true;
|
pub const MID_SCROLL_CHANGE = true;
|
||||||
|
|
||||||
@@ -36,8 +32,10 @@ lines: []Line,
|
|||||||
frame: usize,
|
frame: usize,
|
||||||
count: usize,
|
count: usize,
|
||||||
fg_ini: u32,
|
fg_ini: u32,
|
||||||
|
min_codepoint: u16,
|
||||||
|
max_codepoint: u16,
|
||||||
|
|
||||||
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, fg_ini: u32) !Matrix {
|
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, fg_ini: u32, min_codepoint: u16, max_codepoint: u16) !Matrix {
|
||||||
const dots = try allocator.alloc(Dot, terminal_buffer.width * (terminal_buffer.height + 1));
|
const dots = try allocator.alloc(Dot, terminal_buffer.width * (terminal_buffer.height + 1));
|
||||||
const lines = try allocator.alloc(Line, terminal_buffer.width);
|
const lines = try allocator.alloc(Line, terminal_buffer.width);
|
||||||
|
|
||||||
@@ -51,6 +49,8 @@ pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, fg_ini: u32)
|
|||||||
.frame = 3,
|
.frame = 3,
|
||||||
.count = 0,
|
.count = 0,
|
||||||
.fg_ini = fg_ini,
|
.fg_ini = fg_ini,
|
||||||
|
.min_codepoint = min_codepoint,
|
||||||
|
.max_codepoint = max_codepoint - min_codepoint,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ pub fn draw(self: *Matrix) void {
|
|||||||
const randint = self.terminal_buffer.random.int(u16);
|
const randint = self.terminal_buffer.random.int(u16);
|
||||||
const h = self.terminal_buffer.height;
|
const h = self.terminal_buffer.height;
|
||||||
line.length = @mod(randint, h - 3) + 3;
|
line.length = @mod(randint, h - 3) + 3;
|
||||||
self.dots[x].value = @mod(randint, MAX_CODEPOINT) + MIN_CODEPOINT;
|
self.dots[x].value = @mod(randint, self.max_codepoint) + self.min_codepoint;
|
||||||
line.space = @mod(randint, h + 1);
|
line.space = @mod(randint, h + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ pub fn draw(self: *Matrix) void {
|
|||||||
if (MID_SCROLL_CHANGE) {
|
if (MID_SCROLL_CHANGE) {
|
||||||
const randint = self.terminal_buffer.random.int(u16);
|
const randint = self.terminal_buffer.random.int(u16);
|
||||||
if (@mod(randint, 8) == 0) {
|
if (@mod(randint, 8) == 0) {
|
||||||
dot.value = @mod(randint, MAX_CODEPOINT) + MIN_CODEPOINT;
|
dot.value = @mod(randint, self.max_codepoint) + self.min_codepoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ pub fn draw(self: *Matrix) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const randint = self.terminal_buffer.random.int(u16);
|
const randint = self.terminal_buffer.random.int(u16);
|
||||||
dot.value = @mod(randint, MAX_CODEPOINT) + MIN_CODEPOINT;
|
dot.value = @mod(randint, self.max_codepoint) + self.min_codepoint;
|
||||||
dot.is_head = true;
|
dot.is_head = true;
|
||||||
|
|
||||||
if (seg_len > line.length or !first_col) {
|
if (seg_len > line.length or !first_col) {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ brightness_up_key: ?[]const u8 = "F6",
|
|||||||
clear_password: bool = false,
|
clear_password: bool = false,
|
||||||
clock: ?[:0]const u8 = null,
|
clock: ?[:0]const u8 = null,
|
||||||
cmatrix_fg: u32 = 0x0000FF00,
|
cmatrix_fg: u32 = 0x0000FF00,
|
||||||
|
cmatrix_min_codepoint: u16 = 0x21,
|
||||||
|
cmatrix_max_codepoint: u16 = 0x7B,
|
||||||
colormix_col1: u32 = 0x00FF0000,
|
colormix_col1: u32 = 0x00FF0000,
|
||||||
colormix_col2: u32 = 0x000000FF,
|
colormix_col2: u32 = 0x000000FF,
|
||||||
colormix_col3: u32 = 0x20000000,
|
colormix_col3: u32 = 0x20000000,
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ pub fn main() !void {
|
|||||||
switch (config.animation) {
|
switch (config.animation) {
|
||||||
.none => {},
|
.none => {},
|
||||||
.doom => doom = try Doom.init(allocator, &buffer),
|
.doom => doom = try Doom.init(allocator, &buffer),
|
||||||
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg),
|
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg, config.cmatrix_min_codepoint, config.cmatrix_max_codepoint),
|
||||||
.colormix => color_mix = ColorMix.init(&buffer, config.colormix_col1, config.colormix_col2, config.colormix_col3),
|
.colormix => color_mix = ColorMix.init(&buffer, config.colormix_col1, config.colormix_col2, config.colormix_col3),
|
||||||
}
|
}
|
||||||
defer {
|
defer {
|
||||||
|
|||||||
Reference in New Issue
Block a user