aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2022-09-12 13:00:54 +0200
committerkdx <kikoodx@paranoici.org>2022-09-12 13:00:54 +0200
commit4ddfa1468e86b56c1d66b6c1fa4e71c75742e5a3 (patch)
treef1288da9e432ba712df4e5c0a51c88eb273d7ee9
parente4745b1d61157469893646e3893d80f57328ab59 (diff)
downloadlzr-4ddfa1468e86b56c1d66b6c1fa4e71c75742e5a3.tar.gz
draw rectangle & button down macro
-rw-r--r--lzr.c10
-rw-r--r--lzr.h5
2 files changed, 13 insertions, 2 deletions
diff --git a/lzr.c b/lzr.c
index 7a88adf..c69d210 100644
--- a/lzr.c
+++ b/lzr.c
@@ -442,6 +442,16 @@ int LZR_DrawLine(int x0, int y0, int x1, int y1)
return 0;
}
+int LZR_DrawRectangle(bool fill, int x, int y, int w, int h)
+{
+ SDL_Rect rect = {x, y, w, h};
+ if ((fill ? SDL_RenderFillRect : SDL_RenderDrawRect)(renderer, &rect)) {
+ dx_log_error("%s", SDL_GetError());
+ return -1;
+ }
+ return 0;
+}
+
int LZR_DrawCircle(bool fill, int x, int y, int radius)
{
if ((fill ? filledCircleRGBA : circleRGBA)(renderer, x, y, radius,
diff --git a/lzr.h b/lzr.h
index f474f0b..71e0750 100644
--- a/lzr.h
+++ b/lzr.h
@@ -3,7 +3,8 @@
#define LZR_H_
#include <stdbool.h>
-#define LZR_MAX_IMAGES 32
+#define LZR_MAX_IMAGES 32
+#define LZR_BUTTON(btn) LZR_ButtonDown(LZR_BUTTON_##btn)
typedef struct LZR_Config {
unsigned int display_width;
@@ -56,7 +57,7 @@ int LZR_DrawClear(void);
int LZR_DrawPoint(int x, int y);
int LZR_DrawPoints(int *x, int *y, int n);
int LZR_DrawLine(int x0, int y0, int x1, int y1);
-int LZR_DrawRect(bool fill, int x, int y, int w, int h);
+int LZR_DrawRectangle(bool fill, int x, int y, int w, int h);
int LZR_DrawCircle(bool fill, int x, int y, int radius);
int LZR_DrawPolygon(bool fill, int *vx, int *vy, int n);
int LZR_DrawImage(int id, int x, int y);