void scaleTo(const ofRectangle &targetRect, ofScaleMode scaleMode=OF_SCALEMODE_FIT)
Scale the rectanle using a target ofRectangle and ofScaleMode.
Adjusts the ofRectangle to match the provided ofRectangle using the provided ofScaleMode.
Assuming the ofRectangle as the Subject and the passed-in 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 an example of the various ofScaleModes, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
- Parameters
-
targetRect | The Target Rectangle to scale to. |
scaleMode | The scale mode to use when scaling. |
void scaleTo(const ofRectangle &targetRect, ofAspectRatioMode subjectAspectRatioMode, ofAlignHorz sharedHorzAnchor=OF_ALIGN_HORZ_CENTER, ofAlignVert sharedVertAnchor=OF_ALIGN_VERT_CENTER)
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 use the alignment anchor parameters to position the rectangle.
This is a convenience 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.
- Parameters
-
targetRect | The Target Rectangle to scale to. |
subjectAspectRatioMode | Aspect ratio scaling mode. |
sharedHorzAnchor | The horizontal alignment method. |
sharedVertAnchor | The vertical alignment method. |
void scaleTo(const ofRectangle &targetRect, ofAspectRatioMode subjectAspectRatioMode, ofAlignHorz modelHorzAnchor, ofAlignVert modelVertAnchor, ofAlignHorz subjectHorzAnchor, ofAlignVert subjectVertAnchor)
Scale the rectangle using a target ofRectangle and parameters.
Adjusts the ofRectangle to match the passed-in 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 passed-in 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 an example of how to use ofAspectRatioMode, ofAlignVert, and ofAlignHorz, see the graphics/rectangleAlignmentAndScaling/ example within the examples directory.
- 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. |