diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-03 14:05:14 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:46 +0100 |
| commit | 642b2e14532f906fe133bf2d05bb132ebb53d9ef (patch) | |
| tree | da45eeb332bc786c998f8b64a69585ff36c031e5 /go/ui/utils.go | |
| parent | 6034149d014e999b17247af75b98913e4e4c68af (diff) | |
| download | muhqs-game-642b2e14532f906fe133bf2d05bb132ebb53d9ef.tar.gz muhqs-game-642b2e14532f906fe133bf2d05bb132ebb53d9ef.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 +} |
