CrabUI
Loading...
Searching...
No Matches
CrabUI.CUIRect Struct Reference

Rectangle with float. More...

Public Member Functions

CUIRect Shift (Vector2 shift)
 
bool Contains (float x, float y)
 
bool Contains (Vector2 pos)
 
bool Intersect (CUIRect r)
 
Rectangle Zoom (float Z)
 
 CUIRect (Vector2 size)
 
 CUIRect (Vector2 position, Vector2 size)
 
 CUIRect (float x, float y, float w, float h)
 
override string ToString ()
 

Static Public Member Functions

static Rectangle CreateRect (float x, float y, float w, float h)
 IDK where to put it.
 

Public Attributes

float Left
 
float Top
 
float Width
 
float Height
 

Properties

float Right [get]
 
float Bottom [get]
 
Vector2 Size [get]
 
Vector2 Position [get]
 
Vector2 Center [get]
 
Rectangle Box [get]
 
Vector2 LeftTop [get]
 
Vector2 LeftCenter [get]
 
Vector2 LeftBottom [get]
 
Vector2 CenterTop [get]
 
Vector2 CenterCenter [get]
 
Vector2 CenterBottom [get]
 
Vector2 RightTop [get]
 
Vector2 RightCenter [get]
 
Vector2 RightBottom [get]
 

Detailed Description

Rectangle with float.

Definition at line 16 of file CUIRect.cs.

Constructor & Destructor Documentation

◆ CUIRect() [1/3]

CrabUI.CUIRect.CUIRect ( Vector2 size)

Definition at line 85 of file CUIRect.cs.

85: this(0, 0, size.X, size.Y) { }

◆ CUIRect() [2/3]

CrabUI.CUIRect.CUIRect ( Vector2 position,
Vector2 size )

Definition at line 86 of file CUIRect.cs.

86: this(position.X, position.Y, size.X, size.Y) { }

◆ CUIRect() [3/3]

CrabUI.CUIRect.CUIRect ( float x,
float y,
float w,
float h )

Definition at line 87 of file CUIRect.cs.

88 {
89 Left = x;
90 Top = y;
91 Width = Math.Max(0f, w);
92 Height = Math.Max(0f, h);
93 }

Member Function Documentation

◆ Contains() [1/2]

bool CrabUI.CUIRect.Contains ( float x,
float y )

Definition at line 57 of file CUIRect.cs.

58 {
59 return Left < x && x < Right && Top < y && y < Bottom;
60 }

◆ Contains() [2/2]

bool CrabUI.CUIRect.Contains ( Vector2 pos)

Definition at line 61 of file CUIRect.cs.

62 {
63 return Left < pos.X && pos.X < Right && Top < pos.Y && pos.Y < Bottom;
64 }

◆ CreateRect()

static Rectangle CrabUI.CUIRect.CreateRect ( float x,
float y,
float w,
float h )
static

IDK where to put it.

Definition at line 21 of file CUIRect.cs.

22 {
23 return new Rectangle((int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(w), (int)Math.Round(h));
24 }

◆ Intersect()

bool CrabUI.CUIRect.Intersect ( CUIRect r)

Definition at line 65 of file CUIRect.cs.

66 {
67 return r.Right >= Left && r.Left <= Right && r.Bottom >= Top && r.Top <= Bottom;
68 }

◆ Shift()

CUIRect CrabUI.CUIRect.Shift ( Vector2 shift)

Definition at line 52 of file CUIRect.cs.

53 {
54 return new CUIRect(Left + shift.X, Top + shift.Y, Width, Height);
55 }

◆ Zoom()

Rectangle CrabUI.CUIRect.Zoom ( float Z)

Definition at line 70 of file CUIRect.cs.

71 {
72 Vector2 ScreenCenter = CUI.GameScreenSize / 2.0f;
73 Vector2 PosDif = Position - ScreenCenter;
74 Vector2 newPos = PosDif * Z + ScreenCenter;
75
76 return new Rectangle(
77 (int)newPos.X, (int)newPos.Y,
78 (int)(Width / Z), (int)(Height / Z)
79 );
80 }

Member Data Documentation

◆ Height

float CrabUI.CUIRect.Height

Definition at line 30 of file CUIRect.cs.

◆ Left

float CrabUI.CUIRect.Left

Definition at line 27 of file CUIRect.cs.

◆ Top

float CrabUI.CUIRect.Top

Definition at line 28 of file CUIRect.cs.

◆ Width

float CrabUI.CUIRect.Width

Definition at line 29 of file CUIRect.cs.

Property Documentation

◆ Bottom

float CrabUI.CUIRect.Bottom
get

Definition at line 33 of file CUIRect.cs.

◆ Box

Rectangle CrabUI.CUIRect.Box
get

Definition at line 38 of file CUIRect.cs.

◆ Center

Vector2 CrabUI.CUIRect.Center
get

Definition at line 37 of file CUIRect.cs.

◆ CenterBottom

Vector2 CrabUI.CUIRect.CenterBottom
get

Definition at line 45 of file CUIRect.cs.

◆ CenterCenter

Vector2 CrabUI.CUIRect.CenterCenter
get

Definition at line 44 of file CUIRect.cs.

◆ CenterTop

Vector2 CrabUI.CUIRect.CenterTop
get

Definition at line 43 of file CUIRect.cs.

◆ LeftBottom

Vector2 CrabUI.CUIRect.LeftBottom
get

Definition at line 42 of file CUIRect.cs.

◆ LeftCenter

Vector2 CrabUI.CUIRect.LeftCenter
get

Definition at line 41 of file CUIRect.cs.

◆ LeftTop

Vector2 CrabUI.CUIRect.LeftTop
get

Definition at line 40 of file CUIRect.cs.

◆ Position

Vector2 CrabUI.CUIRect.Position
get

Definition at line 36 of file CUIRect.cs.

◆ Right

float CrabUI.CUIRect.Right
get

Definition at line 32 of file CUIRect.cs.

◆ RightBottom

Vector2 CrabUI.CUIRect.RightBottom
get

Definition at line 48 of file CUIRect.cs.

◆ RightCenter

Vector2 CrabUI.CUIRect.RightCenter
get

Definition at line 47 of file CUIRect.cs.

◆ RightTop

Vector2 CrabUI.CUIRect.RightTop
get

Definition at line 46 of file CUIRect.cs.

◆ Size

Vector2 CrabUI.CUIRect.Size
get

Definition at line 35 of file CUIRect.cs.


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