Socket
Socket
Sign inDemoInstall

@ctrl/tinycolor

Package Overview
Dependencies
0
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.6.0 to 3.6.1

2

dist/conversion.d.ts

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

import { HSL, HSV, Numberify, RGB } from './interfaces';
import { HSL, HSV, Numberify, RGB } from './interfaces.js';
/**

@@ -3,0 +3,0 @@ * Handle bounds / percentage checking to conform to CSS color spec

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.numberInputToObject = exports.parseIntFromHex = exports.convertHexToDecimal = exports.convertDecimalToHex = exports.rgbaToArgbHex = exports.rgbaToHex = exports.rgbToHex = exports.hsvToRgb = exports.rgbToHsv = exports.hslToRgb = exports.rgbToHsl = exports.rgbToRgb = void 0;
var util_1 = require("./util");
var util_js_1 = require("./util.js");
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:

@@ -15,5 +15,5 @@ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>

return {
r: (0, util_1.bound01)(r, 255) * 255,
g: (0, util_1.bound01)(g, 255) * 255,
b: (0, util_1.bound01)(b, 255) * 255,
r: (0, util_js_1.bound01)(r, 255) * 255,
g: (0, util_js_1.bound01)(g, 255) * 255,
b: (0, util_js_1.bound01)(b, 255) * 255,
};

@@ -28,5 +28,5 @@ }

function rgbToHsl(r, g, b) {
r = (0, util_1.bound01)(r, 255);
g = (0, util_1.bound01)(g, 255);
b = (0, util_1.bound01)(b, 255);
r = (0, util_js_1.bound01)(r, 255);
g = (0, util_js_1.bound01)(g, 255);
b = (0, util_js_1.bound01)(b, 255);
var max = Math.max(r, g, b);

@@ -90,5 +90,5 @@ var min = Math.min(r, g, b);

var b;
h = (0, util_1.bound01)(h, 360);
s = (0, util_1.bound01)(s, 100);
l = (0, util_1.bound01)(l, 100);
h = (0, util_js_1.bound01)(h, 360);
s = (0, util_js_1.bound01)(s, 100);
l = (0, util_js_1.bound01)(l, 100);
if (s === 0) {

@@ -117,5 +117,5 @@ // achromatic

function rgbToHsv(r, g, b) {
r = (0, util_1.bound01)(r, 255);
g = (0, util_1.bound01)(g, 255);
b = (0, util_1.bound01)(b, 255);
r = (0, util_js_1.bound01)(r, 255);
g = (0, util_js_1.bound01)(g, 255);
b = (0, util_js_1.bound01)(b, 255);
var max = Math.max(r, g, b);

@@ -156,5 +156,5 @@ var min = Math.min(r, g, b);

function hsvToRgb(h, s, v) {
h = (0, util_1.bound01)(h, 360) * 6;
s = (0, util_1.bound01)(s, 100);
v = (0, util_1.bound01)(v, 100);
h = (0, util_js_1.bound01)(h, 360) * 6;
s = (0, util_js_1.bound01)(s, 100);
v = (0, util_js_1.bound01)(v, 100);
var i = Math.floor(h);

@@ -180,5 +180,5 @@ var f = h - i;

var hex = [
(0, util_1.pad2)(Math.round(r).toString(16)),
(0, util_1.pad2)(Math.round(g).toString(16)),
(0, util_1.pad2)(Math.round(b).toString(16)),
(0, util_js_1.pad2)(Math.round(r).toString(16)),
(0, util_js_1.pad2)(Math.round(g).toString(16)),
(0, util_js_1.pad2)(Math.round(b).toString(16)),
];

@@ -204,6 +204,6 @@ // Return a 3 character hex if possible

var hex = [
(0, util_1.pad2)(Math.round(r).toString(16)),
(0, util_1.pad2)(Math.round(g).toString(16)),
(0, util_1.pad2)(Math.round(b).toString(16)),
(0, util_1.pad2)(convertDecimalToHex(a)),
(0, util_js_1.pad2)(Math.round(r).toString(16)),
(0, util_js_1.pad2)(Math.round(g).toString(16)),
(0, util_js_1.pad2)(Math.round(b).toString(16)),
(0, util_js_1.pad2)(convertDecimalToHex(a)),
];

@@ -227,6 +227,6 @@ // Return a 4 character hex if possible

var hex = [
(0, util_1.pad2)(convertDecimalToHex(a)),
(0, util_1.pad2)(Math.round(r).toString(16)),
(0, util_1.pad2)(Math.round(g).toString(16)),
(0, util_1.pad2)(Math.round(b).toString(16)),
(0, util_js_1.pad2)(convertDecimalToHex(a)),
(0, util_js_1.pad2)(Math.round(r).toString(16)),
(0, util_js_1.pad2)(Math.round(g).toString(16)),
(0, util_js_1.pad2)(Math.round(b).toString(16)),
];

@@ -233,0 +233,0 @@ return hex.join('');

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

import { HSL, HSLA, HSV, HSVA, RGB, RGBA } from './interfaces';
import { HSL, HSLA, HSV, HSVA, RGB, RGBA } from './interfaces.js';
/**

@@ -3,0 +3,0 @@ * Given a string or object, convert that input to RGB

@@ -5,5 +5,5 @@ "use strict";

/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
var conversion_1 = require("./conversion");
var css_color_names_1 = require("./css-color-names");
var util_1 = require("./util");
var conversion_js_1 = require("./conversion.js");
var css_color_names_js_1 = require("./css-color-names.js");
var util_js_1 = require("./util.js");
/**

@@ -40,3 +40,3 @@ * Given a string or object, convert that input to RGB

if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
rgb = (0, conversion_1.rgbToRgb)(color.r, color.g, color.b);
rgb = (0, conversion_js_1.rgbToRgb)(color.r, color.g, color.b);
ok = true;

@@ -46,5 +46,5 @@ format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';

else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
s = (0, util_1.convertToPercentage)(color.s);
v = (0, util_1.convertToPercentage)(color.v);
rgb = (0, conversion_1.hsvToRgb)(color.h, s, v);
s = (0, util_js_1.convertToPercentage)(color.s);
v = (0, util_js_1.convertToPercentage)(color.v);
rgb = (0, conversion_js_1.hsvToRgb)(color.h, s, v);
ok = true;

@@ -54,5 +54,5 @@ format = 'hsv';

else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
s = (0, util_1.convertToPercentage)(color.s);
l = (0, util_1.convertToPercentage)(color.l);
rgb = (0, conversion_1.hslToRgb)(color.h, s, l);
s = (0, util_js_1.convertToPercentage)(color.s);
l = (0, util_js_1.convertToPercentage)(color.l);
rgb = (0, conversion_js_1.hslToRgb)(color.h, s, l);
ok = true;

@@ -65,3 +65,3 @@ format = 'hsl';

}
a = (0, util_1.boundAlpha)(a);
a = (0, util_js_1.boundAlpha)(a);
return {

@@ -111,4 +111,4 @@ ok: ok,

var named = false;
if (css_color_names_1.names[color]) {
color = css_color_names_1.names[color];
if (css_color_names_js_1.names[color]) {
color = css_color_names_js_1.names[color];
named = true;

@@ -150,6 +150,6 @@ }

return {
r: (0, conversion_1.parseIntFromHex)(match[1]),
g: (0, conversion_1.parseIntFromHex)(match[2]),
b: (0, conversion_1.parseIntFromHex)(match[3]),
a: (0, conversion_1.convertHexToDecimal)(match[4]),
r: (0, conversion_js_1.parseIntFromHex)(match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3]),
a: (0, conversion_js_1.convertHexToDecimal)(match[4]),
format: named ? 'name' : 'hex8',

@@ -161,5 +161,5 @@ };

return {
r: (0, conversion_1.parseIntFromHex)(match[1]),
g: (0, conversion_1.parseIntFromHex)(match[2]),
b: (0, conversion_1.parseIntFromHex)(match[3]),
r: (0, conversion_js_1.parseIntFromHex)(match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3]),
format: named ? 'name' : 'hex',

@@ -171,6 +171,6 @@ };

return {
r: (0, conversion_1.parseIntFromHex)(match[1] + match[1]),
g: (0, conversion_1.parseIntFromHex)(match[2] + match[2]),
b: (0, conversion_1.parseIntFromHex)(match[3] + match[3]),
a: (0, conversion_1.convertHexToDecimal)(match[4] + match[4]),
r: (0, conversion_js_1.parseIntFromHex)(match[1] + match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2] + match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3] + match[3]),
a: (0, conversion_js_1.convertHexToDecimal)(match[4] + match[4]),
format: named ? 'name' : 'hex8',

@@ -182,5 +182,5 @@ };

return {
r: (0, conversion_1.parseIntFromHex)(match[1] + match[1]),
g: (0, conversion_1.parseIntFromHex)(match[2] + match[2]),
b: (0, conversion_1.parseIntFromHex)(match[3] + match[3]),
r: (0, conversion_js_1.parseIntFromHex)(match[1] + match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2] + match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3] + match[3]),
format: named ? 'name' : 'hex',

@@ -187,0 +187,0 @@ };

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

import { TinyColor } from './index';
import { TinyColor } from './index.js';
export interface RatioInput {

@@ -3,0 +3,0 @@ r: number | string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.legacyRandom = exports.fromRatio = void 0;
var index_1 = require("./index");
var util_1 = require("./util");
var index_js_1 = require("./index.js");
var util_js_1 = require("./util.js");
/**

@@ -12,5 +12,5 @@ * If input is an object, force 1 into "1.0" to handle ratios properly

var newColor = {
r: (0, util_1.convertToPercentage)(ratio.r),
g: (0, util_1.convertToPercentage)(ratio.g),
b: (0, util_1.convertToPercentage)(ratio.b),
r: (0, util_js_1.convertToPercentage)(ratio.r),
g: (0, util_js_1.convertToPercentage)(ratio.g),
b: (0, util_js_1.convertToPercentage)(ratio.b),
};

@@ -20,3 +20,3 @@ if (ratio.a !== undefined) {

}
return new index_1.TinyColor(newColor, opts);
return new index_js_1.TinyColor(newColor, opts);
}

@@ -26,3 +26,3 @@ exports.fromRatio = fromRatio;

function legacyRandom() {
return new index_1.TinyColor({
return new index_js_1.TinyColor({
r: Math.random(),

@@ -29,0 +29,0 @@ g: Math.random(),

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

import { HSL, HSLA, HSV, HSVA, Numberify, RGB, RGBA } from './interfaces';
import { HSL, HSLA, HSV, HSVA, Numberify, RGB, RGBA } from './interfaces.js';
export interface TinyColorOptions {

@@ -3,0 +3,0 @@ format: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tinycolor = exports.TinyColor = void 0;
var conversion_1 = require("./conversion");
var css_color_names_1 = require("./css-color-names");
var conversion_js_1 = require("./conversion.js");
var css_color_names_js_1 = require("./css-color-names.js");
var format_input_1 = require("./format-input");
var util_1 = require("./util");
var util_js_1 = require("./util.js");
var TinyColor = /** @class */ (function () {

@@ -19,3 +19,3 @@ function TinyColor(color, opts) {

if (typeof color === 'number') {
color = (0, conversion_1.numberInputToObject)(color);
color = (0, conversion_js_1.numberInputToObject)(color);
}

@@ -108,3 +108,3 @@ this.originalInput = color;

TinyColor.prototype.setAlpha = function (alpha) {
this.a = (0, util_1.boundAlpha)(alpha);
this.a = (0, util_js_1.boundAlpha)(alpha);
this.roundA = Math.round(100 * this.a) / 100;

@@ -124,3 +124,3 @@ return this;

TinyColor.prototype.toHsv = function () {
var hsv = (0, conversion_1.rgbToHsv)(this.r, this.g, this.b);
var hsv = (0, conversion_js_1.rgbToHsv)(this.r, this.g, this.b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };

@@ -133,3 +133,3 @@ };

TinyColor.prototype.toHsvString = function () {
var hsv = (0, conversion_1.rgbToHsv)(this.r, this.g, this.b);
var hsv = (0, conversion_js_1.rgbToHsv)(this.r, this.g, this.b);
var h = Math.round(hsv.h * 360);

@@ -144,3 +144,3 @@ var s = Math.round(hsv.s * 100);

TinyColor.prototype.toHsl = function () {
var hsl = (0, conversion_1.rgbToHsl)(this.r, this.g, this.b);
var hsl = (0, conversion_js_1.rgbToHsl)(this.r, this.g, this.b);
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };

@@ -153,3 +153,3 @@ };

TinyColor.prototype.toHslString = function () {
var hsl = (0, conversion_1.rgbToHsl)(this.r, this.g, this.b);
var hsl = (0, conversion_js_1.rgbToHsl)(this.r, this.g, this.b);
var h = Math.round(hsl.h * 360);

@@ -166,3 +166,3 @@ var s = Math.round(hsl.s * 100);

if (allow3Char === void 0) { allow3Char = false; }
return (0, conversion_1.rgbToHex)(this.r, this.g, this.b, allow3Char);
return (0, conversion_js_1.rgbToHex)(this.r, this.g, this.b, allow3Char);
};

@@ -183,3 +183,3 @@ /**

if (allow4Char === void 0) { allow4Char = false; }
return (0, conversion_1.rgbaToHex)(this.r, this.g, this.b, this.a, allow4Char);
return (0, conversion_js_1.rgbaToHex)(this.r, this.g, this.b, this.a, allow4Char);
};

@@ -227,3 +227,3 @@ /**

TinyColor.prototype.toPercentageRgb = function () {
var fmt = function (x) { return "".concat(Math.round((0, util_1.bound01)(x, 255) * 100), "%"); };
var fmt = function (x) { return "".concat(Math.round((0, util_js_1.bound01)(x, 255) * 100), "%"); };
return {

@@ -240,3 +240,3 @@ r: fmt(this.r),

TinyColor.prototype.toPercentageRgbString = function () {
var rnd = function (x) { return Math.round((0, util_1.bound01)(x, 255) * 100); };
var rnd = function (x) { return Math.round((0, util_js_1.bound01)(x, 255) * 100); };
return this.a === 1

@@ -256,4 +256,4 @@ ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)")

}
var hex = '#' + (0, conversion_1.rgbToHex)(this.r, this.g, this.b, false);
for (var _i = 0, _a = Object.entries(css_color_names_1.names); _i < _a.length; _i++) {
var hex = '#' + (0, conversion_js_1.rgbToHex)(this.r, this.g, this.b, false);
for (var _i = 0, _a = Object.entries(css_color_names_js_1.names); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];

@@ -323,3 +323,3 @@ if (hex === value) {

hsl.l += amount / 100;
hsl.l = (0, util_1.clamp01)(hsl.l);
hsl.l = (0, util_js_1.clamp01)(hsl.l);
return new TinyColor(hsl);

@@ -348,3 +348,3 @@ };

hsl.l -= amount / 100;
hsl.l = (0, util_1.clamp01)(hsl.l);
hsl.l = (0, util_js_1.clamp01)(hsl.l);
return new TinyColor(hsl);

@@ -379,3 +379,3 @@ };

hsl.s -= amount / 100;
hsl.s = (0, util_1.clamp01)(hsl.s);
hsl.s = (0, util_js_1.clamp01)(hsl.s);
return new TinyColor(hsl);

@@ -391,3 +391,3 @@ };

hsl.s += amount / 100;
hsl.s = (0, util_1.clamp01)(hsl.s);
hsl.s = (0, util_js_1.clamp01)(hsl.s);
return new TinyColor(hsl);

@@ -394,0 +394,0 @@ };

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

import { bound01, pad2 } from './util';
import { bound01, pad2 } from './util.js';
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:

@@ -3,0 +3,0 @@ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>

/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
import { convertHexToDecimal, hslToRgb, hsvToRgb, parseIntFromHex, rgbToRgb } from './conversion';
import { names } from './css-color-names';
import { boundAlpha, convertToPercentage } from './util';
import { convertHexToDecimal, hslToRgb, hsvToRgb, parseIntFromHex, rgbToRgb, } from './conversion.js';
import { names } from './css-color-names.js';
import { boundAlpha, convertToPercentage } from './util.js';
/**

@@ -6,0 +6,0 @@ * Given a string or object, convert that input to RGB

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

import { TinyColor } from './index';
import { convertToPercentage } from './util';
import { TinyColor } from './index.js';
import { convertToPercentage } from './util.js';
/**

@@ -4,0 +4,0 @@ * If input is an object, force 1 into "1.0" to handle ratios properly

@@ -1,5 +0,5 @@

import { numberInputToObject, rgbaToHex, rgbToHex, rgbToHsl, rgbToHsv } from './conversion';
import { names } from './css-color-names';
import { numberInputToObject, rgbaToHex, rgbToHex, rgbToHsl, rgbToHsv } from './conversion.js';
import { names } from './css-color-names.js';
import { inputToRGB } from './format-input';
import { bound01, boundAlpha, clamp01 } from './util';
import { bound01, boundAlpha, clamp01 } from './util.js';
var TinyColor = /** @class */ (function () {

@@ -6,0 +6,0 @@ function TinyColor(color, opts) {

@@ -1,12 +0,12 @@

import { tinycolor } from './index';
export * from './index';
export * from './css-color-names';
export * from './readability';
export * from './to-ms-filter';
export * from './from-ratio';
export * from './format-input';
export * from './random';
export * from './interfaces';
export * from './conversion';
import { tinycolor } from './index.js';
export * from './index.js';
export * from './css-color-names.js';
export * from './readability.js';
export * from './to-ms-filter.js';
export * from './from-ratio.js';
export * from './format-input.js';
export * from './random.js';
export * from './interfaces.js';
export * from './conversion.js';
// kept for backwards compatability with v1
export default tinycolor;
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
// randomColor by David Merfield under the CC0 license
// https://github.com/davidmerfield/randomColor/
import { TinyColor } from './index';
import { TinyColor } from './index.js';
export function random(options) {

@@ -6,0 +6,0 @@ if (options === void 0) { options = {}; }

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

import { TinyColor } from './index';
import { TinyColor } from './index.js';
// Readability Functions

@@ -3,0 +3,0 @@ // ---------------------

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

import { rgbaToArgbHex } from './conversion';
import { TinyColor } from './index';
import { rgbaToArgbHex } from './conversion.js';
import { TinyColor } from './index.js';
/**

@@ -4,0 +4,0 @@ * Returns the color represented as a Microsoft filter for use in old versions of IE.

@@ -1,8 +0,8 @@

import { names } from './css-color-names';
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input';
import { fromRatio, legacyRandom } from './from-ratio';
import { TinyColor, tinycolor } from './index';
import { random } from './random';
import { mostReadable, readability } from './readability';
import { toMsFilter } from './to-ms-filter';
import { names } from './css-color-names.js';
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input.js';
import { fromRatio, legacyRandom } from './from-ratio.js';
import { TinyColor, tinycolor } from './index.js';
import { random } from './random.js';
import { mostReadable, readability } from './readability.js';
import { toMsFilter } from './to-ms-filter.js';
var tinycolorumd = tinycolor;

@@ -9,0 +9,0 @@ tinycolorumd.TinyColor = TinyColor;

@@ -1,11 +0,11 @@

import { tinycolor } from './index';
export * from './index';
export * from './css-color-names';
export * from './readability';
export * from './to-ms-filter';
export * from './from-ratio';
export * from './format-input';
export * from './random';
export * from './interfaces';
export * from './conversion';
import { tinycolor } from './index.js';
export * from './index.js';
export * from './css-color-names.js';
export * from './readability.js';
export * from './to-ms-filter.js';
export * from './from-ratio.js';
export * from './format-input.js';
export * from './random.js';
export * from './interfaces.js';
export * from './conversion.js';
export default tinycolor;

@@ -17,13 +17,13 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("./index");
__exportStar(require("./index"), exports);
__exportStar(require("./css-color-names"), exports);
__exportStar(require("./readability"), exports);
__exportStar(require("./to-ms-filter"), exports);
__exportStar(require("./from-ratio"), exports);
__exportStar(require("./format-input"), exports);
__exportStar(require("./random"), exports);
__exportStar(require("./interfaces"), exports);
__exportStar(require("./conversion"), exports);
var index_js_1 = require("./index.js");
__exportStar(require("./index.js"), exports);
__exportStar(require("./css-color-names.js"), exports);
__exportStar(require("./readability.js"), exports);
__exportStar(require("./to-ms-filter.js"), exports);
__exportStar(require("./from-ratio.js"), exports);
__exportStar(require("./format-input.js"), exports);
__exportStar(require("./random.js"), exports);
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./conversion.js"), exports);
// kept for backwards compatability with v1
exports.default = index_1.tinycolor;
exports.default = index_js_1.tinycolor;

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

import { TinyColor } from './index';
import { TinyColor } from './index.js';
export interface RandomOptions {

@@ -3,0 +3,0 @@ seed?: number;

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

// https://github.com/davidmerfield/randomColor/
var index_1 = require("./index");
var index_js_1 = require("./index.js");
function random(options) {

@@ -41,3 +41,3 @@ if (options === void 0) { options = {}; }

// Then we return the HSB color in the desired format
return new index_1.TinyColor(res);
return new index_js_1.TinyColor(res);
}

@@ -127,3 +127,3 @@ exports.random = random;

}
var parsed = new index_1.TinyColor(colorInput);
var parsed = new index_js_1.TinyColor(colorInput);
if (parsed.isValid) {

@@ -130,0 +130,0 @@ var hue = parsed.toHsv().h;

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

import { ColorInput, TinyColor } from './index';
import { ColorInput, TinyColor } from './index.js';
/**

@@ -3,0 +3,0 @@ * AKA `contrast`

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mostReadable = exports.isReadable = exports.readability = void 0;
var index_1 = require("./index");
var index_js_1 = require("./index.js");
// Readability Functions

@@ -14,4 +14,4 @@ // ---------------------

function readability(color1, color2) {
var c1 = new index_1.TinyColor(color1);
var c2 = new index_1.TinyColor(color2);
var c1 = new index_js_1.TinyColor(color1);
var c2 = new index_js_1.TinyColor(color2);
return ((Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) /

@@ -78,3 +78,3 @@ (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05));

bestScore = score;
bestColor = new index_1.TinyColor(color);
bestColor = new index_js_1.TinyColor(color);
}

@@ -81,0 +81,0 @@ }

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

import { ColorInput } from './index';
import { ColorInput } from './index.js';
/**

@@ -3,0 +3,0 @@ * Returns the color represented as a Microsoft filter for use in old versions of IE.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMsFilter = void 0;
var conversion_1 = require("./conversion");
var index_1 = require("./index");
var conversion_js_1 = require("./conversion.js");
var index_js_1 = require("./index.js");
/**

@@ -10,9 +10,9 @@ * Returns the color represented as a Microsoft filter for use in old versions of IE.

function toMsFilter(firstColor, secondColor) {
var color = new index_1.TinyColor(firstColor);
var hex8String = '#' + (0, conversion_1.rgbaToArgbHex)(color.r, color.g, color.b, color.a);
var color = new index_js_1.TinyColor(firstColor);
var hex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(color.r, color.g, color.b, color.a);
var secondHex8String = hex8String;
var gradientType = color.gradientType ? 'GradientType = 1, ' : '';
if (secondColor) {
var s = new index_1.TinyColor(secondColor);
secondHex8String = '#' + (0, conversion_1.rgbaToArgbHex)(s.r, s.g, s.b, s.a);
var s = new index_js_1.TinyColor(secondColor);
secondHex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(s.r, s.g, s.b, s.a);
}

@@ -19,0 +19,0 @@ return "progid:DXImageTransform.Microsoft.gradient(".concat(gradientType, "startColorstr=").concat(hex8String, ",endColorstr=").concat(secondHex8String, ")");

@@ -1,8 +0,8 @@

import { names } from './css-color-names';
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input';
import { fromRatio, legacyRandom } from './from-ratio';
import { TinyColor } from './index';
import { random } from './random';
import { mostReadable, readability } from './readability';
import { toMsFilter } from './to-ms-filter';
import { names } from './css-color-names.js';
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input.js';
import { fromRatio, legacyRandom } from './from-ratio.js';
import { TinyColor } from './index.js';
import { random } from './random.js';
import { mostReadable, readability } from './readability.js';
import { toMsFilter } from './to-ms-filter.js';
export interface TinyColorUMD {

@@ -9,0 +9,0 @@ (): TinyColor;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var css_color_names_1 = require("./css-color-names");
var format_input_1 = require("./format-input");
var from_ratio_1 = require("./from-ratio");
var index_1 = require("./index");
var random_1 = require("./random");
var readability_1 = require("./readability");
var to_ms_filter_1 = require("./to-ms-filter");
var tinycolorumd = index_1.tinycolor;
tinycolorumd.TinyColor = index_1.TinyColor;
tinycolorumd.readability = readability_1.readability;
tinycolorumd.mostReadable = readability_1.mostReadable;
tinycolorumd.random = random_1.random;
tinycolorumd.names = css_color_names_1.names;
tinycolorumd.fromRatio = from_ratio_1.fromRatio;
tinycolorumd.legacyRandom = from_ratio_1.legacyRandom;
tinycolorumd.toMsFilter = to_ms_filter_1.toMsFilter;
tinycolorumd.inputToRGB = format_input_1.inputToRGB;
tinycolorumd.stringInputToObject = format_input_1.stringInputToObject;
tinycolorumd.isValidCSSUnit = format_input_1.isValidCSSUnit;
var css_color_names_js_1 = require("./css-color-names.js");
var format_input_js_1 = require("./format-input.js");
var from_ratio_js_1 = require("./from-ratio.js");
var index_js_1 = require("./index.js");
var random_js_1 = require("./random.js");
var readability_js_1 = require("./readability.js");
var to_ms_filter_js_1 = require("./to-ms-filter.js");
var tinycolorumd = index_js_1.tinycolor;
tinycolorumd.TinyColor = index_js_1.TinyColor;
tinycolorumd.readability = readability_js_1.readability;
tinycolorumd.mostReadable = readability_js_1.mostReadable;
tinycolorumd.random = random_js_1.random;
tinycolorumd.names = css_color_names_js_1.names;
tinycolorumd.fromRatio = from_ratio_js_1.fromRatio;
tinycolorumd.legacyRandom = from_ratio_js_1.legacyRandom;
tinycolorumd.toMsFilter = to_ms_filter_js_1.toMsFilter;
tinycolorumd.inputToRGB = format_input_js_1.inputToRGB;
tinycolorumd.stringInputToObject = format_input_js_1.stringInputToObject;
tinycolorumd.isValidCSSUnit = format_input_js_1.isValidCSSUnit;
exports.default = tinycolorumd;
{
"name": "@ctrl/tinycolor",
"version": "3.6.0",
"version": "3.6.1",
"description": "Fast, small color manipulation and conversion for JavaScript",

@@ -61,3 +61,6 @@ "author": "Scott Cooper <scttcper@gmail.com>",

"testEnvironment": "node",
"coverageProvider": "v8"
"coverageProvider": "v8",
"moduleNameMapper": {
"(.+)\\.js": "$1"
}
},

@@ -64,0 +67,0 @@ "babel": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc