From 0faf401f67f0ed85acca83fbdd93db2f1985ec73 Mon Sep 17 00:00:00 2001 From: odweta Date: Mon, 5 Oct 2026 00:56:53 +0200 Subject: [PATCH] add put_rect for direct rectangle rendering --- include/engine.h | 17 +++++++++++++++++ src/engine/render.c | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/engine.h b/include/engine.h index e56626e..efe2808 100644 --- a/include/engine.h +++ b/include/engine.h @@ -72,7 +72,24 @@ put_pixel( uint32_t color ); +void +put_rect( + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint32_t color +); + void clear_framebuffer( uint32_t color +); + +void +put_char( + char c, + uint32_t x, + uint32_t y, + uint8_t size ); \ No newline at end of file diff --git a/src/engine/render.c b/src/engine/render.c index 3f07353..221bbe6 100644 --- a/src/engine/render.c +++ b/src/engine/render.c @@ -22,6 +22,25 @@ put_pixel( } } +/** + * draws a rectangle with its left-top corner at (x,y) with + * a width of 'w' and height of 'h' filled with color 'color' + */ +void +put_rect( + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint32_t color +) { + for (int i = x; i < x + w; i++) { + for (int j = y; j < y + h; j++) { + put_pixel(i, j, color); + } + } +} + // fill the entire framebuffer with a given color void clear_framebuffer(