Package org.xjge.graphics
Class Rectangle
java.lang.Object
org.xjge.graphics.Rectangle
public class Rectangle
extends java.lang.Object
Data structure used by
RectangleBatch
objects to draw single color
rectangles.- Since:
- 2.0.0
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
contains(org.joml.Vector2i point)
Determines if the specified point has intersected this rectangle.void
freeBuffers()
Convenience method which frees the default buffer objects defined by this class.void
render(float opacity, Color color)
A quick and dirty way to render a rectangle with little overhead.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
xPos
public int xPos -
yPos
public int yPos -
width
public int width -
height
public int height
-
-
Constructor Details
-
Rectangle
public Rectangle()Creates a new rectangle object. -
Rectangle
public Rectangle(int xPos, int yPos, int width, int height)Creates a new rectangle object using the data specified.- Parameters:
xPos
- the x-coordinate of the rectangles positionyPos
- the y-coordinate of the rectangles positionwidth
- the width of the rectangleheight
- the height of the rectangle
-
-
Method Details
-
contains
public boolean contains(org.joml.Vector2i point)Determines if the specified point has intersected this rectangle.- Parameters:
point
- the point to check- Returns:
- true if an intersection was detected
-
render
A quick and dirty way to render a rectangle with little overhead.NOTE: Anytime a large number of rectangles needs to be drawn efficiently
RectangleBatch
should instead be used in place of this method.- Parameters:
opacity
- the transparency value of the rectanglecolor
- the color to draw the rectangle in
-
freeBuffers
public void freeBuffers()Convenience method which frees the default buffer objects defined by this class. Only required ifrender()
is called and this object is no longer needed.
-