From 64b3d7e7645878cf0ae3a128ed1af56067ff6f5b Mon Sep 17 00:00:00 2001 From: Ben Perry Date: Wed, 11 Sep 2024 01:31:32 -0500 Subject: [PATCH] Helper functions to find the anchored position of Dot and Bounds --- ext/text/text.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ext/text/text.go b/ext/text/text.go index f6ef645..bcd0a24 100644 --- a/ext/text/text.go +++ b/ext/text/text.go @@ -205,6 +205,20 @@ func (txt *Text) Unaligned() *Text { return txt } +func (txt *Text) AnchoredBounds() pixel.Rect { + if !txt.isAnchored { + return txt.bounds + } + return txt.bounds.Moved(txt.AnchoredOffset()) +} + +func (txt *Text) AnchoredDot() pixel.Vec { + if !txt.isAnchored { + return txt.Dot + } + return txt.AnchoredOffset().Add(txt.Dot) +} + func (txt *Text) AnchoredOffset() pixel.Vec { if !txt.isAnchored { return pixel.ZV