38 lines
766 B
C
38 lines
766 B
C
#include <display.h>
|
|
|
|
void drect(display_t *disp, int x, int y, int width, int height)
|
|
{
|
|
if (x < 0)
|
|
{
|
|
width = width + x;
|
|
x = 0;
|
|
} else {
|
|
if (x + width >= (int)disp->display.width)
|
|
width = disp->display.width - x;
|
|
}
|
|
|
|
// Get "real" Y position and area height.
|
|
if (y < 0)
|
|
{
|
|
height = height + y;
|
|
y = 0;
|
|
} else {
|
|
if (y + height >= (int)disp->display.height)
|
|
height = disp->display.height - y;
|
|
}
|
|
|
|
// Check potential error.
|
|
// @note we do not check height because the while()
|
|
// while do the job for us.
|
|
if (width < 0 || height < 0)
|
|
return;
|
|
|
|
// Draw the two horizontal lines
|
|
dhline(disp, x, y, width);
|
|
dhline(disp, x, y + height, width);
|
|
|
|
// Draw th two vertical line
|
|
dvline(disp, x, y, height);
|
|
dvline(disp, x + width, y, height);
|
|
}
|