Skip to content

Instantly share code, notes, and snippets.

@guidoschmidt
Created January 11, 2024 22:31
Show Gist options
  • Save guidoschmidt/09fdb6cd12aac7e99bce0bbc9871a833 to your computer and use it in GitHub Desktop.
Save guidoschmidt/09fdb6cd12aac7e99bce0bbc9871a833 to your computer and use it in GitHub Desktop.

Revisions

  1. guidoschmidt created this gist Jan 11, 2024.
    15 changes: 15 additions & 0 deletions animate-ascii.zig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    fn printDefault(c: u8) void {
    std.debug.print("{c}", .{ c });
    }

    fn animate(buffer: *[]u8, rows: u32, cols: u32, comptime print_fn: fn(u8) void) void {
    for(0..rows) |dy| {
    for(0..cols) |dx| {
    const idx = dy * cols + dx;
    const pipe_tile = buffer.*[idx];
    std.debug.print("\x1B[{d};{d}H", .{ dy, dx });
    print_fn(pipe_tile);
    }
    }
    std.time.sleep(1000 * 1000 * 16);
    }