2.4.3 • Published 7 months ago

smooth-gradient v2.4.3

Weekly downloads
55
License
-
Repository
github
Last release
7 months ago

smooth-gradient.js

Test

Calculate a gradient and get one of its colors at a given point, from an array of colors.

Install the smooth-gradient module

npm install smooth-gradient

Add it to your source.

import { Gradient } from "smooth-gradient"

Usage

A single class is exposed, Gradient, which takes as much color elements as you want as parameters, and the amount of steps to use.

// Colors can be given as an unlimited number of parameters
const gradient = new Gradient("#FF0000", "#00FF00", "#00FFFF", "#123456");

You can now retreive the color corresponding to your input in the gradiant spectrum. Only values between 0 and 100 are effective. Negatives will be considered as 0 and values above 100 as 100.

const color = gradient.getColorFromValue(50, 'rgb');
const colorHex = gradient.getColorFromValue(50);
console.log(color); // output => rgb(0, 255, 180)
console.log(colorHex); // output => #00ffb4

This package could be a great fit for gradients in progress bars, for example.

2.3.0

7 months ago

2.2.1

7 months ago

2.2.0

7 months ago

2.1.1

7 months ago

2.0.2

7 months ago

2.3.2

7 months ago

2.2.3

7 months ago

2.4.0

7 months ago

2.3.1

7 months ago

2.2.2

7 months ago

2.4.3

7 months ago

2.2.4

7 months ago

2.1.0

7 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.0.0

1 year ago

0.8.0

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago