@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.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')
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()
: Number -
alpha(Number)
: Color
srgb/rgb
-
red()
: Number -
red(Number)
: Color -
green()
: Number -
green(Number)
: Color -
blue()
: Number -
blue(Number)
: Color
Transformers
-
blend(Color, Number:percentage, String:space, Boolean:alpha)
: Color -
clearer(Number)
: Color -
opaquer(Number)
: Color -
shade(Number)
: Color -
tint(Number)
: Color -
tone(Number)
: Color -
greyscale(String:model)
: Color -
negative()
: Color -
scheme(Array<Function>)
: Array<Color> -
gradient(Color, Number)
: Array<Color>
Data
contrast()
-
distance(Color)
: Number -
luminance()
: Number -
readable(Color)
: Boolean
Formatters
-
format(String)
: String -
hex()
: 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