
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
rgbetween is a compact JavaScript package for creating colormaps using RGB color interpolation.
If more advanced features are needed, the package culori is recommended.
The module is available on npm:
npm install rgbetween
The colors must be encoded in a hexadecimal format. If stop values are not specified, the colors will be evenly distributed over the interval [0, 1].
const RGBetween = require("rgbetween");
const cmap = new RGBetween(["#ff0000", "#0000ff"]);
console.log(cmap.evaluate(0.5)); // Color halfway between red and blue
Custom stop values can be specified in the second parameter of the constructor. These values should generally be increasing, but two consecutive stops can have the same value (leading to sharp transitions). Values below the first stop, or above the last stop, are mapped to the first and last colors, respectively.
const colors = ["#000083", "#00ffff", "#ffff00", "#ff0000", "#7f0000"];
const stops = [0.1, 0.5, 0.5, 0.7, 0.9];
const cmap = new RGBetween(colors, stops);
console.log(cmap.evaluate(0.05)); // Prints #000083
Alternatively, the colors and stop values can be specified as an array of color-stop pairs. Transparency is handled by including the alpha channel in the hex format (e.g. #FF000080 is red with 50% transparency).
The method setEasing controls the amount of easing to apply during the interpolation, and expects a value between 0 and 1.
By default, easing is disabled.
const colors = [
["#3b3b3b00", 0],
["#07564aff", 0.2],
["#435fabff", 0.3],
["#f901ffff", 0.6],
["#fdab0000", 1]
];
const cmap = new RGBetween(colors);
cmap.setEasing(0.2);
new RGBetween(colors[, stops])
[["#ff0000", 0], ["#00ff00", 1]]), requiredconst cmap = new RGBetween(["#ff0000", "#0000ff"]);
const cmap = new RGBetween([["#ff0000", 0.2], ["#0000ff", 0.8]]);
const cmap = new RGBetween(["#ff0000", "#0000ff"], [0.2, 0.8]);
cmap.evaluate(t, returnHex = true)
Evaluates the colormap.
t is the position to evaluate, usually a number between 0 and 1.
When returnHex is true, the returned color is encoded as a hex color string.
Otherwise, the return value is an array containing RGB(A) values (scaled to the interval [0, 1]).
const color = cmap.evaluate(0.3);
const [r, g, b] = cmap.evaluate(0.7, false);
cmap.setEasing(value)
Sets the amount of easing to use when interpolating between two colors.
value should be between 0 and 1, where 0 is no easing and 1 is the highest amount possible.
cmap.setEasing(0.2);
FAQs
Lightweight colormaps using RGB color interpolation.
We found that rgbetween demonstrated a not healthy version release cadence and project activity because the last version was released 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
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.