Add drawrect(), a simple helper for drawing rectangles with specified

thickness
This commit is contained in:
Marco Cawthorne 2021-03-27 07:49:13 +01:00
parent 2c7f540787
commit ab355d6a52

View file

@ -111,3 +111,15 @@ __wrap void(vector pos, vector sz, string pic, vector srcpos, vector srcsz, vect
{
return prior([(int)pos[0],(int)pos[1]], sz, pic, srcpos, srcsz, rgb, alpha, drawflag);
};
void drawrect(vector pos, vector sz, float thickness, vector rgb, float al, optional float dfl)
{
/* top */
drawfill(pos, [sz[0], thickness], rgb, al, dfl);
/* bottom */
drawfill(pos + [0, sz[1] - thickness], [sz[0], thickness], rgb, al, dfl);
/* left */
drawfill(pos + [0, thickness], [thickness, sz[1] - (thickness * 2)], rgb, al, dfl);
/* right */
drawfill(pos + [sz[0] - thickness, thickness], [thickness, sz[1] - (thickness * 2)], rgb, al, dfl);
}