JavaScript Library To Generate Linear Gradient Color Stops – gradStop.js

Category: Color , Javascript , Recommended | April 8, 2019
Author:Siddharth11
Views Total:2,130 views
Official Page:Go to website
Last Update:April 8, 2019
License:MIT

Preview:

JavaScript Library To Generate Linear Gradient Color Stops – gradStop.js

Description:

gradStop.js is a lightweight JavaScript library used to generate linear, equidistant color gradients with a specific number of stops.

Installation & Import:

# NPM
$ npm install gradstop --save
import gradstop from 'gradstop';

Basic usage:

First you need to include the gradStop.js library on the webpage.

<script src="dist/gradstop.js"></script>

Create a new gradStop object with options.

var gradient = gradStop({
    stops: 10,
    inputFormat: 'hex',
    colorArray: ['#343838', '#00DFFC', '#f6ff00']
});

Output the gradient colors.

console.log(gradient);

Default options.

// input color options: hex, rgb or hsl
inputFormat: 'hex',
// number of equidistant color stops (cannot be less than colorArray.length)
stops: 5,
// input color array (currently supports only 2)
colorArray: ['#fff', '#000']

Changelog:

04/08/2019

  • v2.2.3: Drop Math.trunc polyfill

01/07/2019

  • v2.2.2: Use reduce instead of map

01/06/2019

  • v2.2.1: Make certain functions non importable

12/30/2018

  • v2.2.0: Throw more validation errors

12/30/2018

  • v2.1.6: Use strict comparison to avoid type coercion

09/02/2018

  • v2.1.4: Do not store defaultOptions in prototype

You Might Be Interested In:


Leave a Reply