Skip to content

ZokugunKS/lang.color.alvy

Repository files navigation

kaoscript License NPM Version Dependency Status Build Status CircleCI Coverage Status

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(): Number
  • hue(Number): Color
  • saturation(): Number
  • saturation(Number): Color
  • lightness(): Number
  • lightness(Number): Color

hsi

  • hue(): Number
  • hue(Number): Color
  • saturation(): Number
  • saturation(Number): Color
  • intensity(): Number
  • intensity(Number): Color

hsb/hsv

  • hue(): Number
  • hue(Number): Color
  • saturation(): Number
  • saturation(Number): Color
  • brightness(): Number
  • brightness(Number): Color

hwb

  • hue(): Number
  • hue(Number): Color
  • whiteness(): Number
  • whiteness(Number): Color
  • blackness(): Number
  • blackness(Number): Color

Transformers

  • darken(Number): Color
  • lighten(Number): Color
  • desaturate(Number): Color
  • shift(Number): Color
  • unshift(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