Socket
Socket
Sign inDemoInstall

gradient-base

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gradient-base

Base module of the gradient.js library


Version published
Weekly downloads
4
increased by300%
Maintainers
1
Install size
920 kB
Created
Weekly downloads
 

Readme

Source

gradient-base.js

License   Travis build  Codecov


This module creates base gradient output for gradient.js modules.

Table of contents


gradient.js

Gradient creation library running in the browser 🖌🌈

gradient.js is a javascript module that takes your source colors array and configuration object, and returns a gradient suitable for your needs.


Usage

Base.get function takes 2 parameters: the colors array and the configuration object.

const base = new Base()

const g = base.get(colors, options)
// [[0,222,31,0.4],[1.3265624999999999,199.890625,31.331640625,0.466328125], (...)]

Parameters

Colors

Colors input should be an array of numbers in rgb or rgba format or array of css rgb(a) strings.

Options

Options object stands for the basic settings of the gradient creation, mandatory for the chroma-js library. Its interface looks like below:

{
    interpolation: 'linear' | 'bezier'
    mode: 'none' | 'lch' | 'lab' | 'rgb' | 'hsv' | 'hsl' | 'hsi' | 'hcl'
    samples: number
    lightnessCorrection: boolean
}

The mode entry is ommited when the interpolation is set to bezier.

Usefullness of setting the lightness correction to true (combined with the bezier interpolation) is very well described by Gregor Aisch here.

The samples stand for the number of the output colors. The more you set, the nicer gradient you get (but with worse performance of course).

Opacity

Alpha values will be not preserved in the output if the interpolation will be set to the bezier value.

Keywords

FAQs

Last updated on 04 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc