Class

MonoContrast

Extends:

Generates a monochromatic constrasting colour palette for background and foreground. What does this mean?

Monochromatic: A single colour is used to generate the base palette, and this colour is lightened five times and darkened five times to provide eleven distinct colours.

Contrasting: The foreground is also generated as a monochromatic colour palettte; however, all generated colours are tested to see that they are appropriately contrasting to ensure maximum readability of the foreground against the background.

Constants
DEFAULT_MINIMUM_BRIGHTNESS_DIFF
DEFAULT_MINIMUM_COLOR_DIFF
Public Attributes
background Hash of CSS background colour values.
foreground Hash of CSS foreground colour values.
minimum_brightness_diff The minimum brightness difference between the background and the foreground, and must be between 0..1. Setting this value will regenerate the palette based on the base colours. The default value for this is 125 / 255.0. If this value is set to nil, it will be restored to the default.
minimum_color_diff The minimum colour difference between the background and the foreground, and must be between 0..3. Setting this value will regenerate the palette based on the base colours. The default value for this is 500 / 255.0.
Public Methods
brightness_diff Returns the absolute difference between the brightness levels of two colours. This will be a decimal value between 0 and 1. W3C accessibility guidelines for colour contrast suggest that this value be at least approximately 0.49 (125 / 255.0) for proper contrast.
calculate_foreground Given a background colour and a foreground colour, modifies the foreground colour so that it will have enough contrast to be seen against the background colour.
color_diff Returns the contrast between to colours, a decimal value between 0 and
minimum_brightness_diff=
minimum_color_diff=
new Generate the initial palette.
regenerate Generate the colour palettes.
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.