Class RGBA

java.lang.Object
info.u_team.u_team_core.util.RGBA

public class RGBA extends Object
Basic rgba representation of a color with some conversion methods
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final RGBA
     
    static final RGBA
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RGBA(float red, float green, float blue, float alpha)
    Creates a new RGBA object from the color components in range from 0 to 1 floats.
    RGBA(int color)
    Creates a new RGBA object from a color integer
    RGBA(int red, int green, int blue, int alpha)
    Creates a new RGBA object from the color components in range from 0 to 255 integers.
  • Method Summary

    Modifier and Type
    Method
    Description
    static RGBA
    fromARGB(int color)
    Returns an RGBA object from an argb integer.
    int
    Get alpha component in range from 0 to 255
    float
    Get alpha component in range from 0 to 1
    int
    Get blue component in range from 0 to 255
    float
    Get blue component in range from 0 to 1
    int
    Get the integer (hex) representation of this color in rgba format
    int
    Get the integer (hex) representation of this color in argb format
    int
    Get green component in range from 0 to 255
    float
    Get green component in range from 0 to 1
    int
    Get red component in range from 0 to 255
    float
    Get red component in range from 0 to 1
    setAlpha(int alpha)
    Set the alpha component in range from 0 to 255
    setAlphaComponent(float alpha)
    Set the alpha component in range from 0 to 1
    setBlue(int blue)
    Set the blue component in range from 0 to 255
    setBlueComponent(float blue)
    Set the blue component in range from 0 to 1
    setGreen(int green)
    Set the green component in range from 0 to 255
    setGreenComponent(float green)
    Set the green component in range from 0 to 1
    setRed(int red)
    Set the red component in range from 0 to 255
    setRedComponent(float red)
    Set the red component in range from 0 to 1
     

    Methods inherited from class java.lang.Object

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

    • BLACK

      public static final RGBA BLACK
    • WHITE

      public static final RGBA WHITE
  • Constructor Details

    • RGBA

      public RGBA(int color)
      Creates a new RGBA object from a color integer
      Parameters:
      color - hex code of color e.g. 0xFFFFFFFF for white
    • RGBA

      public RGBA(int red, int green, int blue, int alpha)
      Creates a new RGBA object from the color components in range from 0 to 255 integers.
      Parameters:
      red - Red component
      green - Green component
      blue - Blue component
      alpha - Alpha component
    • RGBA

      public RGBA(float red, float green, float blue, float alpha)
      Creates a new RGBA object from the color components in range from 0 to 1 floats.
      Parameters:
      red - Red component
      green - Green component
      blue - Blue component
      alpha - Alpha component
  • Method Details

    • getRed

      public int getRed()
      Get red component in range from 0 to 255
      Returns:
      Red component
    • getGreen

      public int getGreen()
      Get green component in range from 0 to 255
      Returns:
      Green component
    • getBlue

      public int getBlue()
      Get blue component in range from 0 to 255
      Returns:
      Blue component
    • getAlpha

      public int getAlpha()
      Get alpha component in range from 0 to 255
      Returns:
      Alpha component
    • getRedComponent

      public float getRedComponent()
      Get red component in range from 0 to 1
      Returns:
      Red component
    • getGreenComponent

      public float getGreenComponent()
      Get green component in range from 0 to 1
      Returns:
      Green component
    • getBlueComponent

      public float getBlueComponent()
      Get blue component in range from 0 to 1
      Returns:
      Blue component
    • getAlphaComponent

      public float getAlphaComponent()
      Get alpha component in range from 0 to 1
      Returns:
      Alpha component
    • getColor

      public int getColor()
      Get the integer (hex) representation of this color in rgba format
      Returns:
      Color as an integer
    • getColorARGB

      public int getColorARGB()
      Get the integer (hex) representation of this color in argb format
      Returns:
      Color as an integer
    • setRed

      public RGBA setRed(int red)
      Set the red component in range from 0 to 255
      Parameters:
      red - Red component
      Returns:
      A new RGBA instance with the red value set
    • setGreen

      public RGBA setGreen(int green)
      Set the green component in range from 0 to 255
      Parameters:
      green - Green component
      Returns:
      A new RGBA instance with the green value set
    • setBlue

      public RGBA setBlue(int blue)
      Set the blue component in range from 0 to 255
      Parameters:
      blue - Blue component
      Returns:
      A new RGBA instance with the blue value set
    • setAlpha

      public RGBA setAlpha(int alpha)
      Set the alpha component in range from 0 to 255
      Parameters:
      alpha - Alpha component
      Returns:
      A new RGBA instance with the alpha value set
    • setRedComponent

      public RGBA setRedComponent(float red)
      Set the red component in range from 0 to 1
      Parameters:
      red - Red component
      Returns:
      A new RGBA instance with the red value set
    • setGreenComponent

      public RGBA setGreenComponent(float green)
      Set the green component in range from 0 to 1
      Parameters:
      green - Green component
      Returns:
      A new RGBA instance with the green value set
    • setBlueComponent

      public RGBA setBlueComponent(float blue)
      Set the blue component in range from 0 to 1
      Parameters:
      blue - Blue component
      Returns:
      A new RGBA instance with the blue value set
    • setAlphaComponent

      public RGBA setAlphaComponent(float alpha)
      Set the alpha component in range from 0 to 1
      Parameters:
      alpha - Alpha component
      Returns:
      A new RGBA instance with the alpha value set
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromARGB

      public static RGBA fromARGB(int color)
      Returns an RGBA object from an argb integer. This encoding is used in many minecraft stuff
      Parameters:
      color - ARBA color
      Returns:
      RGBA object