npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kandinsky-js

v2.0.0

Published

A tiny colour library

Downloads

20

Readme

Installation

npm install --save kandinsky-js

and import as needed.

Features

  • Written in TypeScript, usable in JavaScript
  • Immutable, composable functions
  • Deals with hex, rgb and hsl colours
  • Programmatic generation for linear and non-linear gradients

API

Types


type RGB = [number, number, number];
type HSL = [number, number, number];

// When either RGB or HSL colours can be used
type XYZ = RGB | HSL;

// `t` is expected to be in range [0, 1], and the function should return a value
// in the range [0, 1]
type EaseFn = (t: number) => number;

rgb2hsl(rgbArray)

returns a hsl array


rgb2hsl: ([r, g, b]: RGB) => HSL;

hsl2rgb(hslArray)

returns an rgb array


hsl2rgb: ([h, s, l]: HSL) => RGB;

hex2rgb(hexString)

returns an rgb array


hex2rgb: (hex: string) => RGB;

rgb2hex(rgbArray)

returns a hex string


rgb2hex: (rgb: RGB) => string;

hex2hsl(hexString)

returns a hsl array


hex2hsl: (hex: string) => HSL;

hsl2hex(hslArray)

returns a hex string


hsl2hex: (hsl: HSL) => string;

darkenRgb(amount, rgbArray)

returns a darkened rgb array. amount is a value in the range [0, 1]


darkenRgb: (amount: number, rgb: RGB) => RGB;

lightenRgb(amount, rgbArray)

returns a lightened rgb array. amount is a value in the range [0, 1]


lightenRgb: (amount: number, rgb: RGB) => RGB;

darkenHsl(amount, hslArray)

returns a darkened hsl array. amount is a value in the range [0, 1]


darkenHsl: (amount: number, [h, s, l]: HSL) => HSL;

lightenHsl(amount, hslArray)

returns a lightened hsl array. amount is a value in the range [0, 1]


lightenHsl: (amount: number, [h, s, l]: HSL) => HSL;

lightenHex(amount, hexString)

returns a lightened hex string. amount is a value in the range [0, 1]


lightenHex: (amount: number, hex: string) => string;

darkenHex(amount, hexString)

returns a darkened hex string. amount is a value in the range [0, 1]


darkenHex: (amount: number, hex: string) => string;

lerp3(t, c1, c2)

returns a Vector3 colour somewhere between c1 and c2. t is the "time" value in the range [0, 1]


lerp3: (t: number, [a1, b1, c1]: XYZ, [a2, b2, c2]: XYZ) => XYZ;

linearGradient(n, c1, c2)

returns an length n array of Vector3 colours. colours are evenly spaced between c1 and c2.


linearGradient: (n: number, c1: XYZ, c2: XYZ) => XYZ[];

gradient(easeFn, n, c1, c2)

returns an length n array of Vector3 colours. colours are between c1 and c2, and are spaced according to the easing function easeFn.


gradient: (ease: EaseFn, n: number, c1: XYZ, c2: XYZ) => XYZ[];

multiGradient(n, [col1, col3, ..., colN])

returns a length n array of Vector3 colours. colours are the ones formed from the linearGradient(n/(numColours-1), col1, col2) for all colours col1, col2, ..., colN


multiGradient: (n: number, colors: XYZ[]) => XYZ[];

rLinearGradient(n, c1, c2)

returns a rounded, length n array of Vector3 colours. colours are evenly spaced between c1 and c2.


rLinearGradient: (n: number, c1: XYZ, c2: XYZ) => XYZ[];

rGradient(easeFn, n, c1, c2)

returns a rounded, length n array of Vector3 colours. colours are between c1 and c2, and are spaced according to the easing function easeFn.


rGradient: (ease: EaseFn, n: number, c1: XYZ, c2: XYZ) => XYZ[];

rMultiGradient(n, [col1, col3, ..., colN])

returns a rounded, length n array of Vector3 colours. colours are the ones formed from the linearGradient(n/(numColours-1), col1, col2) for all colours col1, col2, ..., colN


rMultiGradient: (n: number, colors: XYZ[]) => XYZ[];

complimentHex(n, hexString)

returns an length n array of hex strings. The 0th color is the same as the input hexString, while the others are colours corresponding to an eve turn around the colour wheel. If n is 3 for example, the two other colours would represent a 1/3 and 2/3 rotation of the colour wheel.


complimentHex: (n: number, hex: string) => string[];

complimentHsl(n, hsl)

returns an length n array of hsl Vector3. The 0th color is the same as the input hsl, while the others are colours corresponding to an eve turn around the colour wheel. If n is 3 for example, the two other colours would represent a 1/3 and 2/3 rotation of the colour wheel.


complimentHsl: (n: number, [h, s, l]: HSL) => HSL[];

complimentRgb(n, rgb)

returns an length n array of rgb Vector3. The 0th color is the same as the input rgb, while the others are colours corresponding to an eve turn around the colour wheel. If n is 3 for example, the two other colours would represent a 1/3 and 2/3 rotation of the colour wheel.


complimentRgb: (n: number, rgb: RGB) => RGB[];

rgb2css(alpha, rgb)

returns an rgba css string like rgba(255, 255, 255, 1) from the rgb color and alpha value


rgb2css: (alpha: number, rgb: RGB) => string;

hsl2css(alpha, hsl)

returns an hsl css string like hsl(222, 50%, 75%, 0.6) from the hsl color and alpha value


hsl2css: (alpha: number, [h, s, l]: HSL) => string;