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

@ctrl/tinycolor

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ctrl/tinycolor - npm Package Compare versions

Comparing version 3.1.4 to 3.1.5

28

dist/conversion.js

@@ -44,9 +44,9 @@ "use strict";

case r:
h = ((g - b) / d) + (g < b ? 6 : 0);
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = ((b - r) / d) + 2;
h = (b - r) / d + 2;
break;
case b:
h = ((r - g) / d) + 4;
h = (r - g) / d + 4;
break;

@@ -69,3 +69,3 @@ default:

if (t < 1 / 6) {
return p + ((q - p) * (6 * t));
return p + (q - p) * (6 * t);
}

@@ -76,3 +76,3 @@ if (t < 1 / 2) {

if (t < 2 / 3) {
return p + ((q - p) * ((2 / 3) - t) * 6);
return p + (q - p) * (2 / 3 - t) * 6;
}

@@ -101,7 +101,7 @@ return p;

else {
const q = l < 0.5 ? (l * (1 + s)) : (l + s - (l * s));
const p = (2 * l) - q;
r = hue2rgb(p, q, h + (1 / 3));
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - (1 / 3));
b = hue2rgb(p, q, h - 1 / 3);
}

@@ -133,9 +133,9 @@ return { r: r * 255, g: g * 255, b: b * 255 };

case r:
h = ((g - b) / d) + (g < b ? 6 : 0);
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = ((b - r) / d) + 2;
h = (b - r) / d + 2;
break;
case b:
h = ((r - g) / d) + 4;
h = (r - g) / d + 4;
break;

@@ -163,4 +163,4 @@ default:

const p = v * (1 - s);
const q = v * (1 - (f * s));
const t = v * (1 - ((1 - f) * s));
const q = v * (1 - f * s);
const t = v * (1 - (1 - f) * s);
const mod = i % 6;

@@ -167,0 +167,0 @@ const r = [v, q, p, p, t, v][mod];

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

const rgb = this.toRgb();
return ((rgb.r * 299) + (rgb.g * 587) + (rgb.b * 114)) / 1000;
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
}

@@ -89,3 +89,3 @@ /**

}
return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
}

@@ -210,5 +210,5 @@ /**

const rnd = (x) => Math.round(util_1.bound01(x, 255) * 100);
return this.a === 1 ?
`rgb(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%)` :
`rgba(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%, ${this.roundA})`;
return this.a === 1
? `rgb(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%)`
: `rgba(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%, ${this.roundA})`;
}

@@ -282,3 +282,3 @@ /**

toNumber() {
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + (Math.round(this.b));
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
}

@@ -383,6 +383,6 @@ clone() {

const rgba = {
r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
a: ((rgb2.a - rgb1.a) * p) + rgb1.a,
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b,
a: (rgb2.a - rgb1.a) * p + rgb1.a,
};

@@ -453,3 +453,3 @@ return new TinyColor(rgba);

for (let i = 1; i < n; i++) {
result.push(new TinyColor({ h: (h + (i * increment)) % 360, s: hsl.s, l: hsl.l }));
result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
}

@@ -456,0 +456,0 @@ return result;

@@ -40,9 +40,9 @@ import { bound01, pad2 } from './util';

case r:
h = ((g - b) / d) + (g < b ? 6 : 0);
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = ((b - r) / d) + 2;
h = (b - r) / d + 2;
break;
case b:
h = ((r - g) / d) + 4;
h = (r - g) / d + 4;
break;

@@ -64,3 +64,3 @@ default:

if (t < 1 / 6) {
return p + ((q - p) * (6 * t));
return p + (q - p) * (6 * t);
}

@@ -71,3 +71,3 @@ if (t < 1 / 2) {

if (t < 2 / 3) {
return p + ((q - p) * ((2 / 3) - t) * 6);
return p + (q - p) * (2 / 3 - t) * 6;
}

@@ -96,7 +96,7 @@ return p;

else {
var q = l < 0.5 ? (l * (1 + s)) : (l + s - (l * s));
var p = (2 * l) - q;
r = hue2rgb(p, q, h + (1 / 3));
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - (1 / 3));
b = hue2rgb(p, q, h - 1 / 3);
}

@@ -127,9 +127,9 @@ return { r: r * 255, g: g * 255, b: b * 255 };

case r:
h = ((g - b) / d) + (g < b ? 6 : 0);
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = ((b - r) / d) + 2;
h = (b - r) / d + 2;
break;
case b:
h = ((r - g) / d) + 4;
h = (r - g) / d + 4;
break;

@@ -156,4 +156,4 @@ default:

var p = v * (1 - s);
var q = v * (1 - (f * s));
var t = v * (1 - ((1 - f) * s));
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
var mod = i % 6;

@@ -160,0 +160,0 @@ var r = [v, q, p, p, t, v][mod];

@@ -55,3 +55,3 @@ import { rgbaToHex, rgbToHex, rgbToHsl, rgbToHsv, numberInputToObject } from './conversion';

var rgb = this.toRgb();
return ((rgb.r * 299) + (rgb.g * 587) + (rgb.b * 114)) / 1000;
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
};

@@ -88,3 +88,3 @@ /**

}
return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
};

@@ -213,5 +213,5 @@ /**

var rnd = function (x) { return Math.round(bound01(x, 255) * 100); };
return this.a === 1 ?
"rgb(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%)" :
"rgba(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%, " + this.roundA + ")";
return this.a === 1
? "rgb(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%)"
: "rgba(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%, " + this.roundA + ")";
};

@@ -286,3 +286,3 @@ /**

TinyColor.prototype.toNumber = function () {
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + (Math.round(this.b));
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
};

@@ -395,6 +395,6 @@ TinyColor.prototype.clone = function () {

var rgba = {
r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
a: ((rgb2.a - rgb1.a) * p) + rgb1.a,
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b,
a: (rgb2.a - rgb1.a) * p + rgb1.a,
};

@@ -468,3 +468,3 @@ return new TinyColor(rgba);

for (var i = 1; i < n; i++) {
result.push(new TinyColor({ h: (h + (i * increment)) % 360, s: hsl.s, l: hsl.l }));
result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
}

@@ -471,0 +471,0 @@ return result;

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

export {};
//# sourceMappingURL=interfaces.js.map

@@ -7,3 +7,4 @@ // randomColor by David Merfield under the CC0 license

// Check if we need to generate multiple colors
if (options.count !== undefined && options.count !== null) {
if (options.count !== undefined &&
options.count !== null) {
var totalColors = options.count;

@@ -101,4 +102,4 @@ var colors = [];

var m = (v2 - v1) / (s2 - s1);
var b = v1 - (m * s1);
return (m * S) + b;
var b = v1 - m * s1;
return m * S + b;
}

@@ -145,3 +146,3 @@ }

if (seed === undefined) {
return Math.floor(range[0] + (Math.random() * (range[1] + 1 - range[0])));
return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0]));
}

@@ -151,5 +152,5 @@ // Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/

var min = range[0] || 0;
seed = ((seed * 9301) + 49297) % 233280;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280.0;
return Math.floor(min + (rnd * (max - min)));
return Math.floor(min + rnd * (max - min));
}

@@ -176,3 +177,6 @@ function defineColor(bound) {

hueRange: null,
lowerBounds: [[0, 0], [100, 0]],
lowerBounds: [
[0, 0],
[100, 0],
],
},

@@ -197,3 +201,11 @@ {

hueRange: [19, 46],
lowerBounds: [[20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70]],
lowerBounds: [
[20, 100],
[30, 93],
[40, 88],
[50, 86],
[60, 85],
[70, 70],
[100, 70],
],
},

@@ -203,3 +215,12 @@ {

hueRange: [47, 62],
lowerBounds: [[25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75]],
lowerBounds: [
[25, 100],
[40, 94],
[50, 89],
[60, 86],
[70, 84],
[80, 82],
[90, 80],
[100, 75],
],
},

@@ -209,3 +230,12 @@ {

hueRange: [63, 178],
lowerBounds: [[30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40]],
lowerBounds: [
[30, 100],
[40, 90],
[50, 85],
[60, 81],
[70, 74],
[80, 64],
[90, 50],
[100, 40],
],
},

@@ -245,5 +275,13 @@ {

hueRange: [283, 334],
lowerBounds: [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]],
lowerBounds: [
[20, 100],
[30, 90],
[40, 86],
[60, 84],
[80, 80],
[90, 75],
[100, 73],
],
},
];
//# sourceMappingURL=random.js.map

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

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,3 +9,4 @@ "use strict";

// Check if we need to generate multiple colors
if (options.count !== undefined && options.count !== null) {
if (options.count !== undefined &&
options.count !== null) {
const totalColors = options.count;

@@ -104,4 +105,4 @@ const colors = [];

const m = (v2 - v1) / (s2 - s1);
const b = v1 - (m * s1);
return (m * S) + b;
const b = v1 - m * s1;
return m * S + b;
}

@@ -147,3 +148,3 @@ }

if (seed === undefined) {
return Math.floor(range[0] + (Math.random() * (range[1] + 1 - range[0])));
return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0]));
}

@@ -153,5 +154,5 @@ // Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/

const min = range[0] || 0;
seed = ((seed * 9301) + 49297) % 233280;
seed = (seed * 9301 + 49297) % 233280;
const rnd = seed / 233280.0;
return Math.floor(min + (rnd * (max - min)));
return Math.floor(min + rnd * (max - min));
}

@@ -178,3 +179,6 @@ function defineColor(bound) {

hueRange: null,
lowerBounds: [[0, 0], [100, 0]],
lowerBounds: [
[0, 0],
[100, 0],
],
},

@@ -199,3 +203,11 @@ {

hueRange: [19, 46],
lowerBounds: [[20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70]],
lowerBounds: [
[20, 100],
[30, 93],
[40, 88],
[50, 86],
[60, 85],
[70, 70],
[100, 70],
],
},

@@ -205,3 +217,12 @@ {

hueRange: [47, 62],
lowerBounds: [[25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75]],
lowerBounds: [
[25, 100],
[40, 94],
[50, 89],
[60, 86],
[70, 84],
[80, 82],
[90, 80],
[100, 75],
],
},

@@ -211,3 +232,12 @@ {

hueRange: [63, 178],
lowerBounds: [[30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40]],
lowerBounds: [
[30, 100],
[40, 90],
[50, 85],
[60, 81],
[70, 74],
[80, 64],
[90, 50],
[100, 40],
],
},

@@ -247,5 +277,13 @@ {

hueRange: [283, 334],
lowerBounds: [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]],
lowerBounds: [
[20, 100],
[30, 90],
[40, 86],
[60, 84],
[80, 80],
[90, 75],
[100, 73],
],
},
];
//# sourceMappingURL=random.js.map
{
"name": "@ctrl/tinycolor",
"version": "3.1.4",
"version": "3.1.5",
"description": "Fast, small color manipulation and conversion for JavaScript",

@@ -41,24 +41,32 @@ "author": "Scott Cooper <scttcper@gmail.com>",

"devDependencies": {
"@ctrl/eslint-config": "1.0.5",
"@jest/globals": "26.3.0",
"@types/node": "14.0.27",
"@babel/plugin-transform-modules-commonjs": "7.10.4",
"@babel/preset-typescript": "7.10.4",
"@ctrl/eslint-config": "1.2.1",
"@jest/globals": "26.4.2",
"@types/node": "14.11.2",
"del-cli": "3.0.1",
"jest": "26.3.0",
"jest": "26.4.2",
"jest-junit": "11.1.0",
"rollup": "2.23.1",
"rollup-plugin-livereload": "1.3.0",
"rollup-plugin-serve": "1.0.3",
"rollup": "2.28.2",
"rollup-plugin-livereload": "2.0.0",
"rollup-plugin-serve": "1.0.4",
"rollup-plugin-sourcemaps": "0.6.2",
"rollup-plugin-terser": "7.0.0",
"rollup-plugin-typescript2": "0.27.2",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.27.3",
"rollup-plugin-uglify": "6.0.4",
"ts-node": "8.10.2",
"ts-jest": "26.1.4",
"typedoc": "0.18.0",
"typescript": "3.9.7"
"ts-node": "9.0.0",
"typedoc": "0.19.2",
"typescript": "4.0.3"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
},
"babel": {
"presets": [
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
},
"release": {

@@ -65,0 +73,0 @@ "branch": "master"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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