An object which stores red, green, blue, and alpha values in instance variables, and provides numerous class and instance methods for creating and manipulating these values.
Create a new instance with float values.
red |
An instance of Float between 0 and 1. |
green |
An instance of Float between 0 and 1. |
blue |
An instance of Float between 0 and 1. |
alpha |
An instance of Float between 0 and 1. |
Create a new instance from 8-bit integer values between 0 and 255.
red |
An instance of Integer between 0 and 255. |
green |
An Integer between 0 and 255. |
blue |
An Integer between 0 and 255. |
alpha |
An Integer between 0 and 255. |
Same as Color.new(*array)
.
array |
Creates a new instance from a hex color string.
string |
A String. |
The string should be a 6 character web color, or a 3 character CSS style color. A preceding # is optional.
Nothing is darker.
Nothing is lighter.
Nothing is more clear.
American shades of grey.
gray |
Shades between 0 (black) and 1 (white) as Float. |
alpha |
Transparency of gray between 0 and 1 as Float. |
British shades of grey.
grey |
Shades between 0 (black) and 1 (white) as Float. |
alpha |
Transparency of grey between 0 and 1 as Float. |
Create a new red, green, blue, cyan, magenta or yellow Color.
val |
An instance of Float between 0 and 1, where 1 is the bright, fully saturated color, and 0 is black. |
alpha |
Transparency between 0 and 1 as Float. |
A random RGB Color where the colors are randomly chosen between lo
and hi
. See *new.
lo |
An instance of Float between 0 and 1. |
hi |
An instance of Float between 0 and 1. |
Maps hsv and alpha values to rgb between 0 and 1.
hue |
Float between 0 and 0.999. |
sat |
Float between 0 and 1. |
val |
Float between 0 and 1. |
alpha |
Float between 0 and 1. |
Get/set one of the instance variables, red
, green
, blue
, or alpha
.
An instance of Float between 0 and 1.
Returns a String containing a 6 character web color code, preceded by a #.
Binary operator.
Returns a Color, where red
, green
, and blue
are scaled by the alpha
value, and alpha is set to 1.
Interpolates the red
, green
, blue
, and alpha
values of two Colors, linearly weighting between the first and the second.
that |
A second Color. |
blend |
0 means only this, while 1 means only that. |
Returns a random variation of a Color.
val |
Varies the RGB values +- this amount. |
lo |
Low-clips the RGB variation here. |
hi |
High-clips the RGB variation here. |
alphaVal |
Varies the alpha value +/- this amount, and clips it between 0 and 1. |
Returns the complementary color.
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
opacity |
A value between 0 and 1. Default value is 1.0. |
aColor |
An instance of Color. |
blend |
A value between 0 and 1. Default value is 0. |
aColor |
An instance of Color. |
blend |
A value between 0 and 1. Default value is 0. |
aColor |
An instance of Color. |
blend |
A value between 0 and 1. Default value is 0. |
Returns an array with [hue, saturation, value, alpha]
, as values between 0 and 1.
Returns an array with [red, green, blue, alpha]
, as values between 0 and 1.
Returns an array with [red, green, blue, alpha]
.
Round the color.