Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gradient-gauss

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gradient-gauss

Library to generate colors using a smooth gauss function

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gradient-gauss

A library to generate a color in a gradient using a Gaussian function. The gradient gauss library is provided a range of numbers and will then calculate the respective color for a given number with the range.

Simple demo showing the changes the gradient when certain parameters are tweaked.

Build Status npm version Code Climate maintainability

Getting Started

Download the package via NPM

npm install gradient-gauss 

import GradientGauss from 'gradient-gauss

or

const GradientGauss = require('gradient-gauss');

Examples

let gradient = new GradientGauss(1, 100); // Instantiate gradient gauss with a range of  1-100
let color = gradient.getColor(50); // Get the color for value 50

Options can be provided to GradientGauss to modify the behavior when calculating the colors. The following are the values that can be provided via the options:

  • min: the minimum value of your range
  • max: the maximum value of your range
  • outputFormat: the result format of the color. Options are either 'rgba' (for an rgba string) or 'array' (for an array in the format [r,g,b,a])
  • redCenterFactor: the location of the red bell curve center within the range provided
  • blueCenterFactor: the location of the blue bell curve center withiin the range provided
  • greenCenterFactor: the location of the green bell curve center withini the range provided
  • rangeDivisor: the number by which the number range will be divided the color bell curve widths

Note: The min and max options are not be used during instantiation. Check the documentation for more information on the options and default values.

options = {
    outputFormat: 'array',
    rangeDivisor: 4
};

let gradient = new GradientGauss(1, 100, options);

Options can also be provided to the getColors function as one-time overrides. For permanent changes to the values, provide those options during instantiation.

options = {
   max: 50,
};

new GradientGauss(1, 100).getColor(25, options);

Refer to the documentation for more information.

Documentation

Basic documentation
More to come.

License

Licensed under the MIT license.

FAQs

Package last updated on 13 Dec 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc