Class ColorRGBA

java.lang.Object
net.risingworld.api.utils.ColorRGBA
All Implemented Interfaces:
Serializable

public class ColorRGBA extends Object implements Serializable
Represents a color consisting of a red, green and blue component (linear color space) as well as an alpha component (for transparency/opacity).
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    The alpha (opacity) color component (0-1)
    float
    The blue color component (0-1)
    static final ColorRGBA
    Black color (0, 0, 0)
    static final ColorRGBA
    Blue color (0, 0, 1)
    static final ColorRGBA
    Black color with no alpha (0, 0, 0)
    float
    The green color component (0-1)
    static final ColorRGBA
    Green color (0, 1, 0)
    static final ColorRGBA
    Grey color (0.5, 0.5, 0.5)
    float
    The red color component (0-1)
    static final ColorRGBA
    Red color (1, 0, 0)
    static final ColorRGBA
    White color (1, 1, 1)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new white color (all values 1)
    ColorRGBA(float r, float g, float b, float a)
    Creates a new color with the provided values.
    ColorRGBA(int rgba)
     
    Creates a new color and copies the values from the provided color.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(float r, float g, float b, float a)
     
    boolean
    Gets whether or not this color is equal to another object.
    fromIntRGBA(int rgba)
     
    int
     
    interpolateLocal(ColorRGBA color, float mu)
    Interpolates this color to the provided final color, e.g if this color is (0, 0, 1, 1), and the final color is (1, 0.5f, 0, 1), the result (by using a mu-value of 0.5f) would be (0.5f, 0.25f, 0.5f, 1)
    set(float r, float g, float b, float a)
    Sets the r, g, b and a values of this color to the provided values.
    set(ColorRGBA color)
    Sets the r, g, b and a values of this color to the values of the provided color.
    int
    Converts the color r, g, b and a values to an int representation.
    Gets a String representation of this color, for example (1.0, 0.5, 0.0, 1.0)
     

    Methods inherited from class java.lang.Object

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

    • White

      public static final ColorRGBA White
      White color (1, 1, 1)
    • Grey

      public static final ColorRGBA Grey
      Grey color (0.5, 0.5, 0.5)
    • Black

      public static final ColorRGBA Black
      Black color (0, 0, 0)
    • Clear

      public static final ColorRGBA Clear
      Black color with no alpha (0, 0, 0)
    • Red

      public static final ColorRGBA Red
      Red color (1, 0, 0)
    • Green

      public static final ColorRGBA Green
      Green color (0, 1, 0)
    • Blue

      public static final ColorRGBA Blue
      Blue color (0, 0, 1)
    • r

      public float r
      The red color component (0-1)
    • g

      public float g
      The green color component (0-1)
    • b

      public float b
      The blue color component (0-1)
    • a

      public float a
      The alpha (opacity) color component (0-1)
  • Constructor Details

    • ColorRGBA

      public ColorRGBA()
      Creates a new white color (all values 1)
    • ColorRGBA

      public ColorRGBA(int rgba)
    • ColorRGBA

      public ColorRGBA(float r, float g, float b, float a)
      Creates a new color with the provided values.
      Parameters:
      r - the red color component (0-1).
      g - the green color component (0-1).
      b - the blue color component (0-1).
      a - the alpha (opacity) color component (0-1).
    • ColorRGBA

      public ColorRGBA(ColorRGBA copy)
      Creates a new color and copies the values from the provided color.
      Parameters:
      copy - the color to copy.
  • Method Details

    • set

      public ColorRGBA set(ColorRGBA color)
      Sets the r, g, b and a values of this color to the values of the provided color.
      Parameters:
      color - the ColorRGBA to copy.
      Returns:
      this color.
    • set

      public ColorRGBA set(float r, float g, float b, float a)
      Sets the r, g, b and a values of this color to the provided values.
      Parameters:
      r - the red color value.
      g - the green color value.
      b - the blue color value.
      a - the alpha (opacity) color value.
      Returns:
      this color.
    • interpolateLocal

      public ColorRGBA interpolateLocal(ColorRGBA color, float mu)
      Interpolates this color to the provided final color, e.g if this color is (0, 0, 1, 1), and the final color is (1, 0.5f, 0, 1), the result (by using a mu-value of 0.5f) would be (0.5f, 0.25f, 0.5f, 1)
      Parameters:
      color - the color to interpolate towards.
      mu - the mu value between 0.0 and 1.0 (i.e the percentage change from this color to towards the final color).
      Returns:
      this color containing the interpolated color values.
    • toVector4f

      public Vector4f toVector4f()
    • toIntRGBA

      public int toIntRGBA()
      Converts the color r, g, b and a values to an int representation.
      Returns:
      the integer representation of this color in rgba order.
    • fromIntRGBA

      public ColorRGBA fromIntRGBA(int rgba)
    • equals

      public boolean equals(Object o)
      Gets whether or not this color is equal to another object. This function returns true, if the other object is a ColorRGBA and if it has exactly the same r, g, b and a values.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare to equality.
      Returns:
      true if the other object is a ColorRGBA and has the same values as this color, false if not.
    • equals

      public boolean equals(float r, float g, float b, float a)
    • hashCode

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

      public String toString()
      Gets a String representation of this color, for example (1.0, 0.5, 0.0, 1.0)
      Overrides:
      toString in class Object
      Returns:
      a string representing the values of this color.