Source

jscolor /

Filename Size Date modified Message
9.9 KB
1.1 KB
1.8 KB

JSColor -- a small colour utilities library in JavaScript

This library contains functions to convert between different colour schemes in JavaScript. This might be useful for dynamic colour schemes or animation.

Usage

Include color-converter.js in your page. All the functions are available on the Color global object.

Functions

Color.rgb_to_hsl(red, green, blue)

Converts an RGB colour to HSL (hue/saturation/lightness). The input values must be in the range 0-255, the output values will be in the ranges 0-360 (hue) and 0-100 (saturation, lightness).

The algorithm used for conversion is taken from the CSS 3 specification.

Color.hsl_to_rgb(hue, saturation, brightness)

Converts an HSL colour to RGB. The input values must be in the ranges 0-360 (hue) and 0-100 (saturation, lightness), the output values will be in the range 0-255.

Color.to_hex(red, green, blue)

Converts RGB colour values into a CSS hex colour. For example, Color.to_hex(255, 255, 255) will produce "#ffffff".

License

This library is licensed under the Apache License v2.0. See LICENSE.txt for more information.