From 234298474448571c8bcf021247bb48326eefea25 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Wed, 12 Aug 2020 17:24:15 +0200 Subject: [PATCH] bugfix: inverse all anchors --- geometry.go | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/geometry.go b/geometry.go index 1491d9c..05c4937 100644 --- a/geometry.go +++ b/geometry.go @@ -552,40 +552,31 @@ type Anchor Vec var ( Center = Anchor{0.5, 0.5} - Top = Anchor{0.5, 1} - TopRight = Anchor{1, 1} - Right = Anchor{1, 0.5} - BottomRight = Anchor{1, 0} - Bottom = Anchor{0.5, 0} - BottomLeft = Anchor{0, 0} - Left = Anchor{0, 0.5} - TopLeft = Anchor{0, 1} + Top = Anchor{0.5, 0} + TopRight = Anchor{0, 0} + Right = Anchor{0, 0.5} + BottomRight = Anchor{0, 1} + Bottom = Anchor{0.5, 1} + BottomLeft = Anchor{1, 1} + Left = Anchor{1, 0.5} + TopLeft = Anchor{1, 0} ) +var anchorStrings map[Anchor]string = map[Anchor]string{ + Center: "center", + Top: "top", + TopRight: "top-right", + Right: "right", + BottomRight: "bottom-right", + Bottom: "bottom", + BottomLeft: "bottom-left", + Left: "left", + TopLeft: "top-left", +} + // String returns the string representation of an anchor. func (anchor Anchor) String() string { - switch anchor { - case Center: - return "center" - case Top: - return "top" - case TopRight: - return "top-right" - case Right: - return "right" - case BottomRight: - return "bottom-right" - case Bottom: - return "bottom" - case BottomLeft: - return "bottom-left" - case Left: - return "left" - case TopLeft: - return "top-left" - default: - return "" - } + return anchorStrings[anchor] } // AnchorPos returns the relative position of the given anchor.