color in RGB space, with optional alpha More...
Public Member Functions | |
Color () | |
create a color More... | |
Color (number c) | |
create a color from a single 32 bit A-RGB color value More... | |
Color (string colorstr) | |
create a color by CSS color string More... | |
Color (number r, number g, number b, number alpha=1) | |
create a color with RGB values More... | |
Color | assign (Color color) |
copy a color More... | |
convertToGrayscale () | |
convert the color to a matching shade of grey More... | |
boolean | equals (Color color) |
check if this color is the same as another More... | |
boolean | notEquals (Color color) |
check if this color is different than another color More... | |
Public Attributes | |
number | alpha |
alpha channel: 0.0 transparent ... 1.0 solid More... | |
number | blue |
blue component: 0.0 no blue ... 1.0 max blue More... | |
number | green |
green component: 0.0 no green ... 1.0 max green More... | |
number | red |
red component: 0.0 no red ... 1.0 max red More... | |
color in RGB space, with optional alpha
Color is in the global namespace, so you don't need the pdg prefix, even though it will work if you use it
RGB Color Space works by mixing red (R), green (G) and blue (B) light to form all possible colors. Here's a nice color wheel to illustrate.
The optional Alpha Channel is used to determine how translucent the color is, ie: how much the underlying colors show through. For Alpha, 1.0 is completely solid/opaque, and 0.0 is completely transparent. Whenever an Alpha value is not given, 1.0 is assumed.
Color | ( | ) |
create a color
Creates a color with all RGB values set to zero, and Alpha channel set to 1, ie: solid black.
Color | ( | number | c | ) |
create a color from a single 32 bit A-RGB color value
Creates a color from a single 32 bit RGB value with an Alpha channel. It's usually most convenient to express the number in hexadecimal, since it's easier to see the components:
In the example above, the A-RGB component values are represented as:
ff 00 44 88 A R G B
Color | ( | string | colorstr | ) |
create a color by CSS color string
Creates a color from a CSS color value string (ie: #FFF or #FFFFFF); or from a color name. For example:
Supported Color names:**
Color | ( | number | r, |
number | g, | ||
number | b, | ||
number | alpha = 1 |
||
) |
create a color with RGB values
Create a color by giving the Red, Green and Blue values separately, with an optional alpha channel. Values can be given either in the range of 0.0 to 1.0. If no alpha value is given, 1.0 is used, making the color completely solid.
assign | ( | Color | color | ) |
copy a color
Sets this color to be the same as another color
Output:
c1 is now Color(0,0,0)
convertToGrayscale | ( | ) |
convert the color to a matching shade of grey
equals | ( | Color | color | ) |
check if this color is the same as another
notEquals | ( | Color | color | ) |
check if this color is different than another color
alpha |
alpha channel: 0.0 transparent ... 1.0 solid
blue |
blue component: 0.0 no blue ... 1.0 max blue
green |
green component: 0.0 no green ... 1.0 max green
red |
red component: 0.0 no red ... 1.0 max red