implement polygon

a bug in the fill algorythm where it fills every
This commit is contained in:
jonathan santis
2024-11-01 13:21:20 +01:00
parent e91c744c16
commit ece4540426
2 changed files with 24 additions and 2 deletions

View File

@@ -39,6 +39,14 @@ fn draw() !void {
var slice: []u8 = undefined;
var bytes_written: u3 = 0;
var buffer_size: u32 = 0;
var polygon = primitive.LinkedList().new(allocator);
try polygon.add(.{ .x = 5, .y = 5, .z = 0 });
try polygon.add(.{ .x = 67, .y = 13, .z = 0 });
try polygon.add(.{ .x = 77, .y = 33, .z = 0 });
try polygon.add(.{ .x = 48, .y = 21, .z = 0 });
try polygon.add(.{ .x = 21, .y = 39, .z = 0 });
try polygon.add(.{ .x = 24, .y = 23, .z = 0 });
w = try getTermDimension();
buffer_size = w.ws_row;
@@ -62,7 +70,7 @@ fn draw() !void {
slice[bytes_written + ii] = 0;
}
}
try triangle(buffer, w, definitions.vec);
//try triangle(buffer, w, definitions.vec);
//_ = try bresenham(buffer, w, Point{ .x = 10, .y = 10, .z = 0 }, Point{ .x = 30, .y = 12, .z = 0 });
try out.print("\x1B[2J", .{});
@@ -75,9 +83,10 @@ fn draw() !void {
// mv_axis_border_bounce(w, &primitive.vec.b, 'y');
// mv_axis_border_bounce(w, &primitive.vec.c, 'x');
// mv_axis_border_bounce(w, &primitive.vec.c, 'y');
try primitive.polygon_draw(buffer, w, &polygon);
try fill_draw(w, buffer);
try out.print("{s}", .{buffer});
sleep(30000000);
}
}