-
Notifications
You must be signed in to change notification settings - Fork 60
Color
deanjones edited this page Jul 20, 2014
·
1 revision
The HTML 5 Canvas spec allows the same values for color properties as defined in the CSS 3 Color specification.
Every Lienzo method that accepts colors will accept these CSS color strings. In addition, these Lienzo methods will accept objects that implement the IColor interface, namely ColorName (which is an Enum with all valid CSS color names) and Color, which provides functionality to parse CSS3 color strings, convert from/to RGB values etc.
Color Javadoc
ColorName Javadoc
CCS color strings are case-insensitive. Here are some examples:
Example | Meaning |
---|---|
"red" | color name (see Enum ColorName) |
"#FFF" or "#FFFFFF" | hex RGB color (3 or 6 hex digits) |
"rgb(255,255,255)" | RGB values as integers between 0 and 255 |
"rgba(255,255,255,0.8)" | RGB values as integers between 0 and 255 and alpha value between 0 and 1 |
"rgb(100%,100%,100%)" | RGB values as percentages |
"rgba(100%,100%,100%,0.8)" | RGB values as percentages and alpha value between 0 and 1 |
"hsl(120, 100%, 50%)" |
HSL values. Hue between 0 and 360 degrees (not including 360.) Hue values are normalized mod 360.) Saturation and Lightness as percentages. |
"hsla(120, 100%, 50%,0.8)" | HSL values and alpha. |
Alpha is also called "opacity". The default values is 1.
See CSS 3 Color for details
Colors and Transparency demo.