This commit is contained in:
jonathan santis 2024-10-30 14:56:09 +01:00
parent 1634f96817
commit acb8e8163d
2 changed files with 16 additions and 18 deletions

View File

@ -36,13 +36,10 @@ fn draw() !void {
var w = Winsize{};
var i: u64 = 0;
var ii: u64 = 0;
var buf = std.mem.zeroes([2]u8);
var slice: []u8 = undefined;
var bytes_written: u3 = 0;
var buffer_size: u32 = 0;
buf[0] = 0;
w = try getTermDimension();
buffer_size = w.ws_row;
buffer_size = buffer_size * w.ws_col * 4;
@ -51,13 +48,10 @@ fn draw() !void {
defer allocator.free(buffer);
definitions.obj[0].a.x = 10;
print("definitions.obj[0].a.x:{}\n", .{definitions.obj[0].a.x});
print("definitions.obj[0].b.x:{}\n", .{definitions.obj[0].b.x});
print("definitions.obj[9].b.x:{}\n", .{definitions.obj[9].b.x});
_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
wait_for_enter();
// defer std.heap.page_allocator.free(tmp);
//video loop
while (true) {
buffer[0] = 0;
i = 0;
//clear buffer
while (i < buffer.len) : (i += 4) {
@ -82,18 +76,8 @@ fn draw() !void {
// mv_axis_border_bounce(w, &primitive.vec.c, 'x');
// mv_axis_border_bounce(w, &primitive.vec.c, 'y');
// try triangle(buffer, w, primitive.vec2);
// mv_axis_border_bounce(w, &primitive.vec2.a, 'x');
// mv_axis_border_bounce(w, &primitive.vec2.a, 'y');
// mv_axis_border_bounce(w, &primitive.vec2.b, 'x');
// mv_axis_border_bounce(w, &primitive.vec2.b, 'Y');
// mv_axis_border_bounce(w, &primitive.vec2.c, 'x');
// mv_axis_border_bounce(w, &primitive.vec2.c, 'y');
//try triangle(buffer, w, definitions.obj.vec);
try fill_draw(w, buffer);
try out.print("{s}", .{buffer});
//_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
sleep(30000000);
}
}
@ -133,3 +117,8 @@ fn fill_draw(w: Winsize, buffer: []u8) !void {
}
}
}
fn wait_for_enter() void {
_ = stdin.readUntilDelimiterAlloc(std.heap.page_allocator, '\n', 3) catch |err| {
print("string to long{}", .{err});
}; //Memory leak?
}

View File

@ -24,6 +24,15 @@ pub const Triangle = struct {
bufc: *i32,
};
pub const Polygon = struct{
const Node = struct{point:Point,*Node};
head: *Node;
length: u32;
pub fn new() Node {
return Node
pub fn pixel(buffer: []u8, w: Winsize, x: i64, y: i64, symbol: u21) !void {
const i: usize = @intCast(4 * (x + y * w.ws_col));
if (i < buffer.len) { //-1 ??