From ab355d6a52961d264939ccc1738cb5cf8f6db460 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 27 Mar 2021 07:49:13 +0100 Subject: [PATCH] Add drawrect(), a simple helper for drawing rectangles with specified thickness --- src/client/defs.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client/defs.h b/src/client/defs.h index 3d84657c..6378e475 100644 --- a/src/client/defs.h +++ b/src/client/defs.h @@ -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); +}