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

chromaticity-color-utilities

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromaticity-color-utilities - npm Package Compare versions

Comparing version 0.2.8-alpha to 0.2.9-alpha

6

dist/ColorType.js

@@ -19,3 +19,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,0 +26,0 @@ if (k2 === undefined) k2 = k;

@@ -136,3 +136,19 @@ import * as Colors from './Colors';

static hsi2hsl(hsi: Colors.hsi, round?: boolean): Colors.hsl;
/**
* Convert RGB to HSP
* Saturation and Perceived Brightness will be in percentages
*
* @param {Colors.rgb} rgb
* @param {boolean} [round=true]
* @return {Colors.hsp}
*/
static rgb2hsp(rgb: Colors.rgb, round?: boolean, Pb?: number, Pr?: number): Colors.hsp;
/**
* Convert HSP to RGB
* Saturation and Perceived Brightness should be in percentages
*
* @param {Colors.hsp} hsp
* @param {boolean} [round=true]
* @return {Colors.rgb}
*/
static hsp2rgb(hsp: Colors.hsp, round?: boolean, bitDepth?: number): Colors.rgb;

@@ -139,0 +155,0 @@ /**

39

dist/Convert.js

@@ -19,3 +19,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -230,3 +234,3 @@ if (k2 === undefined) k2 = k;

if (hsv.s == 0) {
var all = hsv.v;
var all = hsv.v / 100;
r = all;

@@ -511,3 +515,3 @@ g = all;

case 5:
r = chroma + x;
r = chroma + m;
g = m;

@@ -568,2 +572,10 @@ b = x + m;

};
/**
* Convert RGB to HSP
* Saturation and Perceived Brightness will be in percentages
*
* @param {Colors.rgb} rgb
* @param {boolean} [round=true]
* @return {Colors.hsp}
*/
Convert.rgb2hsp = function (rgb, round, Pb, Pr) {

@@ -612,2 +624,10 @@ if (round === void 0) { round = true; }

};
/**
* Convert HSP to RGB
* Saturation and Perceived Brightness should be in percentages
*
* @param {Colors.hsp} hsp
* @param {boolean} [round=true]
* @return {Colors.rgb}
*/
Convert.hsp2rgb = function (hsp, round, bitDepth) {

@@ -645,3 +665,3 @@ if (round === void 0) { round = true; }

hpp = -1 * hp + 4;
r = pb / Math.sqrt(hsp.pb / Math.pow(s0, 2) + hsp.pr * Math.pow(1 + hpp * (1 / s0 - 1), 2) + hsp.pr);
r = pb / Math.sqrt(hsp.pb / Math.pow(s0, 2) + hsp.pg * Math.pow(1 + hpp * (1 / s0 - 1), 2) + hsp.pr);
b = r / s0;

@@ -680,3 +700,3 @@ g = r + hpp * (b - r);

hpp = hp - 2;
g = Math.sqrt(Math.pow(pb, 2) / (hsp.pr + hsp.pg * Math.pow(hpp, 2)));
g = Math.sqrt(Math.pow(pb, 2) / (hsp.pg + hsp.pb * Math.pow(hpp, 2)));
b = g * hpp;

@@ -908,5 +928,2 @@ r = 0;

var z = m[2][0] * r + m[2][1] * g + m[2][2] * b;
x = Math.min(Math.max(x, 0), 1);
y = Math.min(Math.max(y, 0), 1);
z = Math.min(Math.max(z, 0), 1);
return new Colors.xyz(x, y, z);

@@ -943,5 +960,5 @@ };

// sRGB
r = r <= 0.0031308 ? r * 12.92 : Math.pow((r * 1.055), 1 / 2.4) - 0.055;
g = g <= 0.0031308 ? g * 12.92 : Math.pow((g * 1.055), 1 / 2.4) - 0.055;
b = b <= 0.0031308 ? b * 12.92 : Math.pow((b * 1.055), 1 / 2.4) - 0.055;
r = r <= 0.0031308 ? r * 12.92 : 1.055 * Math.pow(r, 1 / 2.4) - 0.055;
g = g <= 0.0031308 ? g * 12.92 : 1.055 * Math.pow(g, 1 / 2.4) - 0.055;
b = b <= 0.0031308 ? b * 12.92 : 1.055 * Math.pow(b, 1 / 2.4) - 0.055;
}

@@ -948,0 +965,0 @@ else if (colorSpace == 'ecirgb') {

@@ -19,3 +19,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,0 +26,0 @@ if (k2 === undefined) k2 = k;

@@ -19,3 +19,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,0 +26,0 @@ if (k2 === undefined) k2 = k;

@@ -19,3 +19,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,0 +26,0 @@ if (k2 === undefined) k2 = k;

{
"name": "chromaticity-color-utilities",
"version": "0.2.8-alpha",
"version": "0.2.9-alpha",
"description": "Color utilities for Node.js",

@@ -54,5 +54,4 @@ "main": "dist/main.js",

"nodemon": "^2.0.7",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
"ts-node": "^9.1.1"
}
}
# <img src="https://reiniiriarios.github.io/chromaticity-color-utilities/assets/images/chromaticity-icon-01.png" width="26" height="26"> chromaticity-color-utilities
![](https://img.shields.io/npm/dt/chromaticity-color-utilities) ![](https://img.shields.io/npm/types/chromaticity-color-utilities) ![](https://img.shields.io/badge/license-GPLv3-green)
Color utilities for Node.js.

@@ -7,2 +9,17 @@

```ts
const Color = require('chromaticity-color-utilities')
let color1 = Color.from('rgb',[255,128,0]).to('hsv')
let scheme1 = Color.from('hex',0x9A237F).modify('desaturate',{amount:0.2}).to('lab',{
colorSpace: 'AdobeRGB',
referenceWhite: 'D50'
}).scheme('gradient',{
with: Color.from('hsl',[300,50,45]),
colors: 5
})
```
## Install

@@ -22,4 +39,6 @@

## Usage
## Example Usage
See [documentation](https://reiniiriarios.github.io/chromaticity-color-utilities) for more details and usage examples.
Any color can be converted to any other, with only a few caveats. Construction `from()`, conversion `to()`, and modification `modify()` methods can be chained.

@@ -99,2 +118,3 @@

* YUV
* Gamma adjustment modification

@@ -101,0 +121,0 @@ * Auto-gamma adjustment and conversion for rec709, rec2020, and jpeg to/from ypbpr

Sorry, the diff of this file is not supported yet

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