public class Rectangle extends Shape implements Parallelogram
| Constructor and Description |
|---|
Rectangle()
Default constructor.
|
Rectangle(float x,
float y,
float width,
float height)
Constructor
|
Rectangle(Rectangle rectangle)
Constructs a new
Rectangle as a copy of another |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Circle circle) |
boolean |
contains(float x,
float y)
Returns if a set of coordinates are contained inside this
Shape |
boolean |
contains(Parallelogram parallelogram) |
boolean |
contains(Rectangle rectangle) |
boolean |
contains(Shape shape)
|
boolean |
contains(com.badlogic.gdx.math.Vector2 point)
Returns if a
Vector2 is contained inside this Shape |
Shape |
copy()
Returns an exact copy of this
Shape |
void |
draw(Graphics g)
Draws this shape using a
Graphics instance |
EdgeIterator |
edgeIterator()
Returns an
EdgeIterator for looping over the edges of this
Shape |
boolean |
equals(java.lang.Object obj) |
void |
fill(Graphics g)
Fills this shape using a
Graphics instance |
float |
getCenterX()
Returns the x coordinate of the center of this
Rectangle |
float |
getCenterY()
Returns the y coordinate of the center of this
Rectangle |
float |
getDistanceTo(float x,
float y)
Returns the distance from this
Shape to a set of coordinates |
float |
getDistanceTo(Point point)
|
float |
getHeight()
Returns the height of the shape
|
float |
getMaxX()
Returns the greatest x coordinate this
Rectangle |
float |
getMaxY()
Returns the greatest y coordinate this
Rectangle |
float |
getMinX()
Returns the least x coordinate this
Rectangle |
float |
getMinY()
Returns the least y coordinate this
Rectangle |
int |
getNumberOfSides()
Returns the number of edges of this object
|
Polygon |
getPolygon()
|
float |
getRotation()
Returns the rotation of this
Shape |
float[] |
getVertices()
Returns the vertices that make up this
Rectangle |
float |
getWidth()
Returns the width of the shape
|
float |
getX()
Returns the x coordinate of this object
|
float |
getY()
Returns the y coordinate of this object
|
int |
hashCode() |
Rectangle |
intersection(Rectangle rect) |
boolean |
intersects(Circle circle)
|
boolean |
intersects(float x,
float y,
float width,
float height)
Returns if this shape intersects a specified rectangle dimensions
|
boolean |
intersects(Parallelogram parallelogram) |
boolean |
intersects(Polygon polygon)
|
boolean |
intersects(Rectangle rectangle)
Returns if the specified
Rectangle intersects this one |
boolean |
intersects(Shape shape)
|
boolean |
intersects(Triangle triangle)
|
boolean |
intersectsLineSegment(float x1,
float y1,
float x2,
float y2)
Returns if this
Shape intersects a line segment |
boolean |
intersectsLineSegment(LineSegment lineSegment)
Returns if this shape intersects a specified
LineSegment |
boolean |
intersectsLineSegment(com.badlogic.gdx.math.Vector2 pointA,
com.badlogic.gdx.math.Vector2 pointB)
Returns if this
Shape intersects a line segment |
boolean |
isCircle()
|
Rectangle |
lerp(Rectangle target,
float alpha) |
void |
rotate(float degrees)
Rotates this
Shape by a specified amount of degrees with its
first point as the origin |
void |
rotateAround(float centerX,
float centerY,
float degrees)
Rotates this
Shape by a specified amount of degrees around a
specified point |
void |
scale(float scale)
Scales the radius of this shape.
|
void |
set(float x,
float y)
Sets the x and y coordinate of this object
|
Rectangle |
set(float x,
float y,
float width,
float height) |
void |
set(Rectangle rectangle) |
void |
set(com.badlogic.gdx.math.Vector2 position) |
void |
setCenter(float x,
float y)
Sets the center x,y coordinate of this object
|
void |
setCenterX(float x)
Sets the center x coordinate
|
void |
setCenterY(float y)
Sets the center y coordianate
|
Rectangle |
setHeight(float height) |
void |
setRadius(float radius)
Sets the radius of this shape.
|
void |
setRotation(float degrees)
Sets the rotation of this
Shape with its first point as the
origin |
void |
setRotationAround(float centerX,
float centerY,
float degrees)
Sets the rotation of this
Shape with a specified point as the
origin |
void |
setRotationAround(Point center,
float degrees)
Sets the current rotation of the shape around a center point
|
Rectangle |
setSize(float sizeXY) |
Rectangle |
setSize(float width,
float height) |
Rectangle |
setWidth(float width) |
void |
setX(float x)
Sets the x coordinate of this object
|
void |
setY(float y)
Sets the y coordinate of this object
|
java.lang.String |
toString() |
void |
translate(float translateX,
float translateY)
Translates the x and y coordinate of this object
|
add, intersects, subtractpublic Rectangle()
Rectangle at 0,0 with a width and
height of 1public Rectangle(float x,
float y,
float width,
float height)
public boolean contains(float x,
float y)
ShapeShapecontains in interface Parallelogramcontains in class Shapex - The x coordinate to checky - The y coordinate to checkShape contains the specified coordinatespublic boolean contains(com.badlogic.gdx.math.Vector2 point)
ShapeVector2 is contained inside this Shapepublic boolean contains(Parallelogram parallelogram)
public boolean contains(Rectangle rectangle)
public boolean contains(Circle circle)
public boolean intersects(Shape shape)
Shapeintersects in interface Parallelogramintersects in class Shapeshape - The Shape to checkShape intersects the specified Shapepublic boolean intersectsLineSegment(LineSegment lineSegment)
ParallelogramLineSegmentintersectsLineSegment in interface ParallelogramlineSegment - The LineSegment to test for intersectionpublic boolean intersects(Circle circle)
public boolean intersects(Rectangle rectangle)
Rectangle intersects this onepublic boolean intersects(Parallelogram parallelogram)
public boolean intersects(float x,
float y,
float width,
float height)
Parallelogramintersects in interface Parallelogramx - The x coordinate of the rectangley - The y coordinate of the rectanglewidth - The width of the rectangleheight - The height of the rectanglepublic boolean intersects(Triangle triangle)
public boolean intersects(Polygon polygon)
public boolean intersectsLineSegment(com.badlogic.gdx.math.Vector2 pointA,
com.badlogic.gdx.math.Vector2 pointB)
ShapeShape intersects a line segmentintersectsLineSegment in class ShapepointA - The first point in the line segmentpointB - The second point in the line segmentShape intersects the line segmentpublic boolean intersectsLineSegment(float x1,
float y1,
float x2,
float y2)
ShapeShape intersects a line segmentintersectsLineSegment in class Shapex1 - The x coordinate of the first pointy1 - The y coordinate of the first pointx2 - The x coordinate of the second pointy2 - The y coordinate of the second pointShape intersects the line segmentpublic int getNumberOfSides()
ShapegetNumberOfSides in class ShapeShape.getNumberOfSides()public void draw(Graphics g)
ShapeGraphics instancedraw in class Shapeg - The Graphics context to render withShape.draw(Graphics)public void fill(Graphics g)
ShapeGraphics instancepublic float getDistanceTo(Point point)
ShapegetDistanceTo in class Shapepoint - The Point to get the distance topublic float getDistanceTo(float x,
float y)
ShapeShape to a set of coordinatesgetDistanceTo in class Shapex - The x coordinatey - The y coordinatepublic float getRotation()
ShapeShapegetRotation in interface ParallelogramgetRotation in class Shapepublic void setRotation(float degrees)
ShapeShape with its first point as the
originsetRotation in interface ParallelogramsetRotation in class Shapedegrees - The rotation in degreespublic void rotate(float degrees)
ShapeShape by a specified amount of degrees with its
first point as the originrotate in interface Parallelogramrotate in class Shapedegrees - The rotation in degreespublic void rotateAround(float centerX,
float centerY,
float degrees)
ShapeShape by a specified amount of degrees around a
specified pointrotateAround in interface ParallelogramrotateAround in class ShapecenterX - The origin/center x coordinatecenterY - The origin/center y coordinatedegrees - The rotation in degreespublic void setRotationAround(Point center, float degrees)
ParallelogramsetRotationAround in interface Parallelogramcenter - The center point to rotate arounddegrees - The rotation angle in degreespublic void setRotationAround(float centerX,
float centerY,
float degrees)
ShapeShape with a specified point as the
originsetRotationAround in class ShapecenterX - The origin/center x coordinatecenterY - The origin/center y coordinatedegrees - The rotation in degreespublic Rectangle set(float x, float y, float width, float height)
public void set(Rectangle rectangle)
public void set(float x,
float y)
Shapepublic void set(com.badlogic.gdx.math.Vector2 position)
public float getX()
ShapegetX in interface ParallelogramgetX in class Shapepublic void setX(float x)
Shapepublic float getY()
ShapegetY in interface ParallelogramgetY in class Shapepublic void setY(float y)
Shapepublic float getWidth()
ParallelogramgetWidth in interface Parallelogrampublic Rectangle setWidth(float width)
public float getHeight()
ParallelogramgetHeight in interface Parallelogrampublic Rectangle setHeight(float height)
public Rectangle setSize(float width, float height)
public Rectangle setSize(float sizeXY)
public void setRadius(float radius)
Shapepublic void scale(float scale)
Shapepublic void translate(float translateX,
float translateY)
Shapepublic EdgeIterator edgeIterator()
ShapeEdgeIterator for looping over the edges of this
ShapeedgeIterator in class ShapeEdgeIteratorpublic float getCenterX()
RectanglegetCenterX in class Shapepublic float getCenterY()
RectanglegetCenterY in class Shapepublic void setCenter(float x,
float y)
Shapepublic void setCenterX(float x)
ShapesetCenterX in class Shapex - The x coordinate of the shape's centerpublic void setCenterY(float y)
ShapesetCenterY in class Shapey - The y coordinate of the shape's centerpublic float getMinX()
Rectanglepublic float getMinY()
Rectanglepublic float getMaxX()
RectanglegetMaxX in interface ParallelogramgetMaxX in class Shapepublic float getMaxY()
RectanglegetMaxY in interface ParallelogramgetMaxY in class Shapepublic float[] getVertices()
Rectanglepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isCircle()
Shapepublic Polygon getPolygon()
ShapegetPolygon in class ShapeShape is a Circle