19 public static Vector2 TopLeft =
new Vector2(0.0f, 0.0f);
20 public static Vector2 TopCenter =
new Vector2(0.5f, 0.0f);
21 public static Vector2 TopRight =
new Vector2(1.0f, 0.0f);
22 public static Vector2 CenterLeft =
new Vector2(0.0f, 0.5f);
23 public static Vector2 Center =
new Vector2(0.5f, 0.5f);
24 public static Vector2 CenterRight =
new Vector2(1.0f, 0.5f);
25 public static Vector2 BottomLeft =
new Vector2(0.0f, 1.0f);
26 public static Vector2 BottomCenter =
new Vector2(0.5f, 1.0f);
27 public static Vector2 BottomRight =
new Vector2(1.0f, 1.0f);
29 public static Vector2 Direction(Vector2 anchor)
31 return (Center - anchor) * 2;
35 public static Vector2 PosIn(
CUIRect rect, Vector2 anchor)
38 rect.Left + rect.Width * anchor.X,
39 rect.Top + rect.Height * anchor.Y
43 public static Vector2 AnchorFromPos(
CUIRect rect, Vector2 pos)
45 return (pos - rect.Position) / rect.Size;
48 public static Vector2 GetChildPos(
CUIRect parent, Vector2 anchor, Vector2 offset, Vector2 childSize)
50 return PosIn(parent, anchor) + offset - PosIn(
new CUIRect(childSize), anchor);
53 public static Vector2 GetChildPos(
CUIRect parent, Vector2 parentAnchor, Vector2 offset, Vector2 childSize, Vector2 anchor)
55 return PosIn(parent, parentAnchor) + offset - PosIn(
new CUIRect(childSize), anchor);