Class Color

java.lang.Object
org.xjge.graphics.Color

public final class Color
extends java.lang.Object
An immutable object used to represent color.
Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type Field Description
    float b  
    static Color BLACK  
    static Color BLUE  
    static Color BROWN  
    static Color CYAN  
    float g  
    static Color GRAY  
    static Color GREEN  
    static Color LIME  
    static Color MAGENTA  
    static Color ORANGE  
    static Color PINK  
    static Color PURPLE  
    float r  
    static Color RED  
    static Color SILVER  
    static Color TEAL  
    static Color WHITE  
    static Color YELLOW  
  • Method Summary

    Modifier and Type Method Description
    org.joml.Vector3f asVec3()
    Returns the RGB component values of this object as a three-component floating point vector that can be passed to a shader program through a uniform variable.
    boolean compareTo​(Color other)
    Compares the RGB component values of this color to another.
    static Color create​(int r, int g, int b)
    Creates a new color object using the values of the three RGB components supplied.
    static Color random()
    Creates a random color.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • WHITE

      public static final Color WHITE
    • SILVER

      public static final Color SILVER
    • GRAY

      public static final Color GRAY
    • BLACK

      public static final Color BLACK
    • RED

      public static final Color RED
    • ORANGE

      public static final Color ORANGE
    • YELLOW

      public static final Color YELLOW
    • LIME

      public static final Color LIME
    • GREEN

      public static final Color GREEN
    • TEAL

      public static final Color TEAL
    • CYAN

      public static final Color CYAN
    • BLUE

      public static final Color BLUE
    • PURPLE

      public static final Color PURPLE
    • MAGENTA

      public static final Color MAGENTA
    • PINK

      public static final Color PINK
    • BROWN

      public static final Color BROWN
    • r

      public final float r
    • g

      public final float g
    • b

      public final float b
  • Method Details

    • create

      public static Color create​(int r, int g, int b)
      Creates a new color object using the values of the three RGB components supplied. Component values are expected to be within the range of 0 to 255.
      Parameters:
      r - the red color component
      g - the green color component
      b - the blue color component
      Returns:
      a new immutable color object generated with the specified RGB components
    • random

      public static Color random()
      Creates a random color.
      Returns:
      a new immutable color object that exhibits randomized color component values
    • asVec3

      public org.joml.Vector3f asVec3()
      Returns the RGB component values of this object as a three-component floating point vector that can be passed to a shader program through a uniform variable.
      Returns:
      the value of this color RGB components as a three-component floating point vector struct
    • compareTo

      public boolean compareTo​(Color other)
      Compares the RGB component values of this color to another.
      Parameters:
      other - the color to test this one against
      Returns:
      true if the colors are the same