Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Sep 11, 2024
1 parent e39b841 commit b1343a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,25 @@ func (txt *Text) Unaligned() *Text {
return txt
}

// AnchoredBounds returns the text bounds with the anchoring offset applied
func (txt *Text) AnchoredBounds() pixel.Rect {
if !txt.isAnchored {
return txt.bounds
}
return txt.bounds.Moved(txt.AnchoredOffset())
}

// AnchoredDot returns text.Dot with the anchoring offset applied
func (txt *Text) AnchoredDot() pixel.Vec {
if !txt.isAnchored {
return txt.Dot
}
return txt.AnchoredOffset().Add(txt.Dot)
}

// AnchoredOffset calculates the position offset for the text based on it's anchor
//
// Text is anchored relative to the Orig
func (txt *Text) AnchoredOffset() pixel.Vec {
if !txt.isAnchored {
return pixel.ZV
Expand Down

0 comments on commit b1343a5

Please sign in to comment.