diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-03 14:05:14 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:46:38 +0200 |
| commit | 8802f30ff720fcb64d9207c4cb673dc6805390c2 (patch) | |
| tree | 9be529221105fc8681e3afb0e673e229ef9504d4 /go/ui/utils.go | |
| parent | e8f44219976edf8cf57cbd9e964f66fe9d145a9c (diff) | |
| download | muhqs-game-8802f30ff720fcb64d9207c4cb673dc6805390c2.tar.gz muhqs-game-8802f30ff720fcb64d9207c4cb673dc6805390c2.zip | |
add text input and properly center text
Diffstat (limited to 'go/ui/utils.go')
| -rw-r--r-- | go/ui/utils.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/go/ui/utils.go b/go/ui/utils.go new file mode 100644 index 00000000..fd15b642 --- /dev/null +++ b/go/ui/utils.go @@ -0,0 +1,19 @@ +package ui + +import ( + "image" +) + +func centerTextXOffset(b image.Rectangle) int { + return (b.Dx() / 2) - b.Min.X +} + +func centerTextYOffset(b image.Rectangle) int { + return (b.Dy() / 2) + b.Min.Y +} + +func centerText(b image.Rectangle) (x int, y int) { + x = centerTextXOffset(b) + y = centerTextYOffset(b) + return +} |
