java.lang.Object
org.strassburger.colorlab4j.color.Color
org.strassburger.colorlab4j.color.spaces.RGBColor

public class RGBColor extends Color
Represents a color in the RGB color space
See Also:
  • Constructor Details

  • Method Details

    • getRed

      public int getRed()
      Get the red value of the color (0-255)
      Returns:
      Red value
    • getGreen

      public int getGreen()
      Get the green value of the color (0-255)
      Returns:
      Green value
    • getBlue

      public int getBlue()
      Get the blue value of the color (0-255)
    • fromHex

      public static RGBColor fromHex(String hex) throws IllegalArgumentException
      Get an instance of RGBColor from a HEX color code
      Parameters:
      hex - HEX color code (e.g. "#ff0000")
      Returns:
      RGBColor instance
      Throws:
      IllegalArgumentException - If the HEX code is invalid
    • toHex

      public String toHex()
      Get the hex representation of the color
      Overrides:
      toHex in class Color
      Returns:
      Hex representation of the color (e.g. "#ff0000")
    • toRGB

      public RGBColor toRGB()
      Description copied from class: Color
      Convert the color to RGB
      Specified by:
      toRGB in class Color
      Returns:
      RGB representation of the color
    • toHSL

      public HSLColor toHSL()
      Description copied from class: Color
      Convert the color to HSL
      Specified by:
      toHSL in class Color
      Returns:
      HSL representation of the color
    • toHSV

      public HSVColor toHSV()
      Description copied from class: Color
      Convert the color to HSV
      Specified by:
      toHSV in class Color
      Returns:
      HSV representation of the color
    • toLAB

      public LABColor toLAB()
      Description copied from class: Color
      Convert the color to LAB
      Specified by:
      toLAB in class Color
      Returns:
      LAB representation of the color
    • toXYZ

      public XYZColor toXYZ()
      Description copied from class: Color
      Convert the color to XYZ
      Specified by:
      toXYZ in class Color
      Returns:
      XYZ representation of the color
    • toAnsi

      public String toAnsi()
      Description copied from class: Color
      Get the ANSI representation of the color
      Overrides:
      toAnsi in class Color
      Returns:
      ANSI representation of the color
    • toAnsiBackground

      public String toAnsiBackground()
      Description copied from class: Color
      Get the ANSI representation of the color for the background
      Overrides:
      toAnsiBackground in class Color
      Returns:
      ANSI representation of the color for the background
    • toCssString

      public String toCssString()
      Description copied from class: Color
      Get the CSS representation of the color
      Specified by:
      toCssString in class Color
      Returns:
      CSS representation of the color
    • toString

      public String toString()
      Overrides:
      toString in class Object