Rectclass

Represents a rectangle.

objectRect
Namespace
Sandbox
Assembly
Sandbox.System
Declaration
public sealed struct Sandbox.Rect

Constructors2

Showing 2 constructors

Methods22

Showing 22 methods

public Sandbox.Rect AddPoint(Vector2 pos)PUBLIC

Returns this rect expanded to include this point

ParameterTypeDescription
posVector2
Returns:Rect

public Sandbox.Rect Align(Vector2 size, Sandbox.TextFlag align)PUBLIC

Align the smaller rect inside this rect. Default alignment on each axis is Top, Left.

ParameterTypeDescription
sizeVector2
alignTextFlag
Returns:Rect

public Sandbox.Rect Ceiling()PUBLIC

Returns a Rect with position and size rounded up.

Returns:Rect

public Vector2 ClosestPoint(Vector2 point)PUBLIC

Returns the closest point on this rect to another point

ParameterTypeDescription
pointVector2
Returns:Vector2

public Sandbox.Rect Contain(Vector2 size, Sandbox.TextFlag align = 132, bool stretch = False)PUBLIC

Contain a given rectangle (image) within this rectangle (frame), preserving aspect ratio.

ParameterTypeDescription
sizeVector2Size of the rectagle (image) to try to contain within this frame rectangle.
align = 132TextFlagWhere to align the given box within this rectangle.
stretch = FalseboolWhether to stretch the given rectagle (image) should its size be smaller than largest rectagle (image) size possible within this rectangle (frame).
Returns:RectA rectangle with correct position and size to fit within the "parent" rectangle.

public Sandbox.Rect Floor()PUBLIC

Returns a Rect with position and size rounded down.

Returns:Rect

public static Sandbox.Rect FromPoints(Vector2 a, Vector2 b)PUBLICSTATIC

Create a rect between two points. The order of the points doesn't matter.

ParameterTypeDescription
aVector2
bVector2
Returns:Rect

public Sandbox.Rect Round()PUBLIC

Returns a Rect with position and size rounded to closest integer values.

Returns:Rect

public Sandbox.Rect SnapToGrid()PUBLIC

Align to a grid

Returns:Rect

public Vector4 ToVector4()PUBLIC

Returns this rect as a Vector4, where X/Y/Z/W are Left/Top/Right/Bottom respectively.

Returns:Vector4

Properties14

Showing 14 properties

public float Sandbox.Rect.Bottom { get; set; }PUBLICGETSET

Position of rect's bottom edge relative to its parent.

Returns:float

public Vector2 Sandbox.Rect.BottomLeft { get; set; }PUBLICGETSET

Position of the bottom left edge of this rect.

Returns:Vector2

public Vector2 Sandbox.Rect.BottomRight { get; set; }PUBLICGETSET

Position of the bottom right edge of this rect.

Returns:Vector2

public Vector2 Sandbox.Rect.Center { get; set; }PUBLICGETSET

Center of this rect.

Returns:Vector2

public float Sandbox.Rect.Height { get; set; }PUBLICGETSET

Height of the rect.

Returns:float

public float Sandbox.Rect.Left { get; set; }PUBLICGETSET

Position of rect's left edge relative to its parent, can also be interpreted as its position on the X axis.

Returns:float

public float Sandbox.Rect.Right { get; set; }PUBLICGETSET

Position of rect's right edge relative to its parent.

Returns:float

public Vector2 Sandbox.Rect.Size { get; set; }PUBLICGETSET

Size of this rect.

Returns:Vector2

public float Sandbox.Rect.Top { get; set; }PUBLICGETSET

Position of rect's top edge relative to its parent, can also be interpreted as its position on the Y axis.

Returns:float

public Vector2 Sandbox.Rect.TopLeft { get; set; }PUBLICGETSET

Position of the top left edge of this rect.

Returns:Vector2

public Vector2 Sandbox.Rect.TopRight { get; set; }PUBLICGETSET

Position of the top right edge of this rect.

Returns:Vector2

public float Sandbox.Rect.Width { get; set; }PUBLICGETSET

Width of the rect.

Returns:float

public Sandbox.Rect Sandbox.Rect.WithoutPosition { get; set; }PUBLICGETSET

Returns this rect with position set to 0 on both axes.

Returns:Rect

On this page

Constructorspublic Rect(System.Single x, System.Single y, System.Single width, System.Single height)public Rect(Vector2 point, Vector2 size = null)Methodspublic System.Void Add(Sandbox.Rect r)public System.Void Add(Vector2 point)public Sandbox.Rect AddPoint(Vector2 pos)public Sandbox.Rect Align(Vector2 size, Sandbox.TextFlag align)public Sandbox.Rect Ceiling()public Vector2 ClosestPoint(Vector2 point)public Sandbox.Rect Contain(Vector2 size, Sandbox.TextFlag align = 132, System.Boolean stretch = False)public Sandbox.Rect Floor()public static Sandbox.Rect FromPoints(Vector2 a, Vector2 b)public Sandbox.Rect Grow(Sandbox.UI.Margin m)public Sandbox.Rect Grow(System.Single left, System.Single top, System.Single right, System.Single bottom)public Sandbox.Rect Grow(System.Single x, System.Single y)public Sandbox.Rect Grow(System.Single amt)public System.Boolean IsInside(Sandbox.Rect rect, System.Boolean fullyInside = False)public System.Boolean IsInside(Vector2 pos)public Sandbox.Rect Round()public Sandbox.Rect Shrink(Sandbox.UI.Margin m)public Sandbox.Rect Shrink(System.Single left, System.Single top, System.Single right, System.Single bottom)public Sandbox.Rect Shrink(System.Single x, System.Single y)public Sandbox.Rect Shrink(System.Single amt)public Sandbox.Rect SnapToGrid()public Vector4 ToVector4()Propertiespublic System.Single Sandbox.Rect.Bottom { get; set; }public Vector2 Sandbox.Rect.BottomLeft { get; set; }public Vector2 Sandbox.Rect.BottomRight { get; set; }public Vector2 Sandbox.Rect.Center { get; set; }public System.Single Sandbox.Rect.Height { get; set; }public System.Single Sandbox.Rect.Left { get; set; }public Vector2 Sandbox.Rect.Position { get; set; }public System.Single Sandbox.Rect.Right { get; set; }public Vector2 Sandbox.Rect.Size { get; set; }public System.Single Sandbox.Rect.Top { get; set; }public Vector2 Sandbox.Rect.TopLeft { get; set; }public Vector2 Sandbox.Rect.TopRight { get; set; }public System.Single Sandbox.Rect.Width { get; set; }public Sandbox.Rect Sandbox.Rect.WithoutPosition { get; set; }Metadata