feat: add custom ascii art

This commit is contained in:
utox39
2025-09-10 14:21:22 +02:00
parent 3cfae25a75
commit 20e2ef80d2
3 changed files with 18 additions and 8 deletions

View File

@@ -65,18 +65,23 @@ test "parse ffffff" {
try std.testing.expect((result.r == 255) and (result.g == 255) and (result.b == 255));
}
pub fn printAscii(allocator: std.mem.Allocator, sys_info_list: std.array_list.Managed([]u8)) !void {
pub fn printAscii(allocator: std.mem.Allocator, ascii_art_path: ?[]u8, sys_info_list: std.array_list.Managed([]u8)) !void {
var stdout_buffer: [2048]u8 = undefined;
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
const stdout = &stdout_writer.interface;
// const ascii_art_path = "./assets/ascii/guy_fawks.txt";
// var file = try std.fs.cwd().openFile(ascii_art_path, .{});
// defer file.close();
// const ascii_art_data = try file.readToEndAlloc(allocator, std.math.maxInt(usize));
// defer allocator.free(ascii_art_data);
var ascii_art_data: []const u8 = undefined;
if (ascii_art_path) |ascii| {
var ascii_file = try std.fs.cwd().openFile(ascii, .{});
defer ascii_file.close();
ascii_art_data = try ascii_file.readToEndAlloc(allocator, std.math.maxInt(usize));
} else {
ascii_art_data = @embedFile("./assets/ascii/guy_fawks.txt");
}
const ascii_art_data = @embedFile("./assets/ascii/guy_fawks.txt");
defer if (ascii_art_path != null) {
allocator.free(ascii_art_data);
};
var lines = std.mem.splitScalar(u8, ascii_art_data, '\n');