New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.7.2-alpha to 0.7.3-alpha

19

dist/Colors.d.ts
import { newColorArgs, colorType } from './ColorType';
export declare class rgbNormalized extends colorType {
protected type: string;
r: number;

@@ -12,2 +13,3 @@ g: number;

export declare class hex extends colorType {
protected type: string;
hex: string;

@@ -20,2 +22,3 @@ constructor(hex: string | number);

export declare class rgb extends colorType {
protected type: string;
r: number;

@@ -32,2 +35,3 @@ g: number;

export declare class rec709rgb extends colorType {
protected type: string;
r: number;

@@ -45,2 +49,3 @@ g: number;

export declare class rec2020rgb extends colorType {
protected type: string;
r: number;

@@ -58,2 +63,3 @@ g: number;

export declare class hsv extends colorType {
protected type: string;
h: number;

@@ -70,2 +76,3 @@ s: number;

export declare class hsl extends colorType {
protected type: string;
h: number;

@@ -82,2 +89,3 @@ s: number;

export declare class hsi extends colorType {
protected type: string;
h: number;

@@ -93,2 +101,3 @@ s: number;

export declare class hsp extends colorType {
protected type: string;
h: number;

@@ -107,2 +116,3 @@ s: number;

export declare class cmyk extends colorType {
protected type: string;
c: number;

@@ -118,2 +128,3 @@ m: number;

export declare class yiq extends colorType {
protected type: string;
y: number;

@@ -137,2 +148,3 @@ i: number;

export declare class xyz extends colorType {
protected type: string;
x: number;

@@ -147,2 +159,3 @@ y: number;

export declare class xyy extends colorType {
protected type: string;
x: number;

@@ -158,2 +171,3 @@ y: number;

export declare class lab extends colorType {
protected type: string;
l: number;

@@ -175,2 +189,3 @@ a: number;

export declare class luv extends colorType {
protected type: string;
l: number;

@@ -192,2 +207,3 @@ u: number;

export declare class ypbpr extends colorType {
protected type: string;
y: number;

@@ -205,2 +221,3 @@ pb: number;

export declare class ycbcr extends colorType {
protected type: string;
y: number;

@@ -220,2 +237,3 @@ cb: number;

export declare class nm extends colorType {
protected type: string;
wavelength: number;

@@ -227,2 +245,3 @@ constructor(wavelength: number);

export declare class kelvin extends colorType {
protected type: string;
k: number;

@@ -229,0 +248,0 @@ constructor(k: number);

@@ -44,2 +44,3 @@ "use strict";

var _this = _super.call(this) || this;
_this.type = 'rgbNormalized';
_this.valueRangeCheck(r, 0, 1);

@@ -69,2 +70,3 @@ _this.valueRangeCheck(g, 0, 1);

var _this = _super.call(this) || this;
_this.type = 'hex';
if (typeof hex === 'string') {

@@ -112,2 +114,3 @@ if (hex.charAt(0) == '#') {

var _this = _super.call(this) || this;
_this.type = 'rgb';
_this.valueRangeCheck(bitDepth, 1, false, 'Bit depth must be a positive number greater than 1');

@@ -149,2 +152,3 @@ var max = Math.pow(2, bitDepth) - 1;

var _this = _super.call(this) || this;
_this.type = 'rec709rgb';
if (bitDepth != 8 && bitDepth != 10) {

@@ -198,2 +202,3 @@ throw new Error('Invalid bitrate for Rec709, must be 8 or 10');

var _this = _super.call(this) || this;
_this.type = 'rec2020rgb';
if (bitDepth != 10 && bitDepth != 12) {

@@ -247,2 +252,3 @@ throw new Error('Invalid bitrate for Rec2020, must be 10 or 12');

var _this = _super.call(this) || this;
_this.type = 'hsv';
_this.valueRangeCheck(h, 0, 360);

@@ -284,2 +290,3 @@ _this.valueRangeCheck(s, 0, 100);

var _this = _super.call(this) || this;
_this.type = 'hsl';
_this.valueRangeCheck(h, 0, 360);

@@ -321,2 +328,3 @@ _this.valueRangeCheck(s, 0, 100);

var _this = _super.call(this) || this;
_this.type = 'hsi';
_this.valueRangeCheck(h, 0, 360);

@@ -363,2 +371,3 @@ _this.valueRangeCheck(s, 0, 100);

var _this = _super.call(this) || this;
_this.type = 'hsp';
_this.valueRangeCheck(h, 0, 360);

@@ -402,2 +411,3 @@ _this.valueRangeCheck(s, 0, 100);

var _this = _super.call(this) || this;
_this.type = 'cmyk';
_this.valueRangeCheck(c, 0, 100, 'CMYK values must be between 0 and 100');

@@ -444,2 +454,3 @@ _this.valueRangeCheck(m, 0, 100, 'CMYK values must be between 0 and 100');

var _this = _super.call(this) || this;
_this.type = 'yiq';
if (normalized) {

@@ -482,2 +493,3 @@ _this.valueRangeCheck(y, 0, 255, 'Normalized Y value must be between 0 and 255');

var _this = _super.call(this) || this;
_this.type = 'xyz';
// this.valueRangeCheck(x, 0, 1, 'XYZ values must be between 0 and 1')

@@ -507,2 +519,3 @@ // this.valueRangeCheck(y, 0, 1, 'XYZ values must be between 0 and 1')

var _this = _super.call(this) || this;
_this.type = 'xyy';
_this.x = x;

@@ -538,2 +551,3 @@ _this.y = y;

var _this = _super.call(this) || this;
_this.type = 'lab';
_this.valueRangeCheck(l, 0, 100);

@@ -579,2 +593,3 @@ if (typeof a === 'undefined')

var _this = _super.call(this) || this;
_this.type = 'luv';
_this.valueRangeCheck(l, 0, 100);

@@ -616,2 +631,3 @@ // this.valueRangeCheck(u, -100, 100)

var _this = _super.call(this) || this;
_this.type = 'ypbpr';
_this.valueRangeCheck(y, 0, 1);

@@ -655,2 +671,3 @@ _this.valueRangeCheck(pb, -0.5, 0.5);

var _this = _super.call(this) || this;
_this.type = 'ycbcr';
_this.y = y;

@@ -703,2 +720,3 @@ _this.cb = cb;

var _this = _super.call(this) || this;
_this.type = 'nm';
_this.valueRangeCheck(wavelength, 200, 800, 'Wavelength (in nm) must fall between 200 and 800');

@@ -721,2 +739,3 @@ _this.wavelength = wavelength;

var _this = _super.call(this) || this;
_this.type = 'kelvin';
_this.valueRangeCheck(k, 1000, 40000, 'Temperature must fall between 1000 and 40000');

@@ -723,0 +742,0 @@ _this.k = k;

2

dist/ColorType.d.ts

@@ -53,2 +53,3 @@ import * as Colors from './Colors';

constructor();
protected type: string;
bitDepth?: number;

@@ -69,2 +70,3 @@ normalized?: boolean;

to<T extends colorType>(type: string, args?: newColorArgs): T;
getType(): string;
modify<T extends colorType>(modification: string, args?: modifyArgs): T;

@@ -71,0 +73,0 @@ scheme<T extends colorType>(type: string, args?: schemeArgs): T[];

@@ -51,2 +51,3 @@ "use strict";

function colorType() {
this.type = 'colorType';
}

@@ -120,6 +121,12 @@ colorType.prototype.to = function (type, args) {

default:
throw new Error('Unable to find conversion path');
throw new Error('Unable to find conversion path from ' +
this.constructor.name +
' to ' +
type);
}
return to;
};
colorType.prototype.getType = function () {
return this.type;
};
colorType.prototype.modify = function (modification, args) {

@@ -489,3 +496,3 @@ modification = modification.toLowerCase();

if (!isFinite(value)) {
throw new Error('Invalid color value');
throw new Error('Invalid color value: ' + value);
}

@@ -499,3 +506,11 @@ if (lowerLimit !== false &&

(upperLimit !== false && value > upperLimit)) {
throw new Error(typeof msg !== 'undefined' ? msg : 'Color value out of range');
throw new Error(typeof msg !== 'undefined'
? msg
: 'Color value: ' +
value +
' out of range [' +
lowerLimit +
',' +
upperLimit +
']');
}

@@ -502,0 +517,0 @@ };

76

dist/Harmony.js

@@ -153,3 +153,3 @@ "use strict";

var nextV = Math.max(start - separation * i, 0);
scheme.push(new Colors.hsv(hsv.h, hsv.s, nextV, hsv.a).to(color.constructor.name, {
scheme.push(new Colors.hsv(hsv.h, hsv.s, nextV, hsv.a).to(color.getType(), {
round: round,

@@ -167,3 +167,3 @@ }));

var nextI = Math.max(start - separation * i, 0);
scheme.push(new Colors.hsi(hsi.h, hsi.s, nextI, hsi.a).to(color.constructor.name, {
scheme.push(new Colors.hsi(hsi.h, hsi.s, nextI, hsi.a).to(color.getType(), {
round: round,

@@ -181,3 +181,3 @@ }));

var nextP = Math.max(start - separation * i, 0);
scheme.push(new Colors.hsp(hsp.h, hsp.s, nextP, hsp.a).to(color.constructor.name, {
scheme.push(new Colors.hsp(hsp.h, hsp.s, nextP, hsp.a).to(color.getType(), {
round: round,

@@ -195,3 +195,3 @@ }));

var nextL = Math.max(start - separation * i, 0);
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL, hsl.a).to(color.constructor.name, {
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL, hsl.a).to(color.getType(), {
round: round,

@@ -211,3 +211,3 @@ }));

var bNext = Math.max(rgb.b - separation * i, 0);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.constructor.name, { round: round, bitDepth: rgb.bitDepth }));
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.getType(), { round: round, bitDepth: rgb.bitDepth }));
}

@@ -228,3 +228,3 @@ break;

var bNext = Math.max(rgb2.b - bSep * i, 0);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.constructor.name, { round: round, bitDepth: rgb2.bitDepth }));
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.getType(), { round: round, bitDepth: rgb2.bitDepth }));
}

@@ -248,3 +248,3 @@ break;

var nextK = Math.min(cmyk.k - kSep * i, 100);
scheme.push(new Colors.cmyk(nextC, nextM, nextY, nextK).to(color.constructor.name, {
scheme.push(new Colors.cmyk(nextC, nextM, nextY, nextK).to(color.getType(), {
round: round,

@@ -288,3 +288,3 @@ }));

var nextS = Math.min(startVS + separationVS * i, 100);
scheme.push(new Colors.hsv(hsv.h, nextS, nextV).to(color.constructor.name, {
scheme.push(new Colors.hsv(hsv.h, nextS, nextV).to(color.getType(), {
round: round,

@@ -305,3 +305,3 @@ }));

var nextS = Math.min(hsi.s + separationIS * i, 100);
scheme.push(new Colors.hsi(hsi.h, nextS, nextI).to(color.constructor.name, {
scheme.push(new Colors.hsi(hsi.h, nextS, nextI).to(color.getType(), {
round: round,

@@ -322,3 +322,3 @@ }));

var nextS = Math.min(hsp.s + separationPS * i, 100);
scheme.push(new Colors.hsp(hsp.h, nextS, nextP).to(color.constructor.name, {
scheme.push(new Colors.hsp(hsp.h, nextS, nextP).to(color.getType(), {
round: round,

@@ -336,3 +336,3 @@ }));

var nextL = Math.min(start + separation * i, 100);
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL).to(color.constructor.name, {
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL).to(color.getType(), {
round: round,

@@ -353,3 +353,3 @@ }));

var bNext = Math.min(rgb.b + separation * i, rgb.max);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.constructor.name, { round: round, bitDepth: rgb.bitDepth }));
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.getType(), { round: round, bitDepth: rgb.bitDepth }));
}

@@ -373,3 +373,3 @@ break;

var bNext = Math.min(rgb2.b + bSep * i, rgb2.max);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.constructor.name, { round: round, bitDepth: rgb2.bitDepth }));
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.getType(), { round: round, bitDepth: rgb2.bitDepth }));
}

@@ -393,3 +393,3 @@ break;

var nextK = Math.max(cmyk.k - kSep * i, 0);
scheme.push(new Colors.cmyk(nextC, nextM, nextY, nextK).to(color.constructor.name, {
scheme.push(new Colors.cmyk(nextC, nextM, nextY, nextK).to(color.getType(), {
round: round,

@@ -446,10 +446,10 @@ }));

var nextL = Math.max(sEnd + sSeparation * i, 0);
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL, hsl.a).to(color.constructor.name, {
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL, hsl.a).to(color.getType(), {
round: round,
}));
}
scheme.push(hsl.to(color.constructor.name, { round: round }));
scheme.push(hsl.to(color.getType(), { round: round }));
for (var i = 1; i <= colors; i++) {
var nextL = Math.min(hsl.l + tSeparation * i, 100);
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL, hsl.a).to(color.constructor.name, {
scheme.push(new Colors.hsl(hsl.h, hsl.s, nextL, hsl.a).to(color.getType(), {
round: round,

@@ -493,3 +493,3 @@ }));

var nextV = Math.min(Math.max(sEnd + sSeparation * i, 0), 100);
scheme.push(new Colors.hsv(hsv.h, hsv.s, nextV, hsv.a).to(color.constructor.name, {
scheme.push(new Colors.hsv(hsv.h, hsv.s, nextV, hsv.a).to(color.getType(), {
round: round,

@@ -501,3 +501,3 @@ }));

var nextTVS = Math.min(Math.max(hsv.s + separationTVS * i, 0), 100);
scheme.push(new Colors.hsv(hsv.h, nextTVS, nextV, hsv.a).to(color.constructor.name, {
scheme.push(new Colors.hsv(hsv.h, nextTVS, nextV, hsv.a).to(color.getType(), {
round: round,

@@ -540,11 +540,11 @@ }));

var nextI = Math.max(sEnd + sSeparation * i, 0);
scheme.push(new Colors.hsi(hsi.h, hsi.s, nextI, hsi.a).to(color.constructor.name, {
scheme.push(new Colors.hsi(hsi.h, hsi.s, nextI, hsi.a).to(color.getType(), {
round: round,
}));
}
scheme.push(hsi.to(color.constructor.name, { round: round }));
scheme.push(hsi.to(color.getType(), { round: round }));
for (var i = 1; i <= colors; i++) {
var nextI = Math.min(hsi.i + tSeparation * i, 100);
var nextTIS = Math.max(hsi.s + separationTIS * i, 0);
scheme.push(new Colors.hsi(hsi.h, nextTIS, nextI, hsi.a).to(color.constructor.name, {
scheme.push(new Colors.hsi(hsi.h, nextTIS, nextI, hsi.a).to(color.getType(), {
round: round,

@@ -586,3 +586,3 @@ }));

var nextP = Math.max(sEnd + sSeparation * i, 0);
scheme.push(new Colors.hsp(hsp.h, hsp.s, nextP, hsp.a).to(color.constructor.name, {
scheme.push(new Colors.hsp(hsp.h, hsp.s, nextP, hsp.a).to(color.getType(), {
round: round,

@@ -594,3 +594,3 @@ }));

var nextTPS = Math.max(hsp.s + separationTPS * i, 0);
scheme.push(new Colors.hsp(hsp.h, nextTPS, nextP, hsp.a).to(color.constructor.name, {
scheme.push(new Colors.hsp(hsp.h, nextTPS, nextP, hsp.a).to(color.getType(), {
round: round,

@@ -631,5 +631,5 @@ }));

var bNext = Math.max(rgb.b - sSeparation * i, 0);
scheme.unshift(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.constructor.name, { round: round, bitDepth: rgb.bitDepth }));
scheme.unshift(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.getType(), { round: round, bitDepth: rgb.bitDepth }));
}
scheme.push(rgb.to(color.constructor.name, { round: round }));
scheme.push(rgb.to(color.getType(), { round: round }));
for (var i = 1; i <= colors; i++) {

@@ -639,3 +639,3 @@ var rNext = Math.min(rgb.r + tSeparation * i, rgb.max);

var bNext = Math.min(rgb.b + tSeparation * i, rgb.max);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.constructor.name, { round: round, bitDepth: rgb.bitDepth }));
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb.a).to(color.getType(), { round: round, bitDepth: rgb.bitDepth }));
}

@@ -696,3 +696,3 @@ break;

var bNext = Math.min(Math.max(sBEnd + sBSep * i, 0), rgb2.max);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.constructor.name, {
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.getType(), {
round: round,

@@ -705,3 +705,3 @@ }));

var bNext = Math.min(Math.max(rgb2.b + tBSep * i, 0), rgb2.max);
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.constructor.name, {
scheme.push(new Colors.rgb(rNext, gNext, bNext, rgb2.a).to(color.getType(), {
round: round,

@@ -781,3 +781,3 @@ }));

var kNext = Math.min(Math.max(sKEnd - sKSep * i, 0), 100);
scheme.push(new Colors.cmyk(cNext, mNext, yNext, kNext).to(color.constructor.name, {
scheme.push(new Colors.cmyk(cNext, mNext, yNext, kNext).to(color.getType(), {
round: round,

@@ -791,3 +791,3 @@ }));

var kNext = Math.min(Math.max(cmyk.k - tKSep * i, 0), 100);
scheme.push(new Colors.cmyk(cNext, mNext, yNext, kNext).to(color.constructor.name, {
scheme.push(new Colors.cmyk(cNext, mNext, yNext, kNext).to(color.getType(), {
round: round,

@@ -823,25 +823,25 @@ }));

case 'rgba':
gradient.push(Modify_1.default.rgbBlend(color1.to('rgb', { round: false }), color2.to('rgb', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.rgbBlend(color1.to('rgb', { round: false }), color2.to('rgb', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;
case 'hsv':
case 'hsva':
gradient.push(Modify_1.default.hsvBlend(color1.to('hsv', { round: false }), color2.to('hsv', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.hsvBlend(color1.to('hsv', { round: false }), color2.to('hsv', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;
case 'hsl':
case 'hsla':
gradient.push(Modify_1.default.hslBlend(color1.to('hsl', { round: false }), color2.to('hsl', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.hslBlend(color1.to('hsl', { round: false }), color2.to('hsl', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;
case 'hsi':
case 'hsia':
gradient.push(Modify_1.default.hsiBlend(color1.to('hsi', { round: false }), color2.to('hsi', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.hsiBlend(color1.to('hsi', { round: false }), color2.to('hsi', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;
case 'hsp':
case 'hspa':
gradient.push(Modify_1.default.hspBlend(color1.to('hsp', { round: false }), color2.to('hsp', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.hspBlend(color1.to('hsp', { round: false }), color2.to('hsp', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;
case 'cmyk':
gradient.push(Modify_1.default.cmykBlend(color1.to('cmyk', { round: false }), color2.to('cmyk', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.cmykBlend(color1.to('cmyk', { round: false }), color2.to('cmyk', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;
case 'yiq':
gradient.push(Modify_1.default.yiqBlend(color1.to('yiq', { round: false }), color2.to('yiq', { round: false }), amount, false).to(color1.constructor.name, { round: round }));
gradient.push(Modify_1.default.yiqBlend(color1.to('yiq', { round: false }), color2.to('yiq', { round: false }), amount, false).to(color1.getType(), { round: round }));
break;

@@ -848,0 +848,0 @@ }

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

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

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

# <img src="https://reiniiriarios.github.io/chromaticity-color-utilities/assets/images/chromaticity-icon-01.png" width="26" height="26"> chromaticity-color-utilities
# <img src="https://reiniiriarios.github.io/chromaticity-color-utilities/img/chromaticity-icon-01.png" width="26" height="26"> chromaticity-color-utilities

@@ -64,3 +64,3 @@ ![downloads](https://img.shields.io/npm/dt/chromaticity-color-utilities)

Approaching complete-ish stage... Most tests pass.
Approaching complete-ish stage... All tests are passing.

@@ -70,2 +70,4 @@ ### Known Issues

- YCbCr validates only with a high tolerance. Not sure if floating point issue.
- shadetint(cmyk) seems to be reading distanceToWhite and distanceToBlack incorrectly
- shadetint(cmyk) oversaturates toward black when auto and closest bound is white

@@ -72,0 +74,0 @@ ## Documentation

Sorry, the diff of this file is too big to display

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