CrabUI
Loading...
Searching...
No Matches
CrabUI.CUIAnchor Class Reference

CUIAnchor is just a Vector2
This is a static class containing some helper methods. More...

Static Public Member Functions

static Vector2 Direction (Vector2 anchor)
 
static Vector2 PosIn (CUIComponent host)
 
static Vector2 PosIn (CUIRect rect, Vector2 anchor)
 
static Vector2 AnchorFromPos (CUIRect rect, Vector2 pos)
 
static Vector2 GetChildPos (CUIRect parent, Vector2 anchor, Vector2 offset, Vector2 childSize)
 
static Vector2 GetChildPos (CUIRect parent, Vector2 parentAnchor, Vector2 offset, Vector2 childSize, Vector2 anchor)
 

Static Public Attributes

static Vector2 TopLeft = new Vector2(0.0f, 0.0f)
 
static Vector2 TopCenter = new Vector2(0.5f, 0.0f)
 
static Vector2 TopRight = new Vector2(1.0f, 0.0f)
 
static Vector2 CenterLeft = new Vector2(0.0f, 0.5f)
 
static Vector2 Center = new Vector2(0.5f, 0.5f)
 
static Vector2 CenterRight = new Vector2(1.0f, 0.5f)
 
static Vector2 BottomLeft = new Vector2(0.0f, 1.0f)
 
static Vector2 BottomCenter = new Vector2(0.5f, 1.0f)
 
static Vector2 BottomRight = new Vector2(1.0f, 1.0f)
 

Detailed Description

CUIAnchor is just a Vector2
This is a static class containing some helper methods.

Definition at line 17 of file CUIAnchor.cs.

Member Function Documentation

◆ AnchorFromPos()

static Vector2 CrabUI.CUIAnchor.AnchorFromPos ( CUIRect rect,
Vector2 pos )
static

Definition at line 43 of file CUIAnchor.cs.

44 {
45 return (pos - rect.Position) / rect.Size;
46 }

◆ Direction()

static Vector2 CrabUI.CUIAnchor.Direction ( Vector2 anchor)
static

Definition at line 29 of file CUIAnchor.cs.

30 {
31 return (Center - anchor) * 2;
32 }

◆ GetChildPos() [1/2]

static Vector2 CrabUI.CUIAnchor.GetChildPos ( CUIRect parent,
Vector2 anchor,
Vector2 offset,
Vector2 childSize )
static

Definition at line 48 of file CUIAnchor.cs.

49 {
50 return PosIn(parent, anchor) + offset - PosIn(new CUIRect(childSize), anchor);
51 }

◆ GetChildPos() [2/2]

static Vector2 CrabUI.CUIAnchor.GetChildPos ( CUIRect parent,
Vector2 parentAnchor,
Vector2 offset,
Vector2 childSize,
Vector2 anchor )
static

Definition at line 53 of file CUIAnchor.cs.

54 {
55 return PosIn(parent, parentAnchor) + offset - PosIn(new CUIRect(childSize), anchor);
56 }

◆ PosIn()

static Vector2 CrabUI.CUIAnchor.PosIn ( CUIRect rect,
Vector2 anchor )
static

Definition at line 35 of file CUIAnchor.cs.

36 {
37 return new Vector2(
38 rect.Left + rect.Width * anchor.X,
39 rect.Top + rect.Height * anchor.Y
40 );
41 }

Member Data Documentation

◆ BottomCenter

Vector2 CrabUI.CUIAnchor.BottomCenter = new Vector2(0.5f, 1.0f)
static

Definition at line 26 of file CUIAnchor.cs.

◆ BottomLeft

Vector2 CrabUI.CUIAnchor.BottomLeft = new Vector2(0.0f, 1.0f)
static

Definition at line 25 of file CUIAnchor.cs.

◆ BottomRight

Vector2 CrabUI.CUIAnchor.BottomRight = new Vector2(1.0f, 1.0f)
static

Definition at line 27 of file CUIAnchor.cs.

◆ Center

Vector2 CrabUI.CUIAnchor.Center = new Vector2(0.5f, 0.5f)
static

Definition at line 23 of file CUIAnchor.cs.

◆ CenterLeft

Vector2 CrabUI.CUIAnchor.CenterLeft = new Vector2(0.0f, 0.5f)
static

Definition at line 22 of file CUIAnchor.cs.

◆ CenterRight

Vector2 CrabUI.CUIAnchor.CenterRight = new Vector2(1.0f, 0.5f)
static

Definition at line 24 of file CUIAnchor.cs.

◆ TopCenter

Vector2 CrabUI.CUIAnchor.TopCenter = new Vector2(0.5f, 0.0f)
static

Definition at line 20 of file CUIAnchor.cs.

◆ TopLeft

Vector2 CrabUI.CUIAnchor.TopLeft = new Vector2(0.0f, 0.0f)
static

Definition at line 19 of file CUIAnchor.cs.

◆ TopRight

Vector2 CrabUI.CUIAnchor.TopRight = new Vector2(1.0f, 0.0f)
static

Definition at line 21 of file CUIAnchor.cs.


The documentation for this class was generated from the following file: