Rect::ClampPoint

Rect::ClampPoint
inline Point<T> ClampPoint(const Point<T> & pt) const;
Description

ClampPoint clamps a point to the rectangle and returns a new point inside the rectangle. The x component of the point (pt.x) is first compared to the x1 component of the Rectangle. If x1 >= pt.x, x1 becomes the new x component. Otherwise, pt.x is compared to x2. If x2 <= pt.x, x2 becomes the new x component. If neither of these cases is true, then the new x component is set to pt.x. 

Likewise, to determine the y component, pt.y is first compared to y1. If y1 is >= pt.y, the y is set to y1. Otherwise, if y2<= pt.y, the y is set to y2. If neither of these cases match, the y is set to pt.y.

Parameters
Parameters 
Description 
const Point<T> & pt 
The passed point whose components are compared to those of the current rectangle. 
Return Value

A Point value whose components are determined by clamping a point to the current rectangle. This point will exist inside the rectangle.