Files
dangerzone/src/engine/render/rect.c
T

47 lines
1.0 KiB
C

#include <dangerzone/engine.h>
#include <dangerzone/render/misc.h>
#include <dangerzone/render/rect.h>
#include <stdint.h>
/**
* 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(
framebuffer_e framebuffer,
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(framebuffer, i, j, color);
}
}
mark_dirty_rect(x, y, w, h);
}
// TODO: remove, see rect.h
void
clear_rect(int x, int y, int w, int h, uint32_t color)
{
for (int py = y; py < y + h; ++py) {
for (int px = x; px < x + w; ++px) {
if (px >= 0 &&
px < game_state->width &&
py >= 0 &&
py < game_state->height) {
game_state->framebuffer_base[
py * game_state->width + px
] = color;
}
}
}
mark_dirty_rect(x, y, w, h);
}