Provides a color class with the support of the RGB space with support of extensible spaces.
With node previously installed:
npm install @zokugun/lang.color
Use it with JavaScript:
require('kaoscript/register');
const { Color, Space } = require('@zokugun/lang.color')();
const c = new Color('#ff0');Use it with kaoscript:
import '@zokugun/lang.color'
const c = new Color('#ff0')
A color is defined in a color space. If you try to access it into another space, the color will be automatically converted into the new space.
alpha(): Numberalpha(Number): Color
red(): Numberred(Number): Colorgreen(): Numbergreen(Number): Colorblue(): Numberblue(Number): Color
blend(Color, Number:percentage, String:space, Boolean:alpha): Colorclearer(Number): Coloropaquer(Number): Colorshade(Number): Colortint(Number): Colortone(Number): Colorgreyscale(String:model): Colornegative(): Colorscheme(Array<Function>): Array<Color>gradient(Color, Number): Array<Color>
contrast()distance(Color): Numberluminance(): Numberreadable(Color): Boolean
format(String): Stringhex(): String
Color.registerFormatter(String:format, Function)Color.registerParser(String:format, Function)
Color.registerSpace!(Object:space)
There no support for ICC profiles, yet. So the rgb is the standard RGB of the web: sRGB.
| Spaces | Package |
|---|---|
| hsl, hsb/hsv, hsi, hwb | @zokugun/lang.color.alvy |
| CIELAB, CIELUV, CIELCh, CIEXYZ, CIEYxy | @zokugun/lang.color.cie |
- http://www.xarg.org/project/jquery-color-plugin-xcolor/
- https://github.com/brehaut/color-js
- https://github.com/LeaVerou/contrast-ratio
MIT © Baptiste Augrain