aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKikooDX <kikoodx@paranoici.org>2022-03-15 00:15:14 +0100
committerKikooDX <kikoodx@paranoici.org>2022-03-15 00:18:31 +0100
commit139dbb6a013197240597e4633f5c90c6a223f6d1 (patch)
treecc4463347d7f4d412a7011ace98ea2a72643ec83
parentd04324372d4293c9044961eb04140fd5a5cde006 (diff)
downloadlzy-139dbb6a013197240597e4633f5c90c6a223f6d1.tar.gz
center draw with gint
-rw-r--r--inc/lzy.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/inc/lzy.h b/inc/lzy.h
index 66995c7..5b8debf 100644
--- a/inc/lzy.h
+++ b/inc/lzy.h
@@ -185,6 +185,8 @@ int LZY_DrawLine(int x0, int y0, int x1, int y1) {
#include <gint/timer.h>
#include <stdint.h>
+static const int draw_off_x = (DWIDTH - LZY_DISPLAY_WIDTH) / 2;
+static const int draw_off_y = (DHEIGHT - LZY_DISPLAY_HEIGHT) / 2;
static color_t draw_color = C_BLACK;
static int should_quit = 0;
static int timer = 0;
@@ -195,7 +197,6 @@ static unsigned int tset_width, tset_height;
#ifdef LZY_GINT_FONT
static unsigned int font_width, font_height;
#endif
-
static int timer_callback(volatile int *);
int LZY_Init(int argc, const char **argv, const char *title, int target_fps,
@@ -262,13 +263,16 @@ int LZY_DrawClear(void) {
}
int LZY_DrawPoint(int x, int y) {
- dpixel(x, y, draw_color);
+ dpixel(x + draw_off_x, y + draw_off_y, draw_color);
return 0;
}
int LZY_DrawRect(int x, int y, unsigned int w, unsigned int h) {
if (w < 1 || h < 1)
return -1;
+ x += draw_off_x;
+ y += draw_off_y;
+
drect_border(x, y, x + w - 1, y + h - 1, C_NONE, 1, draw_color);
return 0;
}
@@ -276,6 +280,9 @@ int LZY_DrawRect(int x, int y, unsigned int w, unsigned int h) {
int LZY_DrawFillRect(int x, int y, unsigned int w, unsigned int h) {
if (w < 1 || h < 1)
return -1;
+ x += draw_off_x;
+ y += draw_off_y;
+
drect(x, y, x + w - 1, y + h - 1, draw_color);
return 0;
}
@@ -292,6 +299,8 @@ int LZY_DrawTile(unsigned int id, int x, int y) {
if (id >= tset_width * tset_height)
return -1;
+ x += draw_off_x;
+ y += draw_off_y;
ix = id % tset_width * LZY_TILE_SIZE;
iy = id % tset_height * LZY_TILE_SIZE;
@@ -315,6 +324,8 @@ int LZY_DrawChar(unsigned char chr, int x, int y) {
if (id >= font_width * font_height)
return -1;
+ x += draw_off_x;
+ y += draw_off_y;
ix = (id % font_width) * LZY_CHR_WIDTH;
iy = (id / font_width) * LZY_CHR_HEIGHT;