clean up button creation + center text

This commit is contained in:
2026-06-19 02:21:49 -07:00
parent 433ac4152b
commit 1a18c42b9e
2 changed files with 50 additions and 22 deletions
+27
View File
@@ -0,0 +1,27 @@
package game
import rl "vendor:raylib"
draw_text_centered_in_rect :: proc(
text: cstring,
rect: rl.Rectangle,
font_size: i32,
color: rl.Color,
) {
text_w := rl.MeasureText(text, font_size)
x := i32(rect.x) + (i32(rect.width) - text_w) / 2
y := i32(rect.y) + (i32(rect.height) - font_size) / 2
rl.DrawText(text, x, y, font_size, color)
}
draw_button :: proc(
rect: rl.Rectangle,
label: cstring,
bg: rl.Color,
font_size: i32,
text_color: rl.Color,
) {
rl.DrawRectangleRec(rect, bg)
draw_text_centered_in_rect(label, rect, font_size, text_color)
}