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

color-mapping

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-mapping - npm Package Compare versions

Comparing version 1.0.0-0 to 1.0.0-1

dist/presets/index.esm.js

1

dist/index.d.ts
export { createColorMap, createColorMapFromColors, createColorMapFromColorNodes } from './mapping';
export { linearScale } from './scales';
export { viridis, blackWhite } from './colors';
export { Range, RGBColor, RGBAColor, ColorNode, Scale, ColorMap, MapMode } from './types';

@@ -97,26 +97,2 @@ function isColorNode(color) {

const blackWhite = [
[0, 0, 0],
[1, 1, 1]
];
const viridis = [
[0.267004, 0.004874, 0.329415],
[0.282327, 0.094955, 0.417331],
[0.278826, 0.17549, 0.483397],
[0.258965, 0.251537, 0.524736],
[0.229739, 0.322361, 0.545706],
[0.19943, 0.387607, 0.554642],
[0.172719, 0.448791, 0.557885],
[0.149039, 0.508051, 0.55725],
[0.127568, 0.566949, 0.550556],
[0.120638, 0.625828, 0.533488],
[0.157851, 0.683765, 0.501686],
[0.24607, 0.73891, 0.452024],
[0.369214, 0.788888, 0.382914],
[0.515992, 0.831158, 0.294279],
[0.678489, 0.863742, 0.189503],
[0.845561, 0.887322, 0.099702],
[0.993248, 0.906157, 0.143936]
];
export { blackWhite, createColorMap, createColorMapFromColorNodes, createColorMapFromColors, linearScale, viridis };
export { createColorMap, createColorMapFromColorNodes, createColorMapFromColors, linearScale };

@@ -103,27 +103,2 @@ (function (global, factory) {

const blackWhite = [
[0, 0, 0],
[1, 1, 1]
];
const viridis = [
[0.267004, 0.004874, 0.329415],
[0.282327, 0.094955, 0.417331],
[0.278826, 0.17549, 0.483397],
[0.258965, 0.251537, 0.524736],
[0.229739, 0.322361, 0.545706],
[0.19943, 0.387607, 0.554642],
[0.172719, 0.448791, 0.557885],
[0.149039, 0.508051, 0.55725],
[0.127568, 0.566949, 0.550556],
[0.120638, 0.625828, 0.533488],
[0.157851, 0.683765, 0.501686],
[0.24607, 0.73891, 0.452024],
[0.369214, 0.788888, 0.382914],
[0.515992, 0.831158, 0.294279],
[0.678489, 0.863742, 0.189503],
[0.845561, 0.887322, 0.099702],
[0.993248, 0.906157, 0.143936]
];
exports.blackWhite = blackWhite;
exports.createColorMap = createColorMap;

@@ -133,3 +108,2 @@ exports.createColorMapFromColorNodes = createColorMapFromColorNodes;

exports.linearScale = linearScale;
exports.viridis = viridis;

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

{
"name": "color-mapping",
"version": "1.0.0-0",
"version": "1.0.0-1",
"description": "Flexible library to map scalar values to colors",

@@ -5,0 +5,0 @@ "main": "dist/index.umd.js",

@@ -1,2 +0,3 @@

[![CircleCI](https://circleci.com/gh/alesgenova/color-mapping/tree/master.svg?style=svg)](https://circleci.com/gh/alesgenova/color-mapping/tree/master)
[![npm package](https://img.shields.io/npm/v/color-mapping.svg)](https://www.npmjs.com/package/color-mapping)
[![CircleCI](https://circleci.com/gh/alesgenova/color-mapping/tree/master.svg?style=shield)](https://circleci.com/gh/alesgenova/color-mapping/tree/master)
[![codecov](https://codecov.io/gh/alesgenova/color-mapping/branch/master/graph/badge.svg)](https://codecov.io/gh/alesgenova/color-mapping)

@@ -8,5 +9,42 @@

## Install
```
npm install -S color-mapping
```
## Basic Usage
```javascript
import { createColorMap, linearScale } from "color-mapping";
let colors = [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]
];
let domain = [0, 100];
let range = [0, 1];
let scale = linearScale(domain, range);
let colorMap = createColorMap(colors, scale);
let values = [0, 25, 50, 75, 100];
let output = values.map(v => colorMap(v));
// output is [[1,0,0], [0.5,0.5,0], [0,1,0], [0,0.5,0.5], [0,0,1]]
```
## Advanced Usage
The colors array doesn't necessarily need to span evenly the `[0, 1]` interval.
```javascript
import { createColorMap, linearScale } from "color-mapping";
let colors = [
{ value: -1.0, color: [0, 0, 1] },
{ value: 0.0, color: [1, 0, 0] },
{ value: 0.5, color: [0, 1, 0] },
{ value: 2.0, color: [0, 0, 1] }
];
let domain = [0, 100];
let range = [-1, 2];
let scale = linearScale(domain, range);
let colorMap = createColorMap(colors, scale);
let values = [0, 25, 50, 75, 100];
let output = values.map(v => colorMap(v));
// output is [[0,0,1], [0.75,0,0.25], [0,1,0], [0,0.5,0.5], [0,0,1]]
```
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