Skip to content

Commit

Permalink
Helper functions to find the anchored position of Dot and Bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Sep 11, 2024
1 parent d8e969d commit 64b3d7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ext/text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 64b3d7e

Please sign in to comment.