Class RGBColor
java.lang.Object
org.strassburger.colorlab4j.color.Color
org.strassburger.colorlab4j.color.spaces.RGBColor
Represents a color in the RGB color space
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RGBColorGet an instance of RGBColor from a HEX color codeintgetBlue()Get the blue value of the color (0-255)intgetGreen()Get the green value of the color (0-255)intgetRed()Get the red value of the color (0-255)toAnsi()Get the ANSI representation of the colorGet the ANSI representation of the color for the backgroundGet the CSS representation of the colortoHex()Get the hex representation of the colortoHSL()Convert the color to HSLtoHSV()Convert the color to HSVtoLAB()Convert the color to LABtoRGB()Convert the color to RGBtoString()toXYZ()Convert the color to XYZ
-
Constructor Details
-
RGBColor
- Parameters:
r- Red value (0-255)g- Green value (0-255)b- Blue value (0-255)- Throws:
IllegalArgumentException- If any of the values are out of range
-
-
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
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
Get the hex representation of the color -
toRGB
Description copied from class:ColorConvert the color to RGB -
toHSL
Description copied from class:ColorConvert the color to HSL -
toHSV
Description copied from class:ColorConvert the color to HSV -
toLAB
Description copied from class:ColorConvert the color to LAB -
toXYZ
Description copied from class:ColorConvert the color to XYZ -
toAnsi
Description copied from class:ColorGet the ANSI representation of the color -
toAnsiBackground
Description copied from class:ColorGet the ANSI representation of the color for the background- Overrides:
toAnsiBackgroundin classColor- Returns:
- ANSI representation of the color for the background
-
toCssString
Description copied from class:ColorGet the CSS representation of the color- Specified by:
toCssStringin classColor- Returns:
- CSS representation of the color
-
toString
-