Class ColorUtilities
ColorUtilities contains a set of tools to perform
common color operations easily.
- Author:
- Romain Guy romain.guy@mac.com
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColorHSLtoRGB(float h, float s, float l) Returns the RGB equivalent of a given HSL (Hue/Saturation/Luminance) color.static int[]HSLtoRGB(float h, float s, float l, int[] rgb) Returns the RGB equivalent of a given HSL (Hue/Saturation/Luminance) color.static float[]RGBtoHSL(int r, int g, int b) Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color.static float[]RGBtoHSL(int r, int g, int b, float[] hsl) Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color.static float[]Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color.static float[]Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color.
-
Method Details
-
RGBtoHSL
Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color. All three HSL components are between 0.0 and 1.0.
- Parameters:
color- the RGB color to convert- Returns:
- a new array of 3 floats corresponding to the HSL components
-
RGBtoHSL
Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color. All three HSL components are between 0.0 and 1.0.
- Parameters:
color- the RGB color to converthsl- a pre-allocated array of floats; can be null- Returns:
hslif non-null, a new array of 3 floats otherwise- Throws:
IllegalArgumentException- ifhslhas a length lower than 3
-
RGBtoHSL
public static float[] RGBtoHSL(int r, int g, int b) Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color. All three HSL components are between 0.0 and 1.0.
- Parameters:
r- the red component, between 0 and 255g- the green component, between 0 and 255b- the blue component, between 0 and 255- Returns:
- a new array of 3 floats corresponding to the HSL components
-
RGBtoHSL
public static float[] RGBtoHSL(int r, int g, int b, float[] hsl) Returns the HSL (Hue/Saturation/Luminance) equivalent of a given RGB color. All three HSL components are floats between 0.0 and 1.0.
- Parameters:
r- the red component, between 0 and 255g- the green component, between 0 and 255b- the blue component, between 0 and 255hsl- a pre-allocated array of floats; can be null- Returns:
hslif non-null, a new array of 3 floats otherwise- Throws:
IllegalArgumentException- ifhslhas a length lower than 3
-
HSLtoRGB
Returns the RGB equivalent of a given HSL (Hue/Saturation/Luminance) color.
- Parameters:
h- the hue component, between 0.0 and 1.0s- the saturation component, between 0.0 and 1.0l- the luminance component, between 0.0 and 1.0- Returns:
- a new
Colorobject equivalent to the HSL components
-
HSLtoRGB
public static int[] HSLtoRGB(float h, float s, float l, int[] rgb) Returns the RGB equivalent of a given HSL (Hue/Saturation/Luminance) color. All three RGB components are integers between 0 and 255.
- Parameters:
h- the hue component, between 0.0 and 1.0s- the saturation component, between 0.0 and 1.0l- the luminance component, between 0.0 and 1.0rgb- a pre-allocated array of ints; can be null- Returns:
rgbif non-null, a new array of 3 ints otherwise- Throws:
IllegalArgumentException- ifrgbhas a length lower than 3
-