@zokugun/lang.color
v0.3.0
Published
A Color class with extensible color spaces
Readme
@zokugun/lang.color
Provides a color class with the support of the RGB space with support of extensible spaces.
Getting Started
With node previously installed:
npm install @zokugun/lang.colorUse 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')Methods
Properties
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
srgb/rgb
red(): Numberred(Number): Colorgreen(): Numbergreen(Number): Colorblue(): Numberblue(Number): Color
Transformers
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>
Data
contrast()distance(Color): Numberluminance(): Numberreadable(Color): Boolean
Formatters
format(String): Stringhex(): String
Extends
Color.registerFormatter(String:format, Function)Color.registerParser(String:format, Function)
Macros
Color.registerSpace!(Object:space)
ICC Profiles
There no support for ICC profiles, yet. So the rgb is the standard RGB of the web: sRGB.
Spaces
Spaces | Package ------ | ------- hsl, hsb/hsv, hsi, hwb | @zokugun/lang.color.alvy CIELAB, CIELUV, CIELCh, CIEXYZ, CIEYxy | @zokugun/lang.color.cie
Inspired by
- http://www.xarg.org/project/jquery-color-plugin-xcolor/
- https://github.com/brehaut/color-js
- https://github.com/LeaVerou/contrast-ratio
License
MIT © Baptiste Augrain
