Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public Point add(Point rhs)
 {
     return new Point(x+rhs.x, y+rhs.y);
 }
Exemplo n.º 3
0
 public void addToThis(Point p)
 {
     x += p.x;
       y += p.y;
 }
Exemplo n.º 4
0
 public Point subtract(Point rhs)
 {
     return new Point(x-rhs.x, y-rhs.y);
 }
Exemplo n.º 5
0
 public void subtractFromThis(Point p)
 {
     x -= p.x;
       y -= p.y;
 }
Exemplo n.º 6
0
 public Rect(Point leftTop, Point rightBottom)
 {
     set(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y);
 }
Exemplo n.º 7
0
 public bool contains(Point p)
 {
     return ((p.x >= left)&&(p.x <= right)&&(p.y >= top)&&(p.y <= bottom));
 }
Exemplo n.º 8
0
 public void setRightBottom(Point p)
 {
     right = p.x; bottom = p.y;
 }
Exemplo n.º 9
0
 public void setRightTop(Point p)
 {
     right = p.x; top = p.y;
 }
Exemplo n.º 10
0
 public void setLeftTop(Point p)
 {
     left = p.x; top = p.y;
 }
Exemplo n.º 11
0
 public void setLeftBottom(Point p)
 {
     left = p.x; bottom = p.y;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }