class methods
 ofRectangle()
 ~ofRectangle()
 alignTo()
 alignToHorz()
 alignToVert()
 getArea()
 getAspectRatio()
 getBottom()
 getBottomLeft()
 getBottomRight()
 getCenter()
 getHeight()
 getHorzAnchor()
 getIntersection()
 getLeft()
 getMax()
 getMaxX()
 getMaxY()
 getMin()
 getMinX()
 getMinY()
 getPerimeter()
 getPosition()
 getRight()
 getStandardized()
 getTop()
 getTopLeft()
 getTopRight()
 getUnion()
 getVertAnchor()
 getWidth()
 getX()
 getY()
 growToInclude()
 inside()
 intersects()
 isEmpty()
 isStandardized()
 isZero()
 map()
 mapClamp()
 operator!=()
 operator+()
 operator()
 operator==()
 scale()
 scaleFromCenter()
 scaleHeight()
 scaleTo()
 scaleWidth()
 set()
 setFromCenter()
 setHeight()
 setPosition()
 setSize()
 setWidth()
 setX()
 setY()
 standardize()
 translate()
 translateX()
 translateY()
variables
Description
ofRectangle is a simple container for describing the position and size of a 2D rectangle. The ofRectangle class provides a data structure and a collection of useful helper methods for manipulating rectangles.
Since the width
and height
variables can be negative, the x/yposition is not guaranteed to represent the upper right hand corner. For example, two visually identical rectangles can be represented in the following ways:
ofRectangle myRect(0, 0, 100, 100);
or
ofRectangle myRect(100, 100, 100, 100);
While both representations will yield the same visual results in all openFrameworks renderers, the results of some method operations that modify x, y, width and height (such as scaling) produce mathematically correct, but visually different results for each of the above representations.
To avoid this ambiguity, users should prefer "standardized" rectangles. "Standardized" rectangles are rectangles whose width >= 0 and height >= 0. The ofRectangle::standardize() method can be used to ensure that the origin is in the "standard" form.
Documentation from code comments
A class representing a 2D rectangle.
ofRectangle is a simple container for describing the position and size of a 2D rectangle. The ofRectangle::standardize() method can be used to ensure that the origin is in the "standard" form.
Warning: While ofRectangle takes glm::vec3 all ofRectangle operations are 2D only, ignoring the zcomponent.
ofRectangle()
ofRectangle::ofRectangle()
Documentation from code comments
Construct a rectangle with zero width and zero height at 0, 0.
ofRectangle(...)
ofRectangle::ofRectangle(const glm::vec3 &p, float w, float h)
Documentation from code comments
Construct a rectangle from a point and dimensions.
To produce consistent results, users are encouraged to initialize rectangles in the standardized form with width >=0 and height >= 0.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
p The glm::vec3 representing the position of the rectangle.
w The width of the rectangle.
h The height of the rectangle.
ofRectangle(...)
ofRectangle::ofRectangle(const glm::vec3 &p0, const glm::vec3 &p1)
ofRectangle(...)
ofRectangle::ofRectangle(const ofRectangle &rect)
Documentation from code comments
Construct a rectangle by copying another rectangle.
Parameters:
rect The rectangle to copy.
ofRectangle(...)
ofRectangle::ofRectangle(float px, float py, float w, float h)
Documentation from code comments
Construct a rectangle using position and size.
To produce consistent results, users are encouraged to initialize rectangles in the standardized form with width >=0 and height >= 0.
Parameters:
px The xposition of the rectangle.
py The yposition of the rectangle.
w The width of the rectangle.
h The height of the rectangle.
alignTo(...)
void ofRectangle::alignTo(const glm::vec2 &targetPoint, ofAlignHorz thisHorzAnchor=OF_ALIGN_HORZ_CENTER, ofAlignVert thisVertAnchor=OF_ALIGN_VERT_CENTER)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
For a working example of how to use ofAlignVert and ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
alignTo(...)
void ofRectangle::alignTo(const glm::vec3 &targetPoint, ofAlignHorz thisHorzAnchor=OF_ALIGN_HORZ_CENTER, ofAlignVert thisVertAnchor=OF_ALIGN_VERT_CENTER)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
For a working example of how to use ofAlignVert and ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Align this ofRectangle to an glm::vec3 in both x and y dimentions.
Aligns the position of the ofRectangle to the given point using an ofAlignHorz constant and an ofAlignVert constant. If neither constant is passed in, this will align the center of the rectangle.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
targetPoint The target glm::vec3 to align to.
thisHorzAnchor The horizontal alignment anchor.
thisVertAnchor The vertical alignment anchor.
alignTo(...)
void ofRectangle::alignTo(const ofRectangle &targetRect, ofAlignHorz sharedHorzAnchor=OF_ALIGN_HORZ_CENTER, ofAlignVert sharedVertAnchor=OF_ALIGN_VERT_CENTER)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
Documentation from code comments
Align this ofRectangle to an glm::vec3 in both x and y dimentions using a shared anchor.
Aligns the position of the ofRectangle to that of the passedin ofRectangle. Can take an ofAlignHorz constant and an ofAlignVert constant.
If neither constant is passed in, this will align the centers of the rectangles.
If constants are passed in, it will use those constants for both rectangles.
Parameters:
targetRect The target ofRectangle to align this rectangle to.
sharedHorzAnchor The alignment anchor for both rectangles.
sharedVertAnchor The alignment anchor for both rectangles.
alignTo(...)
void ofRectangle::alignTo(const ofRectangle &targetRect, ofAlignHorz targetHorzAnchor, ofAlignVert targetVertAnchor, ofAlignHorz thisHorzAnchor, ofAlignVert thisVertAnchor)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
Documentation from code comments
Vertically align this ofRectangle to another target ofRectangle.
Aligns the position of the ofRectangle to that of the passedin ofRectangle. Takes two ofAlignHorz constants and two ofAlignVert constants.
Will align the chosen anchors in the ofRectangle with the chosen anchors in the passedin ofRectangle.
Parameters:
targetRect The target ofRectangle to align this rectangle to.
targetHorzAnchor The vertical alignment anchor for the target rectangle.
targetVertAnchor The horizontal alignment anchor for the target rectangle.
thisHorzAnchor The horizontal alignment anchor for this rectangle.
thisVertAnchor The vertical alignment anchor for this rectangle.
alignToHorz(...)
void ofRectangle::alignToHorz(const float &targetX, ofAlignHorz thisHorzAnchor=OF_ALIGN_HORZ_CENTER)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
For a working example of how to use ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Horizontally align a rectangle using a position and anchor edge.
Aligns the horizontal position of the ofRectangle to the given x position using an ofAlignHorz constant as anchor. If a constant is not passed in this will align the center of the rectangle.
Parameters:
targetX The xposition to align this rectangle to.
thisHorzAnchor The edge of this rectangle to align.
alignToHorz(...)
void ofRectangle::alignToHorz(const ofRectangle &targetRect, ofAlignHorz sharedAnchor=OF_ALIGN_HORZ_CENTER)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
For a working example of how to use ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Horizontally align two rectangles to another using one anchor for both.
Aligns the horizontal position of the ofRectangle to that of the passedin ofRectangle using an ofAlignHorz constant as anchor.
If a constant is not passed in, this will align the horizontal centers of the rectangles.
If a constant is passed in, it will use that constant for both rectangles.
Parameters:
targetRect The target rectangle to align this rectangle to.
sharedAnchor The common edge of the rectangles to align.
alignToHorz(...)
void ofRectangle::alignToHorz(const ofRectangle &targetRect, ofAlignHorz targetHorzAnchor, ofAlignHorz thisHorzAnchor)
ofAlignHorz Constants:

OF_ALIGN_HORZ_IGNORE
: Does not perform any horizontal alignment. 
OF_ALIGN_HORZ_LEFT
: Uses the left edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_RIGHT
: Uses the right edge of the rectangle to horizontally anchor the alignment. 
OF_ALIGN_HORZ_CENTER
: Uses the center of the rectangle to horizontally anchor the alignment.
For a working example of how to use ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Horizontally align two rectangles to another using two anchors.
Aligns the horizontal position of the ofRectangle to that of the passedin ofRectangle. Takes two ofAlignHorz constants as anchors.
Will align the chosen anchor in the ofRectangle with the chosen anchor in the passedin ofRectangle.
Parameters:
targetRect The target rectangle to align this rectangle to.
targetHorzAnchor The edge of the other rectangle to align.
thisHorzAnchor The edge of this rectangle to align.
alignToVert(...)
void ofRectangle::alignToVert(const float &targetY, ofAlignVert sharedAnchor=OF_ALIGN_VERT_CENTER)
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
For a working example of how to use ofAlignVert, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory
Documentation from code comments
Vertically align a rectangle using a position and anchor edge.
Aligns the vertical position of the ofRectangle to the given y position using an ofAlignVert constant as anchor. If a constant is not passed in this will align the center of the rectangle.
Parameters:
targetY The target yposition to align this rectangle to.
sharedAnchor The alignment position of this ofRectangle to use.
alignToVert(...)
void ofRectangle::alignToVert(const ofRectangle &targetRect, ofAlignVert sharedAnchor=OF_ALIGN_VERT_CENTER)
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
For a working example of how to use ofAlignVert, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory
Documentation from code comments
Vertically align two rectangles to another using one anchor for both.
Aligns the vertical position of the ofRectangle to that of the passedin ofRectangle using an ofAlignVert constant as anchor.
If a constant is not passed in, this will align the vertical centers of the rectangles.
If a constant is passed in, it will use that constant for both rectangles.
Parameters:
targetRect The target ofRectangle to align this rectangle to.
sharedAnchor The alignment position for both rectangles to use.
alignToVert(...)
void ofRectangle::alignToVert(const ofRectangle &targetRect, ofAlignVert targetVertAnchor, ofAlignVert thisVertAnchor)
ofAlignVert Constants:

OF_ALIGN_VERT_IGNORE
: Does not perform any vertical alignment. 
OF_ALIGN_VERT_TOP
: Uses the upper edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_BOTTOM
: Uses the bottom edge of the rectangle to vertically anchor the alignment. 
OF_ALIGN_VERT_CENTER
: Uses the center of the rectangle to vertically anchor the alignment.
For a working example of how to use ofAlignVert, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory
Documentation from code comments
Vertically align two rectangles to another using two anchors.
Will align the chosen anchor in the ofRectangle with the chosen anchor in the passedin ofRectangle.
Parameters:
targetRect The target ofRectangle to align this rectangle to.
targetVertAnchor The alignment anchor for this rectangle.
thisVertAnchor The alignment anchor for the other rectangle.
getArea()
float ofRectangle::getArea()
Example:
// Create a rectangle that is 100 units wide and 200 units tall
ofRectangle myRect(0,0,100,200);
// Get the area of that rectangle
float areaValue = myRect.getArea();
// areaValue will be 20000.0.
Documentation from code comments
Get the area of the ofRectangle.
This is the product of the width and height of the recatngle.
Returns: The area of the rectangle as float.
getAspectRatio()
float ofRectangle::getAspectRatio()
Example:
// Create a rectangle that is 100 units wide and 200 units tall
ofRectangle myRect(0,0,100,200);
// Get the aspect ratio of that rectangle
float aspectRatioValue = myRect.getAspectRatio();
// aspectRatioValue will be 0.5.
Documentation from code comments
Gets the ratio of width to height of the ofRectangle.
Returns: The aspect ratio of the rectangle.
getBottom()
float ofRectangle::getBottom()
Equivalent to ofRectangle::getMaxY().
Documentation from code comments
Gets the y position of the bottom edge of the ofRectangle as float.
See also: getMaxY()
Returns: The y position of the bottom edge of the rectangle.
getBottomLeft()
glm::vec3 ofRectangle::getBottomLeft()
Documentation from code comments
Get the bottomleft coordinates of the ofRectangle as glm::vec3.
Returns: The bottomleft coordinates of the rectangle.
getBottomRight()
glm::vec3 ofRectangle::getBottomRight()
Equivalent to ofRectangle::getMax().
Documentation from code comments
Get the bottomright coordinates of the ofRectangle as glm::vec3.
See also: getMax()
Returns: The bottomright coordinates of the rectangle.
getCenter()
glm::vec3 ofRectangle::getCenter()
Documentation from code comments
Get the coordiantes of the ofRectangle's center as glm::vec3.
Warning: The z component of the returned glm::vec3 will always be 0.
Returns: The x and y coordinates of the center of the rectangle (z = 0).
getHeight()
float ofRectangle::getHeight()
Documentation from code comments
Gets the height of the ofRectangle as float.
Returns: The height of the rectangle.
getHorzAnchor(...)
float ofRectangle::getHorzAnchor(ofAlignHorz anchor)
Possible anchor values are:

OF_ALIGN_HORZ_IGNORE
: returns 0.0 
OF_ALIGN_HORZ_LEFT
: returns the position of the left edge, equivalent to ofRectangle::geLeft(). 
OF_ALIGN_HORZ_RIGHT
: returns the position of the right edge, equivalent to ofRectangle::getRight(). 
OF_ALIGN_HORZ_CENTER
: returns the xposition of the center of the ofRectangle.
Any other anchor value will return 0.0
.
Documentation from code comments
A convenience method that returns the value of one of
the horizontal edges of the ofRectangle using the ofAlignHorz
enum.
Parameters:
anchor The anchor position to query.
Returns: the value of the referenced anchor position.
getIntersection(...)
ofRectangle ofRectangle::getIntersection(const ofRectangle &rect)
Documentation from code comments
Get the intersecting area between this rectangle and another.
This method will attempt to return the area of overlap between this rectangle and the passed rectangle.
If the two rectangles do not overlap, it will return an "empty" rectangle located (0, 0) with 0 width and 0 height.
If the two rectangles only share an edge this will return a rectangle positioned on that edge:
If the shared edge is vertical, the rectangle will have zero width, otherwise it will have zero height.
Parameters:
rect The rectangle to intersect.
Returns: A new ofRectangle representing the intersecting area or an empty rectangle (0, 0, 0, 0) if there is no intersection.
getLeft()
float ofRectangle::getLeft()
Equivalent to ofRectangle::getMinX().
Documentation from code comments
Gets the x position of the left edge of the ofRectangle as float.
See also: getMinX()
Returns: The x position of the left edge of the rectangle.
getMax()
glm::vec3 ofRectangle::getMax()
Returns the (x,y) coordinates of the corner of the rectangle with the largest x and largest y position as an ofPoint.
Equivalent to ofRectangle::getBottomRight().
Documentation from code comments
Get the maximum x and y coordinates of the ofRectangle as glm::vec3.
Returns: The maximum x and y coordinates of the rectangle.
getMaxX()
float ofRectangle::getMaxX()
Returns the position of the larger of the two sides of the rectangle perpendicular to the x axis as a float.
Equivalent to ofRectangle::getRight().
Documentation from code comments
Get the largest x position of the ofRectangle as float.
Returns: The largest x position of the rectangle.
getMaxY()
float ofRectangle::getMaxY()
Equivalent to ofRectangle::getBottom().
Documentation from code comments
Get the largest y position of the ofRectangle as float.
Returns: The largest y position of the rectangle.
getMin()
glm::vec3 ofRectangle::getMin()
Equivalent to ofRectangle::getTopLeft().
Documentation from code comments
Get the minimum x and y coordinates of the ofRectangle as glm::vec3.
Returns: The minimum x and y coordinates of the rectangle.
getMinX()
float ofRectangle::getMinX()
Equivalent to ofRectangle::getLeft().
Documentation from code comments
Get the smallest x position of the ofRectangle as float.
Returns: The smallest xposition of the rectangle.
getMinY()
float ofRectangle::getMinY()
Equivalent to ofRectangle::getTop().
Documentation from code comments
Get the smallest y position of the ofRectangle as float.
Returns: The smallest y position of the rectangle.
getPerimeter()
float ofRectangle::getPerimeter()
Example:
// Create a rectangle that is 100 units wide and 200 units tall
ofRectangle myRect(0,0,100,200);
// Get the perimeter of that rectangle
float perimeterValue = myRect.getPerimeter();
// perimeterValue will be 600.0.
Documentation from code comments
Gets the perimeter of the ofRectangle.
This is the sum of the lengths of the sides.
Returns: The perimeter of the rectangle as float.
getPosition()
const glm::vec3 & ofRectangle::getPosition()
Returns the (x,y) position of the ofRectangle as an ofPoint.
Equivalent to ofRectangle::getPositionRef().
Documentation from code comments
Get the ofRectangle's position.
Warning: The z component of the returned glm::vec3 is undefined.
Returns: The rectangle's position.
getRight()
float ofRectangle::getRight()
Equivalent to ofRectangle::getMaxX().
Documentation from code comments
Gets the x position of the right edge of the ofRectangle as float.
See also: getMaxX()
Returns: The y position of the right edge of the rectangle.
getStandardized()
ofRectangle ofRectangle::getStandardized()
Documentation from code comments
Get the standardized representation of this rectangle.
"Standardized" rectangles are rectangles whose width and height are positive. For more information about standardized rectangles, see the discussion of the standardize() method.
Returns: the Standardized version of this ofRectangle.
getTop()
float ofRectangle::getTop()
Equivalent to ofRectangle::getMinY().
Documentation from code comments
Gets the y position of the top edge of the ofRectangle as float.
See also: getMinY()
Returns: The y position of the top edge of the rectangle.
getTopLeft()
glm::vec3 ofRectangle::getTopLeft()
Equivalent to ofRectangle::getMin().
Documentation from code comments
Get the topleft coordinates of the ofRectangle as glm::vec3.
See also: getMin()
Returns: The topleft coordinates of the rectangle.
getTopRight()
glm::vec3 ofRectangle::getTopRight()
Documentation from code comments
Get the topright coordinates of the ofRectangle as glm::vec3.
Returns: The topright coordinates of the rectangle.
getUnion(...)
ofRectangle ofRectangle::getUnion(const ofRectangle &rect)
Return a new ofRectangle whose area contains both the area of the ofRectangle and that of the passed ofRectangle.
Documentation from code comments
Get the union area between this rectangle and anohter.
See also: getIntersection(const ofRectangle& rect) const
Parameters:
rect The rectangle to unite with.
Returns: A new ofRectangle whose area contains both the area of the this rectangle and the passed rectangle..
getVertAnchor(...)
float ofRectangle::getVertAnchor(ofAlignVert anchor)
Possible anchor values are:

OF_ALIGN_VERT_IGNORE
: returns 0.0 
OF_ALIGN_VERT_TOP
: returns the position of the upper edge, equivalent to ofRectangle::getTop(). 
OF_ALIGN_VERT_BOTTOM
: returns the position of the bottom edge, equivalent to ofRectangle::getBottom(). 
OF_ALIGN_VERT_CENTER
: returns the yposition of the center of the ofRectangle.
Any other anchor value will return 0.0
.
Documentation from code comments
A convenience method that returns the value of one of the vertical edges of the ofRectangle using the ofAlignVert enum.
Parameters:
anchor The anchor position to query.
Returns: the value of the referenced anchor position.
getWidth()
float ofRectangle::getWidth()
Documentation from code comments
Gets the width of the ofRectangle as float.
Returns: The width of the rectangle.
getX()
float ofRectangle::getX()
Documentation from code comments
Gets the x position of the ofRectangle as float.
Returns: The x position of the rectangle.
getY()
float ofRectangle::getY()
Documentation from code comments
Gets the y position of the ofRectangle as float.
Returns: the y position of the rectangle.
growToInclude(...)
void ofRectangle::growToInclude(const glm::vec2 &p0, const glm::vec2 &p1)
Modify the ofRectangle so that both the ofPoints given are enclosed within the rectangle.
growToInclude(...)
void ofRectangle::growToInclude(const glm::vec3 &p)
Documentation from code comments
Grow the ofRectangle to include the given point.
This will potentially change the width, height, xposition, and y position of the ofRectangle. If the point is already within the rectangle, this rectangle will remain unchanged.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
p The position to include.
growToInclude(...)
void ofRectangle::growToInclude(const glm::vec3 &p0, const glm::vec3 &p1)
Modify the ofRectangle so that both the ofPoints given are enclosed within the rectangle.
Documentation from code comments
Grow the ofRectangle to include the given line segment.
This will potentially change the width, height, xposition, and yposition of the ofRectangle. If the points are already within the rectangle, this rectangle will remain unchanged.
Warning: The zcomponents of the passed glm::vec3s are ignored.
Parameters:
p0 The first point to include.
p1 The second point to include.
growToInclude(...)
void ofRectangle::growToInclude(const ofRectangle &rect)
Expands the ofRectangle so that the ofRectangle passed into the method is entirely enclosed by the current ofRectangle.
Documentation from code comments
Grow the ofRectangle to include the given ofRectangle.
This will potentially change the width, height, xposition, and y position of the ofRectangle. If the rectangle is already within the rectangle, this rectangle will remain unchanged.
Parameters:
rect The rectangle to include.
growToInclude(...)
void ofRectangle::growToInclude(float px, float py)
Documentation from code comments
Grow the ofRectangle to include the given (x, y) coordinates.
This will potentially change the width, height, xposition, and y position of the ofRectangle. If the points are already within the rectangle, this rectangle will remain unchanged.
Parameters:
px The xcoordinate to include.
py The ycoordiante to include.
inside(...)
bool ofRectangle::inside(const glm::vec2 &p)
Coordinates (x, y) are considered inside the rectangle if:
x > rectMinX && x < rectMinX && y > rectMinY && y < rectMaxY
inside(...)
bool ofRectangle::inside(const glm::vec2 &p0, const glm::vec2 &p1)
This can be used to test if a line segment is inside the rectangle.
inside(...)
bool ofRectangle::inside(const glm::vec3 &p)
Coordinates (x, y) are considered inside the rectangle if:
x > rectMinX && x < rectMinX && y > rectMinY && y < rectMaxY
Documentation from code comments
Determines if the glm::vec3 is within the ofRectangle.
Note that points on the edge of the ofRectangle are not considered within the rectangle and will return false.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
p The point to test.
Returns: true if the point p is inside this ofRectangle.
inside(...)
bool ofRectangle::inside(const glm::vec3 &p0, const glm::vec3 &p1)
This can be used to test if a line segment is inside the rectangle.
Documentation from code comments
Determines if both of the passed glm::vec3s are within the ofRectangle or not.
Note that points on the edge of the ofRectangle are not considered within the rectangle and will return false.
Warning: The zcomponents of the passed glm::vec3s are ignored.
Parameters:
p0 The first point to test.
p1 The second point to test.
Returns: true if both points are inside the rectangle.
inside(...)
bool ofRectangle::inside(const ofRectangle &rect)
Documentation from code comments
Determines if another ofRectangle is completely within the ofRectangle.
Note that rectangles that share an edge with the ofRectangle are not considered within the rectangle and will return false.
Parameters:
rect The ofRectangle to test.
Returns: true if all four corners of the rect are within this rectangle.
inside(...)
bool ofRectangle::inside(float px, float py)
Coordinates (x, y) are considered inside the rectangle if:
x > rectMinX && x < rectMinX && y > rectMinY && y < rectMaxY
Documentation from code comments
Determines if the coordinates (x, y) are within the ofRectangle.
Note that coordinates on the edge of the ofRectangle are not considered within the rectangle and will return false.
Parameters:
px The xcoordinate to test.
py The ycoordinate to test.
Returns: true if px and py are inside this ofRectangle.
intersects(...)
bool ofRectangle::intersects(const glm::vec2 &p0, const glm::vec2 &p1)
This method can be used to check if any part of the line segment intersects with the rectangle.
intersects(...)
bool ofRectangle::intersects(const glm::vec3 &p0, const glm::vec3 &p1)
This method can be used to check if any part of the line segment intersects with the rectangle.
Documentation from code comments
Determines if a line segment intersects with the ofRectangle.
Warning: The zcomponents of the passed glm::vec3s are ignored.
Parameters:
p0 The first point to test.
p1 The second point to test.
Returns: true
if the line segment defined by the two passed glm::vec3s
either crosses the perimeter of the ofRectangle or is completely
contained within.
intersects(...)
bool ofRectangle::intersects(const ofRectangle &rect)
Returns true if the area contained within the ofRectangle overlaps with the area contained within the passed ofRectangle, returns false otherwise.
Rectangles that only share an edge and do not intersect otherwise are not considered to intersect and will return false.
Documentation from code comments
Determines if another rectangle intersects with this rectangle.
Rectangles that only share an edge and do not intersect otherwise are not considered to intersect and will return false.
Parameters:
rect The rectangle to test.
Returns: true
if the area contained within the ofRectangle overlaps
with the area contained within the passed ofRectangle.
isEmpty()
bool ofRectangle::isEmpty()
Documentation from code comments
Determines if the ofRectangle's area is zero.
See also: getArea().
Returns: true if both the width == 0 and height == 0, false if either is nonzero.
isStandardized()
bool ofRectangle::isStandardized()
Documentation from code comments
Returns true if this ofRectangle is standardized.
"Standardized" rectangles are rectangles whose width and height are positive. For more information about standardized rectangles, see the discussion of the standardize() method.
Returns: true if both width >= 0 and height >= 0.
map(...)
glm::vec2 ofRectangle::map(const glm::vec2 &coeff)
Documentation from code comments
Maps a normalized coordinate into this rectangle
Normalized coordinates range from [0,1] inclusive. It is used to define a ratio between the coordinates and a unitary rectangle. This ratio is mapped into this rectangle to scale to real values. If normalized coordinates are out of bounds, output will be scaled accordingly.
Parameters:
coeff Normalized coordinate to map to this rectangle
Returns: The mapped coordinate
map(...)
ofRectangle ofRectangle::map(const ofRectangle &coeff)
Documentation from code comments
Maps a normalized coordinate into this rectangle
Normalized rectangles' position, width and height range from [0,1] inclusive. It is used to define a ratio between the rectangle and a unitary rectangle. This ratio is mapped into this rectangle to scale to real values. If normalized rectangle is out of bounds, output will be scaled accordingly.
Parameters:
coeff Normalized rectangle to map to this rectangle
Returns: The mapped coordinate
mapClamp(...)
glm::vec2 ofRectangle::mapClamp(const glm::vec2 &coeff)
Documentation from code comments
Maps a normalized coordinate into this rectangle, clamping if out of bounds
Normalized coordinates range from [0,1] inclusive. It is used to define a ratio between the coordinates and a unitary rectangle. This ratio is mapped into this rectangle to scale to real values. If normalized coordinates are out of bounds, output will be clamped to this rectangle's position, width and height.
Parameters:
coeff Normalized coordinate to map to this rectangle
Returns: The mapped coordinate, clamped
mapClamp(...)
ofRectangle ofRectangle::mapClamp(const ofRectangle &coeff)
Documentation from code comments
Maps a normalized rectangle to this rectangle, clamping if out of bounds
Normalized rectangles' position, width and height range from [0,1] inclusive. It is used to define a ratio between the rectangle and a unitary rectangle. This ratio is mapped into this rectangle to scale to real values. If normalized rectangle is out of bounds, output will be clamped to this rectangle's position, width and height.
Parameters:
coeff Normalized rectangle to map to this rectangle
Returns: The mapped rectangle
operator!=(...)
bool ofRectangle::operator!=(const ofRectangle &rect)
Documentation from code comments
If the two ofRectangles differ in x, y, width, or height, they are considered unequal.
Parameters:
rect The rectangle to compare.
Returns: True if the rectangles are not equal.
operator+(...)
ofRectangle ofRectangle::operator+(const glm::vec3 &p)
Documentation from code comments
Returns a new ofRectangle where the x and y positions of the rectangle are offset by the (x, y) coordinates of the glm::vec3.
Parameters:
p The point to translate.
Returns: The translated ofRectangle.
operator(...)
ofRectangle ofRectangle::operator(const glm::vec3 &p)
Documentation from code comments
Returns a new ofRectangle where the x and ypositions of the rectangle are offset by the (x, y) coordinates of the glm::vec3.
Parameters:
p The point to translate.
Returns: The translated ofRectangle.
operator==(...)
bool ofRectangle::operator==(const ofRectangle &rect)
Documentation from code comments
If both ofRectangles have the same x, y, width, and height, they are considered equal.
Parameters:
rect The rectangle to compare.
Returns: True if the rectangles are equal.
scale(...)
void ofRectangle::scale(const glm::vec2 &s)
Scales the width and height of the ofRectangle by multiplying the current width and height with the (x,y) coordinates of the passedin ofPoint.
This is equivalent to calling:
ofRectangle myRect(0, 0, 100, 100);
ofPoint myScaler(2, 2);
myRect.scaleWidth(myScaler.x);
myRect.scaleHeight(myScaler.y);
scale(...)
void ofRectangle::scale(const glm::vec3 &s)
Scales the width and height of the ofRectangle by multiplying the current width and height with the (x,y) coordinates of the passedin ofPoint.
This is equivalent to calling:
ofRectangle myRect(0, 0, 100, 100);
ofPoint myScaler(2, 2);
myRect.scaleWidth(myScaler.x);
myRect.scaleHeight(myScaler.y);
Documentation from code comments
Scale the rectangle.
Scaling will scale the width and the height, but will not change the position.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
s The scaling factor.
scale(...)
void ofRectangle::scale(float s)
Uniformly scales the ofRectangle by multiplying both the current width and current height with the passedin float.
This is equivalent to calling:
ofRectangle myRect(0, 0, 100, 100);
float s = 2;
myRect.scaleWidth(s);
myRect.scaleHeight(s);
Documentation from code comments
Scale the rectangle.
Scaling will scale the width and the height, but will not change the position.
Parameters:
s The scaling factor.
scale(...)
void ofRectangle::scale(float sX, float sY)
Scales the width and height of the ofRectangle by multiplying the current width and height with the passedin floats.
This is equivalent to calling:
ofRectangle myRect(0, 0, 100, 100);
float sX = 2;
float sY = 2;
myRect.scaleWidth(sX);
myRect.scaleHeight(sY);
Documentation from code comments
Scale the rectangle.
Scaling will scale the width and the height, but will not change the position.
Parameters:
sX The widthscaling factor.
sY The heightscaling factor.
scaleFromCenter(...)
void ofRectangle::scaleFromCenter(const glm::vec2 &s)
Scales both the width and height the ofRectangle from its center point. The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
This is equivalent to calling:
ofRectangle myRect(0, 0, 100, 100);
ofPoint myScaler(2, 2);
myRect.scaleFromCenter(myScaler.x, myScaler.y);
scaleFromCenter(...)
void ofRectangle::scaleFromCenter(const glm::vec3 &s)
Scales both the width and height the ofRectangle from its center point. The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
This is equivalent to calling:
ofRectangle myRect(0, 0, 100, 100);
ofPoint myScaler(2, 2);
myRect.scaleFromCenter(myScaler.x, myScaler.y);
Documentation from code comments
Scales both the width and height the ofRectangle from its center.
The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
s The scaling factor.
scaleFromCenter(...)
void ofRectangle::scaleFromCenter(float s)
Uniformly scales the ofRectangle from its center point. The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
Documentation from code comments
Scales both the width and height the ofRectangle from its center.
The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
Parameters:
s The scaling factor.
scaleFromCenter(...)
void ofRectangle::scaleFromCenter(float sX, float sY)
Scales both the width and height the ofRectangle from its center point. The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
Documentation from code comments
Scales both the width and height the ofRectangle from its center.
The center point of the rectangle will remain fixed and the width, height, x, and y will be adjusted.
Parameters:
sX the widthscaling factor.
sY the heightscaling factor.
scaleHeight(...)
void ofRectangle::scaleHeight(float sY)
Scales the height of the ofRectangle by multiplying the current height with the passedin float.
Documentation from code comments
Scale the height of the rectangle.
This will scale the height but will not change the position and width.
Parameters:
sY The heightscaling factor.
scaleTo(...)
void ofRectangle::scaleTo(const ofRectangle &targetRect, ofAspectRatioMode subjectAspectRatioMode, ofAlignHorz modelHorzAnchor, ofAlignVert modelVertAnchor, ofAlignHorz subjectHorzAnchor, ofAlignVert subjectVertAnchor)
Adjusts the ofRectangle to match the passedin ofRectangle. It will use the ofAspectRatioMode to scale the ofRectangle, and will use the use the alignment anchor parameters to position the rectangle.
Assuming the ofRectangle as the Subject and the passedin ofRectangle as the Target:
ofAspectRatioMode Options:
OF_ASPECT_RATIO_IGNORE : Sets the Subject rectangle's width and height to match those of the Target. OF_ASPECT_RATIO_KEEP : Resizes the Subject rectangle to completely fit within the Target rectangle. OF_ASPECT_RATIO_KEEP_BY_EXPANDING : Resizes the Subject rectangle to completely enclose the Target rectangle.
ofAlignHorz Options:
OF_ALIGN_HORZ_IGNORE : Does not perform any horizontal alignment. OF_ALIGN_HORZ_LEFT : Uses the left edge of the rectangle to horizontally anchor the alignment. OF_ALIGN_HORZ_RIGHT : Uses the right edge of the rectangle to horizontally anchor the alignment. OF_ALIGN_HORZ_CENTER : Uses the center of the rectangle to horizontally anchor the alignment.
ofAlignVert Options:
OF_ALIGN_VERT_IGNORE : Does not perform any vertical alignment. OF_ALIGN_VERT_TOP : Uses the upper edge of the rectangle to vertically anchor the alignment. OF_ALIGN_VERT_BOTTOM : Uses the bottom edge of the rectangle to vertically anchor the alignment. OF_ALIGN_VERT_CENTER : Uses the center of the rectangle to vertically anchor the alignment.
For a working example of how to use ofAspectRatioMode, ofAlignVert, and ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Scale the rectangle using a target ofRectangle and parameters.
Adjusts the ofRectangle to match the passedin ofRectangle. It will use the ofAspectRatioMode to scale the ofRectangle, and will use the use the alignment anchor parameters to position the rectangle.
Parameters:
targetRect The Target Rectangle to scale to.
subjectAspectRatioMode Aspect ratio scaling mode.
modelHorzAnchor The target horizontal alignment method.
modelVertAnchor The target vertical alignment method.
subjectHorzAnchor The subject horizontal alignment method.
subjectVertAnchor The subject vertical alignment method.
scaleTo(...)
void ofRectangle::scaleTo(const ofRectangle &targetRect, ofAspectRatioMode subjectAspectRatioMode, ofAlignHorz sharedHorzAnchor=OF_ALIGN_HORZ_CENTER, ofAlignVert sharedVertAnchor=OF_ALIGN_VERT_CENTER)
Adjusts the ofRectangle to match the passedin ofRectangle. It will use the ofAspectRatioMode to scale the ofRectangle, and will use the alignment anchor parameters to position the rectangle.
This is a convenient method when both the target and subject rectangles are using the same alignment anchors. For a more complete explanation, see
void scaleTo(const ofRectangle& targetRect,
ofAspectRatioMode subjectAspectRatioMode,
ofAlignHorz modelHorzAnchor,
ofAlignVert modelVertAnchor,
ofAlignHorz subjectHorzAnchor,
ofAlignVert subjectVertAnchor);
For a working example of how to use ofAspectRatioMode, ofAlignVert, and ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Scale the rectangle using a target ofRectangle and parameters.
Scales the ofRectangle to match the target ofRectangle. It will use the ofAspectRatioMode to scale the ofRectangle and will use the alignment anchor parameters to position the rectangle.
Parameters:
targetRect The Target Rectangle to scale to.
subjectAspectRatioMode Aspect ratio scaling mode.
sharedHorzAnchor The horizontal alignment method.
sharedVertAnchor The vertical alignment method.
scaleTo(...)
void ofRectangle::scaleTo(const ofRectangle &targetRect, ofScaleMode scaleMode=OF_SCALEMODE_FIT)
Adjusts the ofRectangle to match the passedin ofRectangle using the passedin ofScaleMode.
Assuming the ofRectangle as the Subject and the passedin ofRectangle as the Target:
OF_SCALEMODE_FIT: This centers the Subject rectangle within the Target rectangle, and resizes the Subject rectangle to completely fit within the Target Rectangle.
 It fits the Subject rectangle inside the target rectangle.
 It preserves Subject's aspect ratio.
 The Subject's final area <= the Target's area.
 The Subject's center == the Target's center.
OF_SCALEMODE_FILL: This centers the Subject rectangle within the Target rectangle, and resizes the Subject rectangle to completely encompass the Target Rectangle.
 It fills the Target rectangle with the Subject rectangle.
 It preserves the Subject's aspect ratio.
 The Subject's Area >= the Target's area.
 The Subject's center == the Target's center.
OF_SCALEMODE_CENTER: This centers the Subject rectangle within the Target rectangle, and does not modify the Subject's scale.
 It preserves the Subject's aspect ratio.
 The Subject's area is unchanged.
 The Subject's center == Target's center.
OF_SCALEMODE_STRETCH_TO_FILL: This simply modifies the Subject rectangle to match the Target rectangle's dimensions.
 It can change the Subject's aspect ratio.
 The Subject's area == the Target's area.
 The Subject's center == the Target's center.
For a working example of the various ofScaleModes, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
Documentation from code comments
Scale the rectanle using a target ofRectangle and ofScaleMode.
Adjusts the ofRectangle to match the provided ofRectangle using the provided ofScaleMode.
Parameters:
targetRect The Target Rectangle to scale to.
scaleMode The scale mode to use when scaling.
scaleWidth(...)
void ofRectangle::scaleWidth(float sX)
Scales the width of the ofRectangle by multiplying the current width with the passedin float.
Documentation from code comments
Scale the width of the rectangle.
This will scale the width but will not change the position or height.
Parameters:
sX The widthscaling factor.
set(...)
void ofRectangle::set(const glm::vec2 &p, float w, float h)
Sets the (x,y) coordinates, width, and height of the ofRectangle.
set(...)
void ofRectangle::set(const glm::vec2 &p0, const glm::vec2 &p1)
Sets the x position, y position, width, and height of the ofRectangle to enclose the line segment defined by the passed ofPoints.
The rectangle will always be in standardized form, regardless of the order of the ofPoints passed in.
set(...)
void ofRectangle::set(const glm::vec3 &p, float w, float h)
Sets the (x,y) coordinates, width, and height of the ofRectangle.
Documentation from code comments
Set the position and size of the rectangle.
To produce consistent results, users are encouraged to initialize rectangles in the standardized form with width >=0 and height >= 0.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
p The new position.
w The new width.
h The new height.
set(...)
void ofRectangle::set(const glm::vec3 &p0, const glm::vec3 &p1)
Sets the x position, y position, width, and height of the ofRectangle to enclose the line segment defined by the passed ofPoints.
The rectangle will always be in standardized form, regardless of the order of the ofPoints passed in.
set(...)
void ofRectangle::set(const ofRectangle &rect)
Sets the x position, y position, width, and height of the ofRectangle to match those of the passed ofRectangle.
Documentation from code comments
Set the position and size by copying them from anohter rectangle.
Parameters:
rect The rectangle to copy.
set(...)
void ofRectangle::set(float px, float py, float w, float h)
Sets the x position, y position, width, and height of the ofRectangle.
Documentation from code comments
Set the position and size of the rectangle.
To produce consistent results, users are encouraged to initialize rectangles in the standardized form with width >=0 and height >= 0.
Parameters:
px The new xposition.
py The new yposition.
w The new width.
h The new height.
setFromCenter(...)
void ofRectangle::setFromCenter(const glm::vec2 &p, float w, float h)
Sets the position, width, and height of the ofRectangle. The (x,y) coordinates passed into the function determine the center point of the ofRectangle.
setFromCenter(...)
void ofRectangle::setFromCenter(const glm::vec3 &p, float w, float h)
Sets the position, width, and height of the ofRectangle. The (x,y) coordinates passed into the function determine the center point of the ofRectangle.
Documentation from code comments
Set position and size of the rectangle from the center.
The center of the rectangle is defined and the width and height grow out around the center.
Parameters:
p The position of the rectangle's center as an glm::vec3.
w The width of the rectangle.
h The height of the rectangle.
setFromCenter(...)
void ofRectangle::setFromCenter(float px, float py, float w, float h)
Sets the position, width, and height of the ofRectangle. The x and y position passed into the function determine the center point of the ofRectangle.
Documentation from code comments
Set position and size of the rectangle from the center.
The center of the rectangle is defined and the width and height grow out around the center.
Parameters:
px The xposition of the rectangle's center.
py The yposition of the rectangle's center.
w The width of the rectangle.
h The height of the rectangle.
setHeight(...)
void ofRectangle::setHeight(float h)
Sets the height of the ofRectangle.
Documentation from code comments
Set the height of the rectangle.
Parameters:
h The new height.
setPosition(...)
void ofRectangle::setPosition(const glm::vec3 &p)
Sets the (x,y) position of the ofRectangle by passing in x and y as an ofPoint.
Documentation from code comments
Set the position of the rectangle.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
p The position as an glm::vec3.
setPosition(...)
void ofRectangle::setPosition(float px, float py)
Sets the (x,y) position of the ofRectangle by passing in x and y as floats.
Documentation from code comments
Set the position of the rectangle.
Parameters:
px The new xposition.
py The new yposition.
setSize(...)
void ofRectangle::setSize(float w, float h)
Documentation from code comments
Set the size of the rectangle.
Parameters:
w The new width.
h The new height.
setWidth(...)
void ofRectangle::setWidth(float w)
Sets the width of the ofRectangle.
Documentation from code comments
Set the width of the rectangle.
Parameters:
w The new width.
setX(...)
void ofRectangle::setX(float px)
Sets the x position of the ofRectangle.
Documentation from code comments
Set the xposition of the rectangle.
Parameters:
px The new xposition.
setY(...)
void ofRectangle::setY(float py)
Sets the y position of the ofRectangle.
Documentation from code comments
Set the yposition of the rectangle.
Parameters:
py The new yposition.
standardize()
void ofRectangle::standardize()
ofRectangle is a simple container for describing the position and size of 2D rectangles. Like many rectangle data structures found in other frameworks and graphics libraries, member width and height variables can take negative values. Additionally, x / y position and width / height are publicly accessible, resulting in great programming freedom. Consequently, two visually identical rectangles can be represented in the following ways:
ofRectangle myRect(0,0,100,100);
// OR
ofRectangle myRect(100,100,100,100);
While both representations will yield the same visual results in all openFrameworks renderers, the results of some method operations that modify x / y / width / height (such as scaling) produce mathematically correct, but visually different results for each of the above representations.
Documentation from code comments
Standardize the rectangle
"Standardized" rectangles are rectangles whose width and height are positive: width >= 0 and height
= 0. This method can be used to ensure that the rectangle is "standardized". If the rectangle is nonstandard, it will modify the x / width and y / height values into their respective standardized versions.
translate(...)
void ofRectangle::translate(const glm::vec2 &dp)
Offsets the position of the ofRectangle in the both the x and y dimensions by passing in an ofPoint.
translate(...)
void ofRectangle::translate(const glm::vec3 &dp)
Offsets the position of the ofRectangle in the both the x and y dimensions by passing in an ofPoint.
Documentation from code comments
Translate the rectangle's position by an x and y amount.
Warning: The zcomponent of the passed glm::vec3 is ignored.
Parameters:
dp The amount to translate as an glm::vec3.
translate(...)
void ofRectangle::translate(float dx, float dy)
Offsets the position of the ofRectangle in the both the x and y dimensions by passing in two floats.
Documentation from code comments
Translate the rectangle's position by an x and y amount.
Parameters:
dx The amount to translate in the x direction.
dy The amount to translate in the y direction.
translateX(...)
void ofRectangle::translateX(float dx)
Offsets the position of the ofRectangle in the x dimension by a given amount.
Documentation from code comments
Translate the xposition of the rectangle.
Parameters:
dx The amount to translate on the xaxis.
translateY(...)
void ofRectangle::translateY(float dy)
Offsets the position of the ofRectangle in the y dimension by a given amount.
Documentation from code comments
Translate the yposition of the rectangle.
Parameters:
dy The amount to translate on the yaxis.
Last updated Thursday, 15 November 2018 09:13:42 UTC  25a012470a92ee466fd1102eac0b3be9a0ecbc7e
Hosting for openFrameworks is generously provided by Rackspace
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue