java.lang.Object
technology.sola.engine.graphics.Color

@NullMarked public class Color extends Object
The Color class represents an argb color that can be used for rendering.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Color
    Color constant - rgb(0, 0, 0).
    static final Color
    Color constant - argb(0, 0, 0, 0).
    static final Color
    Color constant - rgb(0, 0, 255).
    static final Color
    Color constant - rgb(169, 169, 169).
    static final Color
    Color constant - rgb(0, 255, 0).
    static final Color
    Color constant - rgb(173, 216, 230).
    static final Color
    Color constant - rgb(211, 211, 211)
    static final float
    Constant used to normalize ARGB values to between 0 and 1.
    static final Color
    Color constant - rgb(255, 165, 0).
    static final Color
    Color constant - rgb(255, 0, 0).
    static final Color
    Color constant - rgb(255, 255, 255).
    static final Color
    Color constant - rgb(255, 255, 0).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Color(int argb)
    Creates a color instance from a 4 byte integer.
    Color(int r, int g, int b)
    Creates a Color instance via rgb values.
    Color(int alpha, int r, int g, int b)
    Creates a Color instance via argb values.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
     
    int
     
    int
     
    int
     
    int
     
    Creates a grey scale Color using this Color as the base.
    boolean
     
    int
     
    int
     
    shade(float shadeFactor)
    Creates a new Color that is a shade of this Color.
    tint(float tintFactor)
    Creates a new Color that is a tint of this Color.
     
    updateAlpha(int alpha)
    Returns a new Color with updated alpha.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • BLACK

      public static final Color BLACK
      Color constant - rgb(0, 0, 0).
    • BLANK

      public static final Color BLANK
      Color constant - argb(0, 0, 0, 0).
    • BLUE

      public static final Color BLUE
      Color constant - rgb(0, 0, 255).
    • DARK_GRAY

      public static final Color DARK_GRAY
      Color constant - rgb(169, 169, 169).
    • GREEN

      public static final Color GREEN
      Color constant - rgb(0, 255, 0).
    • ORANGE

      public static final Color ORANGE
      Color constant - rgb(255, 165, 0).
    • RED

      public static final Color RED
      Color constant - rgb(255, 0, 0).
    • LIGHT_BLUE

      public static final Color LIGHT_BLUE
      Color constant - rgb(173, 216, 230).
    • LIGHT_GRAY

      public static final Color LIGHT_GRAY
      Color constant - rgb(211, 211, 211)
    • YELLOW

      public static final Color YELLOW
      Color constant - rgb(255, 255, 0).
    • WHITE

      public static final Color WHITE
      Color constant - rgb(255, 255, 255).
    • ONE_DIV_255

      public static final float ONE_DIV_255
      Constant used to normalize ARGB values to between 0 and 1.
      See Also:
  • Constructor Details

    • Color

      public Color(int r, int g, int b)
      Creates a Color instance via rgb values. Alpha is set to 255. Values should be set to between 0 and 255 inclusive.
      Parameters:
      r - red
      g - green
      b - blue
    • Color

      public Color(int alpha, int r, int g, int b)
      Creates a Color instance via argb values. Values should be set to between 0 and 255 inclusive.
      Parameters:
      alpha - the alpha
      r - red
      g - green
      b - blue
    • Color

      public Color(int argb)
      Creates a color instance from a 4 byte integer. Order of bytes should be [alpha, red, green, blue].
      Parameters:
      argb - the 4 byte integer
  • Method Details

    • hexInt

      public int hexInt()
      Returns:
      the color has a 4 byte hex integer
    • getAlpha

      public int getAlpha()
      Returns:
      the alpha value
    • getRed

      public int getRed()
      Returns:
      the red value
    • getGreen

      public int getGreen()
      Returns:
      the green value
    • getBlue

      public int getBlue()
      Returns:
      the blue value
    • hasAlpha

      public boolean hasAlpha()
      Returns:
      true if alpha value is not 255
    • updateAlpha

      public Color updateAlpha(int alpha)
      Returns a new Color with updated alpha.
      Parameters:
      alpha - the new alpha
      Returns:
      a new color instance with updated alpha
    • greyScale

      public Color greyScale()
      Creates a grey scale Color using this Color as the base.
      Returns:
      this color as greyscale
    • shade

      public Color shade(float shadeFactor)
      Creates a new Color that is a shade of this Color.
      Parameters:
      shadeFactor - the shade factor from 0-1
      Returns:
      the shaded Color
    • tint

      public Color tint(float tintFactor)
      Creates a new Color that is a tint of this Color.
      Parameters:
      tintFactor - the tint factor from 0-1
      Returns:
      the tinted Color
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object