VCV Rack API v2
|
2-dimensional rectangle for graphics. More...
#include <math.hpp>
Public Member Functions | |
Rect () | |
Rect (Vec pos, Vec size) | |
Rect (float posX, float posY, float sizeX, float sizeY) | |
bool | contains (Vec v) const |
Returns whether this Rect contains a point, inclusive on the left/top, exclusive on the right/bottom. | |
bool | contains (Rect r) const |
Returns whether this Rect contains (is a superset of) a Rect. | |
bool | intersects (Rect r) const |
Returns whether this Rect overlaps with another Rect. | |
bool | equals (Rect r) const |
float | getLeft () const |
float | getRight () const |
float | getTop () const |
float | getBottom () const |
float | getWidth () const |
float | getHeight () const |
Vec | getCenter () const |
Returns the center point of the rectangle. | |
Vec | getTopLeft () const |
Vec | getTopRight () const |
Vec | getBottomLeft () const |
Vec | getBottomRight () const |
Rect | clamp (Rect bound) const |
Clamps the edges of the rectangle to fit within a bound. | |
Rect | nudge (Rect bound) const |
Nudges the position to fix inside a bounding box. | |
Rect | expand (Rect b) const |
Returns the bounding box of the union of this and b . | |
Rect | intersect (Rect b) const |
Returns the intersection of this and b . | |
Rect | zeroPos () const |
Returns a Rect with its position set to zero. | |
Rect | grow (Vec delta) const |
Expands each corner. | |
Rect | shrink (Vec delta) const |
Contracts each corner. | |
Vec | interpolate (Vec p) |
Returns pos + size * p | |
bool | isContaining (Vec v) const |
bool | isIntersecting (Rect r) const |
bool | isEqual (Rect r) const |
Static Public Member Functions | |
static Rect | fromMinMax (Vec a, Vec b) |
Constructs a Rect from a top-left and bottom-right vector. | |
static Rect | fromCorners (Vec a, Vec b) |
Constructs a Rect from any two opposite corners. | |
static Rect | inf () |
Returns the infinite Rect. | |
Public Attributes | |
Vec | pos |
Vec | size |
2-dimensional rectangle for graphics.
Mathematically, Rects include points on its left/top edge but not its right/bottom edge. The infinite Rect (equal to the entire plane) is defined using pos=-inf and size=inf.
|
inline |
|
inline |
Constructs a Rect from a top-left and bottom-right vector.
Constructs a Rect from any two opposite corners.
|
inline |
Returns whether this Rect contains a point, inclusive on the left/top, exclusive on the right/bottom.
Correctly handles infinite Rects.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the center point of the rectangle.
Returns a NaN coordinate if pos=-inf and size=inf.
|
inline |
|
inline |
|
inline |
|
inline |
Clamps the edges of the rectangle to fit within a bound.
Nudges the position to fix inside a bounding box.
Returns the bounding box of the union of this
and b
.
|
inline |
|
inline |
|
inline |
Vec rack::math::Rect::pos |
Vec rack::math::Rect::size |