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

@evergis/color

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/color - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

dist/es/ColorScale.d.ts

32

dist/es/index.js

@@ -468,2 +468,32 @@ /**

export { Color };
class ColorScale {
constructor(palette) {
this.palette = palette;
}
getColor(p) {
const palette = this.palette.slice();
palette[0][0] = 0;
palette[palette.length - 1][0] = 1;
let colors = palette.map(item => { return new Color(item[1]); });
if (p >= 1) {
let color = new Color(palette[palette.length - 1][1]);
color.a = 255;
return color.toString();
}
for (let i = 0; i < palette.length; i++) {
if (palette[i][0] > p) {
let width = palette[i][0] - palette[i - 1][0];
let color1 = colors[i - 1];
let color2 = colors[i];
let k = (p - palette[i - 1][0]) / width;
let channels = ['r', 'g', 'b', 'a'].map(function (ch) { return Math.round(color1[ch] + (color2[ch] - color1[ch]) * k); });
channels[3] = 1;
return 'rgba(' + channels.join(',') + ')';
}
}
return null;
}
;
}
export { Color, ColorScale };

@@ -474,3 +474,34 @@ (function (global, factory) {

class ColorScale {
constructor(palette) {
this.palette = palette;
}
getColor(p) {
const palette = this.palette.slice();
palette[0][0] = 0;
palette[palette.length - 1][0] = 1;
let colors = palette.map(item => { return new Color(item[1]); });
if (p >= 1) {
let color = new Color(palette[palette.length - 1][1]);
color.a = 255;
return color.toString();
}
for (let i = 0; i < palette.length; i++) {
if (palette[i][0] > p) {
let width = palette[i][0] - palette[i - 1][0];
let color1 = colors[i - 1];
let color2 = colors[i];
let k = (p - palette[i - 1][0]) / width;
let channels = ['r', 'g', 'b', 'a'].map(function (ch) { return Math.round(color1[ch] + (color2[ch] - color1[ch]) * k); });
channels[3] = 1;
return 'rgba(' + channels.join(',') + ')';
}
}
return null;
}
;
}
exports.Color = Color;
exports.ColorScale = ColorScale;

@@ -477,0 +508,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

3

package.json
{
"name": "@evergis/color",
"version": "0.0.2",
"version": "0.0.3",
"description": "",

@@ -11,2 +11,3 @@ "main": "dist/lib/index.js",

"build": "cross-env NODE_ENV=production rollup --config rollup.config.js",
"dev": "cross-env NODE_ENV=production rollup --config rollup.config.js --watch",
"prepublishOnly": "npm i && npm run build"

@@ -13,0 +14,0 @@ },

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