A class for manipulating rectangles.
None
Rect.new(Integer x, Integer y, Integer width,
Integer height)
Creates a Rect object from x, y, width and height values.
Rect.new(Point topLeft, Point bottomRight)
Creates a Rect object from top-left and bottom-right points.
Rect.new(Point pos, Size size)
Creates a Rect object from position and size values.
Rect.new(Size size)
Creates a Rect object from size values at the origin.
intx
x coordinate of the top-level corner of the rectangle.
inty
y coordinate of the top-level corner of the rectangle.
intwidth
Width member.
intheight
Height member.
Rect centre_in(Rect r, Integer dir = BOTH)
Rect center_in(Rect r, Integer dir = BOTH)
Returns the rectangle having the same size as this one but centered relatively
to the given rectangle r. By default, rectangle is centred in both
directions but if dir includes only VERTICAL or only
HORIZONTAL flag, then it is only centered in this direction while
the other component of its position remains unchanged.
Boolean contains(Integer x, Integer y)
Boolean contains(Point pt)
Returns true if the given point is inside the rectangle (or on its
boundary) and false otherwise.
Boolean contains(Rect rect)
Returns if the given rectangle is completely inside this rectangle (or touches its boundary) and otherwise.
deflate(Integer dx, Integer dy)
deflate(Size diff)
deflate(Integer diff)
Rect deflate(Integer dx, Integer dy)
Decrease the rectangle size.
This method is the opposite from Inflate: Deflate(a, b) is equivalent to Inflate(-a, -b). Please refer to Inflate for full description.
Integer get_bottom()
Gets the bottom point of the rectangle.
Integer get_height()
Gets the height member.
Integer get_left()
Gets the left point of the rectangle (the same as Rect#get_x).
Point get_position()
Gets the position.
Point get_top_left()
Gets the position of the top left corner of the rectangle, same as get_position.
Point get_top_right()
Gets the position of the top right corner.
Point get_bottom_left()
Gets the position of the bottom left corner.
Point get_bottom_right()
Gets the position of the bottom right corner.
Integer get_right()
Gets the right point of the rectangle.
Size get_size()
Gets the size.
Integer get_top()
Gets the top point of the rectangle (the same as Rect#get_y).
Integer get_width()
Gets the width member.
Integer get_x()
Gets the x member.
Integer get_y()
Gets the y member.
inflate(Integer dx, Integer dy)
inflate(Size diff)
inflate(Integer diff)
Rect inflate(Integer dx, Integer dy)
Increases the size of the rectangle.
The second form uses the same diff for both dx and dy.
The first two versions modify the rectangle in place, the last one returns a new rectangle leaving this one unchanged.
The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note the the width and height of the rectangle thus change by 2dx and 2dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
Inflating and deflating behaves ``naturally’’. Defined more precisely, that means:
Boolean intersects(Rect rect)
Returns true if this rectangle has a non-empty intersection with the
rectangle rect and false otherwise.
Boolean is_empty()
Returns true if this rectangle has a width or height less than or equal to
0 and false otherwise.
offset(Integer dx, Integer dy)
offset(Point pt)
Moves the rectangle by the specified offset. If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
set_height(Integer height)
Sets the height.
set_size(Size s)
Sets the size.
set_width(Integer width)
Sets the width.
set_x(Integer x)
Sets the x position.
set_y(Integer y)
Sets the y position.
Rect union(Rect rect)
Rect union(Rect rect)
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. The const version returns the new rectangle, the other one modifies this rectangle in place.
operator $=$(Rect rect)
Assignment operator.
Boolean operator $==$(Rect rect)
Equality operator.
Boolean operator $!=$(Rect rect)
Inequality operator.
[This page automatically generated from the Textile source at Thu May 01 00:50:42 +0100 2008]