update module

This commit is contained in:
2024-10-09 00:55:57 -04:00
parent 1b47194249
commit e29f27266a
3 changed files with 80 additions and 26 deletions

View File

@@ -1,13 +1,13 @@
draw :: (screen: *Screen, x: s64, y: s64, char: PIXEL_TYPE = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
draw :: (screen: *Screen, x: s64, y: s64, char: PIXEL_CHAR = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
using screen;
if x >= 0 && x < width && y >= 0 && y < height {
buffer[y * width + x].type = char;
buffer[y * width + x].char = char;
buffer[y * width + x].color = color;
}
}
draw_line :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, char: PIXEL_TYPE = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
draw_line :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, char: PIXEL_CHAR = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
x, y, dx, dy, dx1, dy1, xe, ye, px, py : s64;
dx = x2 - x1;
@@ -72,7 +72,7 @@ draw_line :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, char: PIXEL_T
}
}
draw_triangle :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, x3: s64, y3: s64, char: PIXEL_TYPE = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
draw_triangle :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, x3: s64, y3: s64, char: PIXEL_CHAR = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
draw_line(x1, y1, x2, y2, char, color);
draw_line(x2, y2, x3, y3, char, color);
draw_line(x3, y3, x1, y1, char, color);
@@ -81,23 +81,26 @@ draw_triangle :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, x3: s64,
clip :: (screen: *Screen, x: *s64, y: *s64) {
using screen;
if x < 0 then x = 0;
if x >= width then x = width;
if y < 0 then y = 0;
if y >= height then y = height;
if x.* < 0 then x.* = 0;
if x.* >= width then x.* = width;
if y.* < 0 then y.* = 0;
if y.* >= height then y.* = height;
}
fill :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, char: PIXEL_TYPE = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
fill :: (screen: *Screen, x1: s64, y1: s64, x2: s64, y2: s64, char: PIXEL_CHAR = .PIXEL_SOLID, color: COLOR = .FG_WHITE) {
clip(screen, *x1, *y1);
clip(screen, *x2, *y2);
for x: x1..x2 {
for y: y1..y2 {
draw(x, y, char, color);
draw(screen, x, y, char, color);
}
}
}
fill_entire_screen :: (screen: *Screen, char: PIXEL_CHAR = .PIXEL_SOLID, color: COLOR = .BG_BLACK) {
fill(screen, 0, 0, screen.width, screen.height, char, color);
}
draw_string :: (screen: *Screen, x: s64, y: s64, text: string, c: COLOR = .FG_WHITE) {
assert(false, "not implemented");