example4b_css_color - simple css color operations
To Notice: A simple
color
class allows HTML colors to be defined with
simple syntax, with a few math operations. Some example ways to define colors::
color(hex_rgb) // example: color(0xFF0000)
color(html_string) // example: color('#0F0') or color('#00FF00')
color(rgb_a) // example: color('#0F0',0.5) or color(0x0000FF,0.25)
color(r,g,b) // example: color(255,0,255)
add
, sub
, and mix
methods allow colors to be modified:
c.add(0xFF0000) // add red to existing color
c.sub(0xFF0000) // subtract red from existing color
c.mix(0xFF0000,0.75) // mix existing color with red (ration 25% to 75%)
methods r()
, g()
, b()
, & a()
can be used to get or set these components:
c.r() // return the red value of color
c.g(255) // set the green component to 255 (maximum value)
c.a(0.75) // set alpha value (opposite of opacity) to 75%
next: example5_inner_tag top: all js examples