1.0.1 • Published 5 years ago

colourz v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

colourz

Manipulate colors using hsv, rgba and use as css, hex string or integer array

Install: yarn add colourz --save

Use:

    import * as co from 'colourz'

    let myColor = new co.shifter();

    // set hue saturation luminance and alpha values between 0 and 1
    myColor
        .hue(0.5)
        .sat(0.4)
        .lum(0.3)
        .alp(1.0);

    console.log(myColor.css()); // `hsla(0.5, 0.4, 0.3, 1.0)`
    

Constructor

    let color = new co.shifter(/*rgba color*/);
    color = new co.shifter(co.Palette.Blue);

Takes an rgba color in format 0xaarrggbb where a is alpha rgb is other colors. You can also use predefined colors from #Palette.

Methods

   color
    .hue(0.1)
    .sat(0.1)
    .lum(0.1)
    .alp(1.0)

.hue, .sat .lum .alp sets the hue, saturation, luminance and alpha values between 0 and 1.

color.hsl([h, s, l]) sets hsl from a single array of h s l values in range 0 and 1.

color.hsb([h, s, b]) sets hsl from a single array of h s b values in range h 360 s 100 b 100.

color.reset() reset the hue saturation luminance and alpha values to base values.

color.base() set the current color values as the base values. So the .reset will reset to current values.

color.copy() returns a new instance with the same color values.

Palette

Defines predefined color values in Palette format 0xaarrggbb to pass to the constructor. See colors.js for all defined colors.

    co.Palette.Blue
    co.Palette.SwanWhite
    co.Palette.CrocTooth
    co.Palette.SummerSky
    co.Palette.GreyPorc
    co.Palette.Pumpkin
    co.Palette.CelGreen
    co.Palette.FluRed
    co.Palette.Mandarin
    co.Palette.LuckyP
    co.Palette.ChileanFire

Misc

co.arr(rgba) Converts a color defined in Palette format to array format. Eg: co.arr(0xaarrggbb) gives [r, g, b, a];

co.fromArr([r, g, b, a]) Converts a color in array format to Palette format.

hslToRgba(h, s, l, a) Converts h, s, l, a values into Palette format.

css(/* colour in Palette format */) returns Css color property in rgba(r, g, b, a) format.