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.8.0-alpha to 0.8.4-alpha

4

dist/ColorType.d.ts

@@ -78,6 +78,6 @@ import * as Colors from './Colors';

*
* @param {string} whitespace equiv to third JSON.stringify parameter
* @param {string | number} whitespace equiv to third JSON.stringify parameter
* @returns {string}
*/
toString(whitespace?: string, quotes?: boolean): string;
toString(whitespace?: string | number, quotes?: boolean): string;
to<T extends colorType>(type: string, args?: newColorArgs): T;

@@ -84,0 +84,0 @@ getType(): string;

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

*
* @param {string} whitespace equiv to third JSON.stringify parameter
* @param {string | number} whitespace equiv to third JSON.stringify parameter
* @returns {string}

@@ -228,3 +228,3 @@ */

default:
throw new Error('Unrecognized blending method');
throw new Error('Unrecognized blending method: ' + args.method);
}

@@ -279,3 +279,3 @@ break;

default:
throw new Error('Unrecognized darken method');
throw new Error('Unrecognized darken method: ' + args.method);
}

@@ -330,3 +330,3 @@ break;

default:
throw new Error('Unrecognized lighten method');
throw new Error('Unrecognized lighten method: ' + args.method);
}

@@ -350,4 +350,17 @@ break;

break;
case 'hsi':
case 'hsia':
case 'intensity':
modified = Modify_1.default.hsiDesaturate(this.tohsi({ round: false }), args.amount, args.round);
break;
case 'hsp':
case 'hspa':
case 'brightness':
case 'perceived brightness':
case 'perceived':
case 'perceivedbrightness':
modified = Modify_1.default.hspDesaturate(this.tohsp({ round: false }), args.amount, args.round);
break;
default:
throw new Error('Unrecognized desaturate method');
throw new Error('Unrecognized desaturate method: ' + args.method);
}

@@ -371,8 +384,21 @@ break;

break;
case 'hsi':
case 'hsia':
case 'intensity':
modified = Modify_1.default.hsiSaturate(this.tohsi({ round: false }), args.amount, args.round);
break;
case 'hsp':
case 'hspa':
case 'brightness':
case 'perceived brightness':
case 'perceived':
case 'perceivedbrightness':
modified = Modify_1.default.hspSaturate(this.tohsp({ round: false }), args.amount, args.round);
break;
default:
throw new Error('Unrecognized saturate method');
throw new Error('Unrecognized saturate method: ' + args.method);
}
break;
default:
throw new Error('Unrecognized modify action');
throw new Error('Unrecognized modify action: ' + modification);
}

@@ -379,0 +405,0 @@ var ogModified = modified.to(og, ogargs);

@@ -100,3 +100,7 @@ import * as Colors from './Colors';

static hsvSaturate(hsv: Colors.hsv, amount?: number, round?: boolean): Colors.hsv;
static hsiDesaturate(hsi: Colors.hsi, amount?: number, round?: boolean): Colors.hsi;
static hsiSaturate(hsi: Colors.hsi, amount?: number, round?: boolean): Colors.hsi;
static hspDesaturate(hsp: Colors.hsp, amount?: number, round?: boolean): Colors.hsp;
static hspSaturate(hsp: Colors.hsp, amount?: number, round?: boolean): Colors.hsp;
}
export = Modify;

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

if (round === void 0) { round = true; }
var realAmount = 1 - Math.min(Math.max(amount, 0), 1);
var realAmount = Math.min(Math.max(amount, 0), 1);
var c2 = cmyk.c + (100 - cmyk.c) * realAmount;

@@ -309,3 +309,3 @@ var m2 = cmyk.m + (100 - cmyk.m) * realAmount;

if (round === void 0) { round = true; }
var realAmount = Math.min(Math.max(amount, 0), 1);
var realAmount = 1 - Math.min(Math.max(amount, 0), 1);
var c2 = cmyk.c * realAmount;

@@ -375,5 +375,8 @@ var m2 = cmyk.m * realAmount;

var vLighter = hsv.v + (100 - hsv.v) * realAmount;
if (round)
var sLighter = (1 - realAmount) * 100;
if (round) {
vLighter = Math.round(vLighter);
return new Colors.hsv(hsv.h, hsv.s, vLighter, hsv.a);
sLighter = Math.round(sLighter);
}
return new Colors.hsv(hsv.h, sLighter, vLighter, hsv.a);
};

@@ -394,5 +397,8 @@ Modify.hsiDarken = function (hsi, amount, round) {

var vLighter = hsi.i + (100 - hsi.i) * realAmount;
if (round)
var sLighter = (1 - realAmount) * 100;
if (round) {
vLighter = Math.round(vLighter);
return new Colors.hsi(hsi.h, hsi.s, vLighter, hsi.a);
sLighter = Math.round(sLighter);
}
return new Colors.hsi(hsi.h, sLighter, vLighter, hsi.a);
};

@@ -413,5 +419,8 @@ Modify.hspDarken = function (hsp, amount, round) {

var pLighter = hsp.p + (100 - hsp.p) * realAmount;
if (round)
var sLighter = (1 - realAmount) * 100;
if (round) {
pLighter = Math.round(pLighter);
return new Colors.hsp(hsp.h, hsp.s, pLighter, hsp.a, hsp.pb, hsp.pr);
sLighter = Math.round(sLighter);
}
return new Colors.hsp(hsp.h, sLighter, pLighter, hsp.a, hsp.pb, hsp.pr);
};

@@ -430,3 +439,3 @@ Modify.hslDesaturate = function (hsl, amount, round) {

if (round === void 0) { round = true; }
var realAmount = 1 - Math.min(Math.max(amount, 0), 1);
var realAmount = Math.min(Math.max(amount, 0), 1);
var sMore = hsl.s + (100 - hsl.s) * realAmount;

@@ -449,3 +458,3 @@ if (round)

if (round === void 0) { round = true; }
var realAmount = 1 - Math.min(Math.max(amount, 0), 1);
var realAmount = Math.min(Math.max(amount, 0), 1);
var sMore = hsv.s + (100 - hsv.s) * realAmount;

@@ -456,4 +465,40 @@ if (round)

};
Modify.hsiDesaturate = function (hsi, amount, round) {
if (amount === void 0) { amount = 0.5; }
if (round === void 0) { round = true; }
var realAmount = 1 - Math.min(Math.max(amount, 0), 1);
var sLess = hsi.s * realAmount;
if (round)
sLess = Math.round(sLess);
return new Colors.hsi(hsi.h, sLess, hsi.i, hsi.a);
};
Modify.hsiSaturate = function (hsi, amount, round) {
if (amount === void 0) { amount = 0.5; }
if (round === void 0) { round = true; }
var realAmount = Math.min(Math.max(amount, 0), 1);
var sMore = hsi.s + (100 - hsi.s) * realAmount;
if (round)
sMore = Math.round(sMore);
return new Colors.hsi(hsi.h, sMore, hsi.i, hsi.a);
};
Modify.hspDesaturate = function (hsp, amount, round) {
if (amount === void 0) { amount = 0.5; }
if (round === void 0) { round = true; }
var realAmount = 1 - Math.min(Math.max(amount, 0), 1);
var sLess = hsp.s * realAmount;
if (round)
sLess = Math.round(sLess);
return new Colors.hsp(hsp.h, sLess, hsp.p, hsp.a);
};
Modify.hspSaturate = function (hsp, amount, round) {
if (amount === void 0) { amount = 0.5; }
if (round === void 0) { round = true; }
var realAmount = Math.min(Math.max(amount, 0), 1);
var sMore = hsp.s + (100 - hsp.s) * realAmount;
if (round)
sMore = Math.round(sMore);
return new Colors.hsp(hsp.h, sMore, hsp.p, hsp.a);
};
return Modify;
}());
module.exports = Modify;
{
"name": "chromaticity-color-utilities",
"version": "0.8.0-alpha",
"version": "0.8.4-alpha",
"description": "Color utilities for Node.js",

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

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