Example #1
0
 /// <summary>
 /// If the point is outside the rectangle specified by the two arguments,
 /// it will be moved horizontally and/or vertically until it falls 
 /// inside the rectangle.
 /// </summary>
 /// <param name="topLeft">Minimum values acceptable for X and Y</param>
 /// <param name="bottomRight">Maximum values acceptable for X and Y</param>
 ///
 public void constrainTo(Point topLeft, Point bottomRight)
 {
     if (x < topLeft.x)
     x = topLeft.x;
       if (y < topLeft.y)
     y = topLeft.y;
       if (x > bottomRight.x)
     x = bottomRight.x;
       if (y > bottomRight.y)
     y = bottomRight.y;
 }
Example #2
0
 public Point add(Point rhs)
 {
     return new Point(x+rhs.x, y+rhs.y);
 }
Example #3
0
 public void addToThis(Point p)
 {
     x += p.x;
       y += p.y;
 }
Example #4
0
 public Point subtract(Point rhs)
 {
     return new Point(x-rhs.x, y-rhs.y);
 }
Example #5
0
 public void subtractFromThis(Point p)
 {
     x -= p.x;
       y -= p.y;
 }
Example #6
0
 public Rect(Point leftTop, Point rightBottom)
 {
     set(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y);
 }
Example #7
0
 public bool contains(Point p)
 {
     return ((p.x >= left)&&(p.x <= right)&&(p.y >= top)&&(p.y <= bottom));
 }
Example #8
0
 public void setRightBottom(Point p)
 {
     right = p.x; bottom = p.y;
 }
Example #9
0
 public void setRightTop(Point p)
 {
     right = p.x; top = p.y;
 }
Example #10
0
 public void setLeftTop(Point p)
 {
     left = p.x; top = p.y;
 }
Example #11
0
 public void setLeftBottom(Point p)
 {
     left = p.x; bottom = p.y;
 }
Example #12
0
 /// <summary>
 /// Translates the rectangle so that its top left corner is at the 
 /// point specified.
 /// </summary>
 public void offsetTo(Point p)
 {
     offsetTo(p.x, p.y);
 }
Example #13
0
 /// <summary>
 /// Translates the rectangle by the amount specified in both the x and y 
 /// dimensions
 /// </summary>
 public void offsetBy(Point p)
 {
     offsetBy(p.x, p.y);
 }
Example #14
0
 /// <summary>
 /// Makes the rectangle smaller by the amount specified in both 
 /// the x and y dimensions
 /// </summary>
 public void insetBy(Point p)
 {
     insetBy(p.x, p.y);
 }