libgdx API

com.badlogic.gdx.math
Class Rectangle

java.lang.Object
  extended by com.badlogic.gdx.math.Rectangle
All Implemented Interfaces:
java.io.Serializable

public class Rectangle
extends java.lang.Object
implements java.io.Serializable

Encapsulates a 2D rectangle defined by it's bottom corner point and its extends in x (width) and y (height).

Author:
badlogicgames@gmail.com
See Also:
Serialized Form

Field Summary
 float height
           
static Rectangle tmp
          Static temporary rectangle.
static Rectangle tmp2
          Static temporary rectangle.
 float width
           
 float x
           
 float y
           
 
Constructor Summary
Rectangle()
          Constructs a new rectangle with all values set to zero
Rectangle(float x, float y, float width, float height)
          Constructs a new rectangle with the given corner point in the bottom left and dimensions.
Rectangle(Rectangle rect)
          Constructs a rectangle based on the given rectangle
 
Method Summary
 boolean contains(float x, float y)
           
 boolean contains(Rectangle rectangle)
           
 float getHeight()
           
 float getWidth()
           
 float getX()
           
 float getY()
           
 void merge(Rectangle rect)
          Merges this rectangle with the other rectangle.
 boolean overlaps(Rectangle rectangle)
           
 void set(float x, float y, float width, float height)
           
 void set(Rectangle rect)
          Sets the values of the given rectangle to this rectangle.
 void setHeight(float height)
          Sets the height of this rectangle
 void setWidth(float width)
          Sets the width of this rectangle
 void setX(float x)
          Sets the x-coordinate of the bottom left corner
 void setY(float y)
          Sets the y-coordinate of the bottom left corner
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tmp

public static final Rectangle tmp
Static temporary rectangle. Use with care! Use only when sure other code will not also use this.


tmp2

public static final Rectangle tmp2
Static temporary rectangle. Use with care! Use only when sure other code will not also use this.


x

public float x

y

public float y

width

public float width

height

public float height
Constructor Detail

Rectangle

public Rectangle()
Constructs a new rectangle with all values set to zero


Rectangle

public Rectangle(float x,
                 float y,
                 float width,
                 float height)
Constructs a new rectangle with the given corner point in the bottom left and dimensions.

Parameters:
x - The corner point x-coordinate
y - The corner point y-coordinate
width - The width
height - The height

Rectangle

public Rectangle(Rectangle rect)
Constructs a rectangle based on the given rectangle

Parameters:
rect - The rectangle
Method Detail

getX

public float getX()
Returns:
the x-coordinate of the bottom left corner

setX

public void setX(float x)
Sets the x-coordinate of the bottom left corner

Parameters:
x - The x-coordinate

getY

public float getY()
Returns:
the y-coordinate of the bottom left corner

setY

public void setY(float y)
Sets the y-coordinate of the bottom left corner

Parameters:
y - The y-coordinate

getWidth

public float getWidth()
Returns:
the width

setWidth

public void setWidth(float width)
Sets the width of this rectangle

Parameters:
width - The width

getHeight

public float getHeight()
Returns:
the height

setHeight

public void setHeight(float height)
Sets the height of this rectangle

Parameters:
height - The height

contains

public boolean contains(Rectangle rectangle)
Parameters:
rectangle - the other Rectangle.
Returns:
whether the other rectangle is contained in this rectangle.

overlaps

public boolean overlaps(Rectangle rectangle)
Parameters:
rectangle - the other Rectangle
Returns:
whether this rectangle overlaps the other rectangle.

set

public void set(float x,
                float y,
                float width,
                float height)

contains

public boolean contains(float x,
                        float y)
Parameters:
x - point x coordinate
y - point y coordinate
Returns:
whether the point is contained in the rectangle

set

public void set(Rectangle rect)
Sets the values of the given rectangle to this rectangle.

Parameters:
rect - the other rectangle

merge

public void merge(Rectangle rect)
Merges this rectangle with the other rectangle.

Parameters:
rect - the other rectangle

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)