# Class: Rectangle

### LuxModule: gui

A 2D rectangle for hittests. 2D Rectangles are used as bounding boxes for the Component class.

## Methods:

### Method overview:

- 1
- 2
- 3
- 4
- add
- area
- contains
- getClosestSide
- getCorners
- intersection
- intersects
- new
- setBounds
- toString
- translate

new ([table class, [float x,y,width,height]/[Rectangle rect] ])
  returns: ()
  creates a rectangle object with the given values as attributes. If a parameter is not specified, 0 is used as default value.
1
  {[int]} - x component
2
  {[int]} - y component
3
  {[int]} - width
4
  {[int]} - height
add (Rectangle self, Rectangle r / float x,float y)
  returns: ()
  adds a point or rectangle to the rectangle.
area (Rectangle self)
  returns: (area)
  area of rectangle (width*height)
contains (Rectangle r, float x,y)
  returns: (boolean)
  returns true if the given point is inside the rectangle. The borders of the rectangle are included.
getClosestSide (Rectangle,x,y)
  returns: (side)
  returns closest side to a given point, 1 top edge, 2... clockwise
getCorners (Rectangle)
  returns: (x1,y1,x2,y2)
  returns top left and bottom right coordinates
intersection (Rectangle a,b)
  returns: ([Rectangle])
  returns intersection of both triangles or nil if a and b do not intersect. If a or b is nil, nil is returned.
intersects (Rectangle self, Rectangle other)
  returns: (boolean)
  returns true if both rectangles do intersect
setBounds (Rectangle self, float x,y,w,h)
  returns: ()
  sets bounds of the Rectangle
toString (Rectangle self)
  returns: (string)
  returns a simple string representing this rectangle.
translate (Rectangle,x,y)
  returns: ()
  translates the rectangle