From 8802f30ff720fcb64d9207c4cb673dc6805390c2 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 3 Feb 2023 14:05:14 +0100 Subject: add text input and properly center text --- go/ui/utils.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 go/ui/utils.go (limited to 'go/ui/utils.go') 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 +} -- cgit v1.2.3