mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-01-01 06:23:35 +01:00
render: add a drect_border() function
This commit is contained in:
parent
4a3c396284
commit
06345967fd
2 changed files with 37 additions and 0 deletions
|
@ -60,6 +60,12 @@ void dclear(color_t color);
|
|||
fxcg50: Any R5G6B5 color */
|
||||
void drect(int x1, int y1, int x2, int y2, color_t color);
|
||||
|
||||
/* drect_border(): Rectangle with border
|
||||
This function draws a rectangle with an inner border. The border width must
|
||||
be smaller than half the width and half the height. */
|
||||
void drect_border(int x1, int y1, int x2, int y2, int fill_color,
|
||||
int border_width, int border_color);
|
||||
|
||||
//---
|
||||
// Point drawing functions
|
||||
//---
|
||||
|
|
31
src/render/drect_border.c
Normal file
31
src/render/drect_border.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <gint/defs/util.h>
|
||||
#include <gint/display.h>
|
||||
|
||||
/* drect_border(): Rectangle with border */
|
||||
void drect_border(int x1, int y1, int x2, int y2, int fill, int width,
|
||||
int border)
|
||||
{
|
||||
if(x1 > x2) swap(x1, x2);
|
||||
if(y1 > y2) swap(y1, y2);
|
||||
|
||||
/* Order and bounds */
|
||||
if(x1 >= 396 || x2 < 0 || y1 >= 224 || y2 < 0) return;
|
||||
if(x1 < 0) x1 = 0;
|
||||
if(x2 >= 396) x2 = 395;
|
||||
if(y1 < 0) y1 = 0;
|
||||
if(y2 >= 224) y2 = 223;
|
||||
|
||||
drect(x1, y1, x2, y1 + (width-1), border);
|
||||
drect(x1, y2 - (width-1), x2, y2, border);
|
||||
|
||||
y1 += width;
|
||||
y2 -= width;
|
||||
|
||||
drect(x1, y1, x1 + (width-1), y2, border);
|
||||
drect(x2 - (width-1), y1, x2, y2, border);
|
||||
|
||||
x1 += width;
|
||||
x2 -= width;
|
||||
|
||||
if(fill != C_NONE) drect(x1, y1, x2, y2, fill);
|
||||
}
|
Loading…
Reference in a new issue