rect
__call
Constructor
Creates a new rectangle.
Arguments
1. Default rectangle (0, 0 position; 0, 0 size).
None.
2. Single value.
value
float
Mins XY, maxs XY value.
3. Single vector.
value
Mins vector, maxs vector.
4. Double value.
x
float
Mins/maxs X coordinate.
y
float
Mins/maxs Y coordinate.
5. Double vector.
mins
Mins vector.
maxs
Maxs vector.
6. Four values.
x0
float
Mins X coordinate.
y0
float
Mins Y coordinate.
x1
float
Maxs X coordinate.
y1
float
Maxs Y coordinate.
Returns
rect
New rectangle.
Example
mins
Field
Type: vec2
Mins (top-left) vector.
maxs
Field
Type: vec2
Maxs (bottom-right) vector.
width
Method
Either returns rectangle's width, or sets a new width.
Arguments
1. Get width.
None.
2. Set width.
value
float
New width.
Returns
1. Get width.
float
Width.
2. Set width.
rect
New rectangle with changed width.
Example
height
Method
Either returns rectangle's height, or sets a new height.
Arguments
1. Get height.
None.
2. Set height.
value
float
New height.
Returns
1. Get height.
float
Height.
2. Set height.
rect
New rectangle with changed height.
Example
size
Method
Either returns rectangle's size, or sets a new size.
Arguments
1. Get size.
None.
2. Set size.
value
New size.
Returns
1. Get size.
Size.
2. Set size.
rect
New rectangle with changed size.
Example
explode
Method
Explodes the rectangle by given vector (increase size from center into all directions by coordinates in the vector).
Arguments
value
Explode size.
Returns
rect
Exploded rectangle.
Example
half_width
Method
Returns a rectangle with half of the width of this rectangle.
Arguments
None.
Returns
rect
Rectangle with halved width.
Example
translate
Method
Translates (moves) this rectangle by vector coordinates.
Arguments
value
Translation amount.
Returns
rect
Translated rectangle.
Example
margin_left
Method
Move rectangle from the left by given amount.
Arguments
value
float
Margin amount.
Returns
rect
Moved rectangle.
Example
margin_right
Method
Move rectangle from the right by given amount.
Arguments
value
float
Margin amount.
Returns
rect
Moved rectangle.
Example
margin_top
Method
Move rectangle from the top by given amount.
Arguments
value
float
Margin amount.
Returns
rect
Moved rectangle.
Example
margin_bottom
Method
Move rectangle from the bottom by given amount.
Arguments
value
float
Margin amount.
Returns
rect
Moved rectangle.
Example
padding_left
Method
Adds the value to the left side of the rectangle.
Arguments
value
float
Padding amount.
Returns
rect
Resized rectangle.
Example
padding_right
Method
Adds the value to the right side of the rectangle.
Arguments
value
float
Padding amount.
Returns
rect
Resized rectangle.
Example
padding_top
Method
Adds the value to the top side of the rectangle.
Arguments
value
float
Padding amount.
Returns
rect
Resized rectangle.
Example
padding_bottom
Method
Adds the value to the bottom side of the rectangle.
Arguments
value
float
Padding amount.
Returns
rect
Resized rectangle.
Example
shrink
Method
Shrinks (implodes) the rectangle by given amount.
Arguments
value
float
Shrink value.
Returns
rect
Resized rectangle.
Example
expand
Method
Expands (explodes) the rectangle by given amount.
Arguments
value
float
Expand value.
Returns
rect
Resized rectangle.
Example
contains
Method
Returns true
if this rectangle contains either vector or another rectangle.
Rectangle overload will return true
ONLY of entire other rectangle is within the bounds of this one.
Arguments
1. Vector variant.
other
Vector to check against.
2. Rectangle variant.
other
rect
Rectangle to check against.
Returns
bool
true
if other object is in bounds of this rectangle.
Example
overlaps
Method
Returns true
if the other rectangle overlaps with this rectangle.
Arguments
other
rect
Rectangle to check against.
Returns
bool
true
if other rectangle overlaps with this rectangle.
Example
intersect
Method
Intersects this rectangle with another rectangle.
Arguments
other
rect
Rectangle to intersect with.
Returns
rect
Intersected rectangle.
Example
tl
Method
Returns top-left vector.
Arguments
None.
Returns
Top-left vector.
Example
tr
Method
Returns top-right vector.
Arguments
None.
Returns
Top-right vector.
Example
br
Method
Returns bottom-right vector.
Arguments
None.
Returns
Bottom-right vector.
Example
bl
Method
Returns bottom-left vector.
Arguments
None.
Returns
Bottom-left vector.
Example
center
Method
Returns center point of this rectangle.
Arguments
None.
Returns
Center point.
Example
circle
Method
Treats this rectangle as an ellipsis and returns point on it. Note, that this "ellipsis" will be perfect with no modified curvature (basically if this rectangle is a box - you will get a point on a perfect circle).
Arguments
r
float
Radians value.
Returns
Point on the ellipsis.
Example
floor
Method
Returns floored rectangle.
Arguments
None.
Returns
rect
Floored rectangle.
Example
ceil
Method
Returns ceiled rectangle.
Arguments
None.
Returns
rect
Ceiled rectangle.
Example
round
Method
Returns rounded rectangle.
Arguments
None.
Returns
rect
Rounded rectangle.
Example
is_zero
Method
Returns true
if both mins and maxs are equal to 0.
Arguments
None.
Returns
bool
true
if this is a zero rectangle.
Example
Last updated