Class RGB

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

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

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

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

    Modifier and Type
    Method
    Description
    static RGB
    fromRGBA(RGBA rgba)
    Returns an RGB object from an RGBA object.
    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 rgb 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
    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 RGB BLACK
    • WHITE

      public static final RGB WHITE
  • Constructor Details

    • RGB

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

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

      public RGB(float red, float green, float blue)
      Creates a new RGB object from the color components in range from 0 to 1 floats.
      Parameters:
      red - Red component
      green - Green component
      blue - Blue 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
    • 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
    • getColor

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

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

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

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

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

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

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

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

      public static RGB fromRGBA(RGBA rgba)
      Returns an RGB object from an RGBA object. Alpha value is lost in that conversion.
      Parameters:
      rgba - RGBA object
      Returns:
      RGB object