Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
smooth-gradient
Advanced tools
Readme
Calculate a gradient and get one of its colors at a given point, from an array of colors.
npm install smooth-gradient
Add it to your source.
import { Gradient } from "smooth-gradient"
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.
FAQs
Generates a gradient and can return a calculated color from an input
The npm package smooth-gradient receives a total of 104 weekly downloads. As such, smooth-gradient popularity was classified as not popular.
We found that smooth-gradient demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.