Author image Claes Jakobsson
and 1 contributors

NAME

VS::Chart::Color - Solid colors

INTERFACE

CLASS METHODS

new ( RED, GREEN, BLUE [, ALPHA ])
new ( HEX )

Creates a new instance with the color specified by either specifiying each component. Components should normally be defined as a decimal fraction from 0 to 1. Components may also be specified as a value from 0 to 255 but if any compoenent is specified as such all components will considered to be specified in the same way.

For simplicitiy it is also possible to specify a hexadecimal string with leading # as HTML. This must be either 6 or 8 characters long. If it's 8 characters the last two are considered to be alpha.

An alpha value of 1 (255 or #ff) is non-translucent.

color ( NAME )

Returns the color with the predefined NAME.

Predefined colors are (in hexadecimal form without alpha):

 # Colors
 white          #ffffff
 black          #000000
 red            #ff0000
 green          #00ff00
 blue           #0000ff
 
 # Specific items on the chart
 grid           #cccccc
 axis           #333333
 major_tick     #333333
 minor_tick     #eeeeee
 text           #000000
 border         #000000

 # Colors for 16 series which may be repated
 dataset_0      #2e578c
 dataset_1      #5d9648
 dataset_2      #e7a13d
 dataset_3      #bc2d30
 dataset_4      #6f3d79
 dataset_5      #7d807f
 dataset_6      #41699b
 dataset_7      #6ea45a
 dataset_8      #eaad55
 dataset_9      #c54346
 dataset_10     #814f8b
 dataset_11     #8e9190
 dataset_12     #577caa
 dataset_13     #80b26e
 dataset_14     #eeb96d
 dataset_15     #ce5b5d
 
get ( [SPEC | COLOR], DEFAULT )

Returns a color either by spec (SEE new above), an existing instance COLOR or the default if SPEC or COLOR couldn't be handled correctly or are 1.

INSTANCE METHODS

set ( CONTEXT )

Sets the color to be the corrent drawing color for CONTEXT.

as_hex

Returns the color as a hexadecimal formated string suitable for using in CSS. Returned string is prefixed with #.