summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Stensgård <mastensg@mastensg.net>2025-07-06 22:56:08 +0200
committerMartin Stensgård <mastensg@mastensg.net>2025-07-06 22:56:08 +0200
commit2d53279261253ee1ae7015084c46244ecf13afc5 (patch)
tree56dfbdd734b96996690d4ce707fb171ae4eb1ffd
parentd5c102558c9cc14fd6d7e5355c559046ec3f3c08 (diff)
opplysning: draw with go mono
-rw-r--r--opplysning.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/opplysning.c b/opplysning.c
index 56a8f2b..030a559 100644
--- a/opplysning.c
+++ b/opplysning.c
@@ -147,8 +147,8 @@ ray_init(void)
memcpy(codes + 128, the_non_ascii, strlen(the_non_ascii));
int ncp = 0;
int *cp = LoadCodepoints(codes + 1, &ncp);
- R.font_h = LoadFontEx("font/adventpro-bold.ttf", 60, cp, ncp);
- R.font_p = LoadFontEx("font/NHaasGroteskTXPro-55Rg.ttf", 40, cp, ncp);
+ R.font_h = LoadFontEx("font/adventpro-bold.ttf", 48, cp, ncp);
+ R.font_p = LoadFontEx("font/Go-Mono.ttf", 24, cp, ncp);
UnloadCodepoints(cp);
free(codes);
@@ -200,13 +200,20 @@ draw_time(int x, int y)
void
draw_one_event(int x, int y, const struct event *e)
{
+ char s[128] = {0};
+ snprintf(s, sizeof(s), "%02u:%02u-%02u:%02u %s", e->hour, e->minute,
+ e->end_hour, e->end_minute, e->title);
+ line(x, y, R.font_p, R.fg, s);
+}
+
+void
+draw_date(int x, int y, int wday, int day, int month)
+{
char s[64] = {0};
- snprintf(s, sizeof(s), "%02u:%02u - %02u:%02u", e->hour, e->minute,
- e->end_hour, e->end_minute);
- Vector2 m = MeasureTextEx(R.font_p, s, R.font_p.baseSize, 0);
- line(x + 5.8 * R.font_p.baseSize - m.x, y, R.font_p, R.fg, s);
- line(x + 6.5 * R.font_p.baseSize, y, R.font_p, R.fg, e->title);
+ snprintf(s, sizeof(s), "%s %u. %s", ukedag[wday], day, maaned[month]);
+ line(x, y, R.font_h, R.hd, s);
}
+
void
draw_events(int x, int y, size_t numevents,
const struct event events[static numevents])
@@ -219,11 +226,8 @@ draw_events(int x, int y, size_t numevents,
year = e->year;
month = e->month;
day = e->day;
-
- char s[64] = {0};
- snprintf(s, sizeof(s), "%s %u. %s", ukedag[e->wday],
- e->day, maaned[e->month]);
- line(x + 25, y += 50, R.font_h, R.hd, s);
+ y += 40;
+ draw_date(x, y, e->wday, e->day, e->month);
y += 20;
}
y += 40;
@@ -247,8 +251,10 @@ main(void)
BeginDrawing();
ClearBackground(R.bg);
draw_time(SCREEN_W / 2, 0);
- draw_events(0, 0, ne_meetup, ev_meetup);
- draw_events(SCREEN_W / 2, 0, ne_booking, ev_booking);
+ int x = 20;
+ int y = 20;
+ draw_events(x, y, ne_meetup, ev_meetup);
+ draw_events(x + SCREEN_W / 2, y, ne_booking, ev_booking);
EndDrawing();
}
CloseWindow();