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

    Fields
    Modifier and Type Field Description
    int height  
    int width  
    int xPos  
    int yPos  
  • Constructor Summary

    Constructors
    Constructor Description
    Rectangle()
    Creates a new rectangle object.
    Rectangle​(int xPos, int yPos, int width, int height)
    Creates a new rectangle object using the data specified.
  • 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 position
      yPos - the y-coordinate of the rectangles position
      width - the width of the rectangle
      height - 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

      public void render​(float opacity, Color color)
      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 rectangle
      color - 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 if render() is called and this object is no longer needed.