working on things
This commit is contained in:
+15
-26
@@ -1,9 +1,11 @@
|
||||
const std = @import("std");
|
||||
const grome = @import("grome");
|
||||
const grome = @import("root.zig");
|
||||
|
||||
const Io = std.Io;
|
||||
const Rect = grome.matrix.Rect;
|
||||
const DoubleBuffer = grome.draw.DoubleBuffer;
|
||||
const Duration = Io.Duration;
|
||||
const Clock = Io.Clock;
|
||||
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
// This is appropriate for anything that lives as long as the process.
|
||||
@@ -12,34 +14,21 @@ pub fn main(init: std.process.Init) !void {
|
||||
// Initialize the stdout writer
|
||||
var stdout_buffer: [1024]u8 = undefined;
|
||||
var stdout_file_writer: Io.File.Writer = .init(.stdout(), init.io, &stdout_buffer);
|
||||
const stdout_writer = &stdout_file_writer.interface;
|
||||
|
||||
// alright lets play with the matrix
|
||||
const size = Rect{ .height = 20, .width = 50 };
|
||||
var matrix = try DoubleBuffer.init(arena, size);
|
||||
var double_buf = try DoubleBuffer.init(arena, size);
|
||||
|
||||
const density = (width * height) / 100;
|
||||
for (0..density) |_| {
|
||||
var buf: [3]u8 = undefined;
|
||||
init.io.random(&buf);
|
||||
matrix.set(@intCast(buf[0] % width), @intCast(buf[1] % height), @intCast((buf[2] % 50) + 93));
|
||||
const density = size.area() / 100;
|
||||
while (true) {
|
||||
var frame = double_buf.frame(.{ .x = 0, .y = 0 }, size);
|
||||
for (0..density) |_| {
|
||||
var buf: [3]u8 = undefined;
|
||||
init.io.random(&buf);
|
||||
try frame.set(.{ .x = @intCast(buf[0] % size.width), .y = @intCast(buf[1] % size.height) }, .{ .char = [_]u8{@intCast((buf[2] % 50) + 93)} ** 8, .width = 1 });
|
||||
}
|
||||
|
||||
_ = try double_buf.render(&stdout_file_writer.interface);
|
||||
try init.io.sleep(Duration.fromMilliseconds(100), Clock.real);
|
||||
}
|
||||
|
||||
_ = try stdout_writer.write(" ┌─");
|
||||
for (0..width) |_| {
|
||||
_ = try stdout_writer.write("─");
|
||||
}
|
||||
_ = try stdout_writer.write("─┐ \n");
|
||||
|
||||
while (iter.next()) |row| {
|
||||
_ = try stdout_writer.print(" │ {s} │ \n", .{row});
|
||||
}
|
||||
|
||||
_ = try stdout_writer.write(" └─");
|
||||
for (0..width) |_| {
|
||||
_ = try stdout_writer.write("─");
|
||||
}
|
||||
_ = try stdout_writer.write("─┘ \n");
|
||||
|
||||
try stdout_writer.flush();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user