@zokugun/lang.color.alvy
v0.3.0
Published
Add hsv/hsb, hsl, hwb and hsi spaces to Color class
Downloads
31
Maintainers
Readme
@zokugun/lang.color.alvy
Provides HSV/HSB, HSV, HWB and HSI spaces.
Getting Started
With node previously installed:
npm install @zokugun/lang.color.alvy
Use it with JavaScript
:
require('kaoscript/register');
const { Color, Space } = require('@zokugun/lang.color.alvy')();
const c = new Color('hsl(90, 100%, 50%)');
Use it with kaoscript
:
import '@zokugun/lang.color.alvy'
const c = new Color('hsl(90, 100%, 50%)')
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.
hsl
hue()
: Numberhue(Number)
: Colorsaturation()
: Numbersaturation(Number)
: Colorlightness()
: Numberlightness(Number)
: Color
hsi
hue()
: Numberhue(Number)
: Colorsaturation()
: Numbersaturation(Number)
: Colorintensity()
: Numberintensity(Number)
: Color
hsb/hsv
hue()
: Numberhue(Number)
: Colorsaturation()
: Numbersaturation(Number)
: Colorbrightness()
: Numberbrightness(Number)
: Color
hwb
hue()
: Numberhue(Number)
: Colorwhiteness()
: Numberwhiteness(Number)
: Colorblackness()
: Numberblackness(Number)
: Color
Transformers
darken(Number)
: Colorlighten(Number)
: Colordesaturate(Number)
: Colorshift(Number)
: Colorunshift(Number)
: Color
Syntax
hsl
hsla?(hue, saturation, lightness, alpha?)
hue: from 0 to 100, no decimal
saturation: from 0 to 100, up to 1 decimal place
lightness: from 0 to 100, up to 1 decimal place
alpha: from 0 to 1, up to 3 decimal places
hsl(60, 100%, 50%)
hsl(100grad, 100%, 50%)
hsl(yellow, 100%, 50%)
hsi
hsia?(hue, saturation, intensity, alpha?)
hue: from 0 to 100, no decimal
saturation: from 0 to 100, up to 1 decimal place
intensity: from 0 to 255, no decimal
alpha: from 0 to 1, up to 3 decimal places
hsb
hsba?(hue, saturation, brightness, alpha?)
hue: from 0 to 100, no decimal
saturation: from 0 to 100, up to 1 decimal place
brightness: from 0 to 100, up to 1 decimal place
alpha: from 0 to 1, up to 3 decimal places
hwb
hwba?(hue, whiteness, blackness, alpha?)
hue: from 0 to 100, no decimal
whiteness: from 0 to 100, up to 1 decimal place
blackness: from 0 to 100, up to 1 decimal place
alpha: from 0 to 1, up to 3 decimal places
License
MIT © Baptiste Augrain