java.lang.Object | |
↳ | android.graphics.Color |
The Color class defines methods for creating and converting color ints. Colors are represented as packed ints, made up of 4 bytes: alpha, red, green, blue. The values are unpremultiplied, meaning any transparency is stored solely in the alpha component, and not in the color components. The components are stored as follows (alpha << 24) | (red << 16) | (green << 8) | blue. Each component ranges between 0..255 with 0 meaning no contribution for that component, and 255 meaning 100% contribution. Thus opaque-black would be 0xFF000000 (100% opaque but no contributions from red, green, or blue), and opaque-white would be 0xFFFFFFFF
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | BLACK | ||||||||||
int | BLUE | ||||||||||
int | CYAN | ||||||||||
int | DKGRAY | ||||||||||
int | GRAY | ||||||||||
int | GREEN | ||||||||||
int | LTGRAY | ||||||||||
int | MAGENTA | ||||||||||
int | RED | ||||||||||
int | TRANSPARENT | ||||||||||
int | WHITE | ||||||||||
int | YELLOW |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Convert HSV components to an ARGB color.
|
||||||||||
|
Convert HSV components to an ARGB color.
|
||||||||||
|
Convert RGB components to HSV.
|
||||||||||
|
Return the alpha component of a color int.
|
||||||||||
|
Return a color-int from alpha, red, green, blue components.
|
||||||||||
|
Return the blue component of a color int.
|
||||||||||
|
Convert the argb color to its HSV components.
|
||||||||||
|
Return the green component of a color int.
|
||||||||||
|
Parse the color string, and return the corresponding color-int.
|
||||||||||
|
Return the red component of a color int.
|
||||||||||
|
Return a color-int from red, green, blue components.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Convert HSV components to an ARGB color. Alpha set to 0xFF. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.
hsv | 3 element array which holds the input HSV components. |
---|
Convert HSV components to an ARGB color. The alpha component is passed through unchanged. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.
alpha | the alpha component of the returned argb color. |
---|---|
hsv | 3 element array which holds the input HSV components. |
Convert RGB components to HSV. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]
red | red component value [0..255] |
---|---|
green | green component value [0..255] |
blue | blue component value [0..255] |
hsv | 3 element array which holds the resulting HSV components. |
Return the alpha component of a color int. This is the same as saying color >>> 24
Return a color-int from 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.
alpha | Alpha component [0..255] of the color |
---|---|
red | Red component [0..255] of the color |
green | Green component [0..255] of the color |
blue | Blue component [0..255] of the color |
Return the blue component of a color int. This is the same as saying color & 0xFF
Convert the argb color to its HSV components. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]
color | the argb color to convert. The alpha component is ignored. |
---|---|
hsv | 3 element array which holds the resulting HSV components. |
Return the green component of a color int. This is the same as saying (color >> 8) & 0xFF
Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuschia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'
Return the red component of a color int. This is the same as saying (color >> 16) & 0xFF
Return a color-int from red, green, blue components. The alpha component is implicity 255 (fully opaque). 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.
red | Red component [0..255] of the color |
---|---|
green | Green component [0..255] of the color |
blue | Blue component [0..255] of the color |