diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-06-23 22:02:59 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-06-23 22:02:59 +0300 |
| commit | dc718d39e520da0b9e4c49d45da4f43700f0f895 (patch) | |
| tree | e47a6d8ce9b1472cacf4455d4ff618b73003a1fe | |
| parent | 4d871b697295f892c76b2204ca50ad513d508788 (diff) | |
| download | wafflestone-dc718d39e520da0b9e4c49d45da4f43700f0f895.tar.xz | |
Add a function to draw a vertical line
| -rw-r--r-- | framebuffer.c | 9 | ||||
| -rw-r--r-- | framebuffer.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/framebuffer.c b/framebuffer.c index b4c2f6e..01d169c 100644 --- a/framebuffer.c +++ b/framebuffer.c @@ -1,3 +1,4 @@ +#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <termios.h> @@ -71,6 +72,14 @@ void fb_put(Framebuffer fb, size_t row, size_t col, Pixel pixel) { fb.fb[row][col] = pixel; } +void fb_vert_line(Framebuffer fb, size_t x, size_t y1, size_t y2, Pixel pixel) { + assert(y2 >= y1); + + for (size_t y = y1; y <= y2; y++) { + fb.fb[y][x] = pixel; + } +} + void term_init(void) { tcgetattr(0, &initial_terminal_state); diff --git a/framebuffer.h b/framebuffer.h index 2a26454..8c971c2 100644 --- a/framebuffer.h +++ b/framebuffer.h @@ -62,6 +62,9 @@ void fb_fill(Framebuffer fb, Pixel pixel); /* Puts a pixel onto fb in a specified position */ void fb_put(Framebuffer fb, size_t row, size_t col, Pixel pixel); +/* Draws a vertical line to fb on col x, from y1 to y2 */ +void fb_vert_line(Framebuffer fb, size_t x, size_t y1, size_t y2, Pixel pixel); + /* Initializes the terminal and sets TERM_WIDTH and TERM_HEIGHT */ void term_init(void); |
