bugfix: inverse all anchors
@@ -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.
