Package icyllis.arc3d.core
Class Color
java.lang.Object
icyllis.arc3d.core.Color
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Represents fully opaque black.static final int
Represents fully opaque blue.static final int
Describes different color channels one can manipulate.static final int
Describes different color channels one can manipulate.static final int
Used to represent the channels available in a color type or texture format as a mask.static final int
Used to represent the channels available in a color type or texture format as a mask.static final int
Used to represent the channels available in a color type or texture format as a mask.static final int
Used to represent the channels available in a color type or texture format as a mask.static final int
Used to represent the channels available in a color type or texture format as a mask.static final int
static final int
static final int
static final int
Describes different color channels one can manipulate.static final int
Describes different color channels one can manipulate.static final int
Represents fully opaque cyan.static final int
Represents fully opaque dark gray.static final int
Represents fully opaque gray.static final int
Represents fully opaque green.static final int
Represents fully opaque light gray.static final int
Represents fully opaque magenta.static final int
Represents fully opaque red.static final int
Represents fully transparent Color.static final int
Represents fully opaque white.static final int
Represents fully opaque yellow. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
alpha
(int color) Return the alpha component of a color int.static int
alpha
(int color, int alpha) Returns un-premultiplied color with red, blue, and green set fromcolor
; and alpha set fromalpha
.static int
argb
(float alpha, float red, float green, float blue) Return a color-int from alpha, red, green, blue float components in the range \([0..1]\).static int
argb
(int alpha, int red, int green, int blue) Return a color-int from 8-bit alpha, red, green, blue components.static int
blue
(int color) Return the blue component of a color int.static float
GammaToLinear
(float x) Converts a color component from the sRGB space to the linear RGB space, using the sRGB transfer function.static void
GammaToLinear
(float @NonNull [] col) Converts a color from the sRGB space to the linear RGB space, using the sRGB transfer function.static int
green
(int color) Return the green component of a color int.static int
HSVToColor
(float @NonNull [] hsv) Converts HSV components to an RGB color.static int
HSVToColor
(float h, float s, float v) Converts HSV components to an RGB color.static float
lightness
(float lum) Coverts a luminance value to a perceptual lightness value.static float
LinearToGamma
(float x) Converts a color component from the linear RGB space to the sRGB space, using the inverse of sRGB transfer function.static void
LinearToGamma
(float @NonNull [] col) Converts a color from the linear RGB space to the sRGB space, using the inverse of sRGB transfer function.static float @NonNull []
load_and_premul
(int col) static float
luminance
(float[] col) Converts a linear RGB color to a luminance value.static float
luminance
(float r, float g, float b) Converts a linear RGB color to a luminance value.static int
red
(int color) Return the red component of a color int.static int
rgb
(float red, float green, float blue) Return a color-int from red, green, blue float components in the range \([0..1]\).static int
rgb
(int red, int green, int blue) Return a color-int from 8-bit alpha, red, green, blue components.static void
RGBToHSV
(int color, float[] hsv) Converts RGB to its HSV components.static void
RGBToHSV
(int r, int g, int b, float[] hsv) Converts RGB to its HSV components.
-
Field Details
-
TRANSPARENT
Represents fully transparent Color. May be used to initialize a destination containing a mask or a non-rectangular image.- See Also:
-
BLACK
Represents fully opaque black.- See Also:
-
DKGRAY
Represents fully opaque dark gray. Note that SVG dark gray is equivalent to 0xFFA9A9A9.- See Also:
-
GRAY
Represents fully opaque gray. Note that HTML gray is equivalent to 0xFF808080.- See Also:
-
LTGRAY
Represents fully opaque light gray. HTML silver is equivalent to 0xFFC0C0C0. Note that SVG light gray is equivalent to 0xFFD3D3D3.- See Also:
-
WHITE
Represents fully opaque white.- See Also:
-
RED
Represents fully opaque red.- See Also:
-
GREEN
Represents fully opaque green. HTML lime is equivalent. Note that HTML green is equivalent to 0xFF008000.- See Also:
-
BLUE
Represents fully opaque blue.- See Also:
-
YELLOW
Represents fully opaque yellow.- See Also:
-
CYAN
Represents fully opaque cyan. HTML aqua is equivalent.- See Also:
-
MAGENTA
Represents fully opaque magenta. HTML fuchsia is equivalent.- See Also:
-
COLOR_CHANNEL_R
public static final int COLOR_CHANNEL_RDescribes different color channels one can manipulate.- See Also:
-
COLOR_CHANNEL_G
public static final int COLOR_CHANNEL_GDescribes different color channels one can manipulate.- See Also:
-
COLOR_CHANNEL_B
public static final int COLOR_CHANNEL_BDescribes different color channels one can manipulate.- See Also:
-
COLOR_CHANNEL_A
public static final int COLOR_CHANNEL_ADescribes different color channels one can manipulate.- See Also:
-
COLOR_CHANNEL_FLAG_RED
public static final int COLOR_CHANNEL_FLAG_REDUsed to represent the channels available in a color type or texture format as a mask.- See Also:
-
COLOR_CHANNEL_FLAG_GREEN
public static final int COLOR_CHANNEL_FLAG_GREENUsed to represent the channels available in a color type or texture format as a mask.- See Also:
-
COLOR_CHANNEL_FLAG_BLUE
public static final int COLOR_CHANNEL_FLAG_BLUEUsed to represent the channels available in a color type or texture format as a mask.- See Also:
-
COLOR_CHANNEL_FLAG_ALPHA
public static final int COLOR_CHANNEL_FLAG_ALPHAUsed to represent the channels available in a color type or texture format as a mask.- See Also:
-
COLOR_CHANNEL_FLAG_GRAY
public static final int COLOR_CHANNEL_FLAG_GRAYUsed to represent the channels available in a color type or texture format as a mask.- See Also:
-
COLOR_CHANNEL_FLAGS_RG
public static final int COLOR_CHANNEL_FLAGS_RG- See Also:
-
COLOR_CHANNEL_FLAGS_RGB
public static final int COLOR_CHANNEL_FLAGS_RGB- See Also:
-
COLOR_CHANNEL_FLAGS_RGBA
public static final int COLOR_CHANNEL_FLAGS_RGBA- See Also:
-
-
Method Details
-
alpha
Return the alpha component of a color int. This is the same as saying color >>> 24 -
red
Return the red component of a color int. This is the same as saying (color >> 16) invalid input: '&' 0xFF -
green
Return the green component of a color int. This is the same as saying (color >> 8) invalid input: '&' 0xFF -
blue
Return the blue component of a color int. This is the same as saying color invalid input: '&' 0xFF -
alpha
Returns un-premultiplied color with red, blue, and green set fromcolor
; and alpha set fromalpha
. The alpha component ofcolor
is ignored and is replaced byalpha
in result.- Parameters:
color
- packed RGB, eight bits per componentalpha
- alpha: transparent at zero, fully opaque at 255- Returns:
- color with transparency
-
rgb
Return a color-int from 8-bit alpha, red, green, blue components. The alpha component is implicitly set fully opaque to 255. These component values should be \([0..255]\), but there is no range check performed, so if they are out of range, the returned color is undefined.- Parameters:
red
- red component \([0..255]\) of the colorgreen
- green component \([0..255]\) of the colorblue
- blue component \([0..255]\) of the color- Returns:
- color and alpha, un-premultiplied
-
rgb
Return a color-int from red, green, blue float components in the range \([0..1]\). The alpha component is implicitly 1.0 (fully opaque). If the components are out of range, the returned color is undefined.- Parameters:
red
- red component \([0..1]\) of the colorgreen
- green component \([0..1]\) of the colorblue
- blue component \([0..1]\) of the color- Returns:
- color and alpha, un-premultiplied
-
argb
Return a color-int from 8-bit alpha, red, green, blue components. These component values should be \([0..255]\), but there is no range check performed, so if they are out of range, the returned color is undefined. Since color is un-premultiplied, alpha may be smaller than the largest of red, green, and blue.- Parameters:
alpha
- alpha component \([0..255]\) of the colorred
- red component \([0..255]\) of the colorgreen
- green component \([0..255]\) of the colorblue
- blue component \([0..255]\) of the color- Returns:
- color and alpha, un-premultiplied
-
argb
Return a color-int from alpha, red, green, blue float components in the range \([0..1]\). If the components are out of range, the returned color is undefined.- Parameters:
alpha
- alpha component \([0..1]\) of the colorred
- red component \([0..1]\) of the colorgreen
- green component \([0..1]\) of the colorblue
- blue component \([0..1]\) of the color- Returns:
- color and alpha, un-premultiplied
-
RGBToHSV
public static void RGBToHSV(int r, int g, int b, float[] hsv) Converts RGB to its HSV components. hsv[0] contains hsv hue, a value from zero to less than 360. hsv[1] contains hsv saturation, a value from zero to one. hsv[2] contains hsv value, a value from zero to one.- Parameters:
r
- red component value from zero to 255g
- green component value from zero to 255b
- blue component value from zero to 255hsv
- three element array which holds the resulting HSV components
-
RGBToHSV
public static void RGBToHSV(int color, float[] hsv) Converts RGB to its HSV components. Alpha in ARGB (if it has) is ignored. hsv[0] contains hsv hue, and is assigned a value from zero to less than 360. hsv[1] contains hsv saturation, a value from zero to one. hsv[2] contains hsv value, a value from zero to one.- Parameters:
color
- RGB or ARGB color to converthsv
- three element array which holds the resulting HSV components
-
HSVToColor
public static int HSVToColor(float h, float s, float v) Converts HSV components to an RGB color. Alpha is NOT implicitly set.Out of range hsv values are clamped.
- Parameters:
h
- hsv hue, an angle from zero to less than 360s
- hsv saturation, and varies from zero to onev
- hsv value, and varies from zero to one- Returns:
- RGB equivalent to HSV, without alpha
-
HSVToColor
public static int HSVToColor(float @NonNull [] hsv) Converts HSV components to an RGB color. Alpha is NOT implicitly set. hsv[0] represents hsv hue, an angle from zero to less than 360. hsv[1] represents hsv saturation, and varies from zero to one. hsv[2] represents hsv value, and varies from zero to one.Out of range hsv values are clamped.
- Parameters:
hsv
- three element array which holds the input HSV components- Returns:
- RGB equivalent to HSV, without alpha
-
GammaToLinear
public static float GammaToLinear(float x) Converts a color component from the sRGB space to the linear RGB space, using the sRGB transfer function.- Parameters:
x
- a color component- Returns:
- transformed color component
-
LinearToGamma
public static float LinearToGamma(float x) Converts a color component from the linear RGB space to the sRGB space, using the inverse of sRGB transfer function.- Parameters:
x
- a color component- Returns:
- transformed color component
-
GammaToLinear
public static void GammaToLinear(float @NonNull [] col) Converts a color from the sRGB space to the linear RGB space, using the sRGB transfer function.- Parameters:
col
- the color components
-
LinearToGamma
public static void LinearToGamma(float @NonNull [] col) Converts a color from the linear RGB space to the sRGB space, using the inverse of sRGB transfer function.- Parameters:
col
- the color components
-
luminance
public static float luminance(float r, float g, float b) Converts a linear RGB color to a luminance value. -
luminance
public static float luminance(float[] col) Converts a linear RGB color to a luminance value.- Parameters:
col
- the color components
-
lightness
public static float lightness(float lum) Coverts a luminance value to a perceptual lightness value. -
load_and_premul
public static float @NonNull [] load_and_premul(int col)
-