Socket
Socket
Sign inDemoInstall

@ant-design/fast-color

Package Overview
Dependencies
Maintainers
7
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ant-design/fast-color - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

39

es/FastColor.js

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

const round = Math.round;
/**

@@ -169,3 +171,3 @@ * Support format, alpha unit will check the % mark:

} else {
this._h = Math.round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
this._h = round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
}

@@ -249,7 +251,8 @@ }

const p = amount / 100;
const calc = key => (color[key] - this[key]) * p + this[key];
const rgba = {
r: (color.r - this.r) * p + this.r,
g: (color.g - this.g) * p + this.g,
b: (color.b - this.b) * p + this.b,
a: (color.a - this.a) * p + this.a
r: round(calc('r')),
g: round(calc('g')),
b: round(calc('b')),
a: round(calc('a') * 100) / 100
};

@@ -288,3 +291,3 @@ return this._c(rgba);

const calc = key => {
return Math.round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha);
return round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha);
};

@@ -325,3 +328,3 @@ return this._c({

if (typeof this.a === 'number' && this.a >= 0 && this.a < 1) {
const aHex = Math.round(this.a * 255).toString(16);
const aHex = round(this.a * 255).toString(16);
hex += aHex.length === 2 ? aHex : '0' + aHex;

@@ -345,4 +348,4 @@ }

const h = this.getHue();
const s = Math.round(this.getSaturation() * 100);
const l = Math.round(this.getLightness() * 100);
const s = round(this.getSaturation() * 100);
const l = round(this.getLightness() * 100);
return this.a !== 1 ? `hsla(${h},${s}%,${l}%,${this.a})` : `hsl(${h},${s}%,${l}%)`;

@@ -427,3 +430,3 @@ }

if (s <= 0) {
const rgb = Math.round(l * 255);
const rgb = round(l * 255);
this.r = rgb;

@@ -459,5 +462,5 @@ this.g = rgb;

const lightnessModification = l - chroma / 2;
this.r = Math.round((r + lightnessModification) * 255);
this.g = Math.round((g + lightnessModification) * 255);
this.b = Math.round((b + lightnessModification) * 255);
this.r = round((r + lightnessModification) * 255);
this.g = round((g + lightnessModification) * 255);
this.b = round((b + lightnessModification) * 255);
}

@@ -474,3 +477,3 @@ fromHsv({

this.a = typeof a === 'number' ? a : 1;
const vv = Math.round(v * 255);
const vv = round(v * 255);
this.r = vv;

@@ -485,5 +488,5 @@ this.g = vv;

const ff = hh - i;
const p = Math.round(v * (1.0 - s) * 255);
const q = Math.round(v * (1.0 - s * ff) * 255);
const t = Math.round(v * (1.0 - s * (1.0 - ff)) * 255);
const p = round(v * (1.0 - s) * 255);
const q = round(v * (1.0 - s * ff) * 255);
const t = round(v * (1.0 - s * (1.0 - ff)) * 255);
switch (i) {

@@ -538,3 +541,3 @@ case 0:

// Convert percentage to number. e.g. 50% -> 128
txt.includes('%') ? Math.round(num / 100 * 255) : num);
txt.includes('%') ? round(num / 100 * 255) : num);
this.r = cells[0];

@@ -541,0 +544,0 @@ this.g = cells[1];

@@ -7,2 +7,4 @@ "use strict";

exports.FastColor = void 0;
const round = Math.round;
/**

@@ -176,3 +178,3 @@ * Support format, alpha unit will check the % mark:

} else {
this._h = Math.round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
this._h = round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
}

@@ -256,7 +258,8 @@ }

const p = amount / 100;
const calc = key => (color[key] - this[key]) * p + this[key];
const rgba = {
r: (color.r - this.r) * p + this.r,
g: (color.g - this.g) * p + this.g,
b: (color.b - this.b) * p + this.b,
a: (color.a - this.a) * p + this.a
r: round(calc('r')),
g: round(calc('g')),
b: round(calc('b')),
a: round(calc('a') * 100) / 100
};

@@ -295,3 +298,3 @@ return this._c(rgba);

const calc = key => {
return Math.round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha);
return round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha);
};

@@ -332,3 +335,3 @@ return this._c({

if (typeof this.a === 'number' && this.a >= 0 && this.a < 1) {
const aHex = Math.round(this.a * 255).toString(16);
const aHex = round(this.a * 255).toString(16);
hex += aHex.length === 2 ? aHex : '0' + aHex;

@@ -352,4 +355,4 @@ }

const h = this.getHue();
const s = Math.round(this.getSaturation() * 100);
const l = Math.round(this.getLightness() * 100);
const s = round(this.getSaturation() * 100);
const l = round(this.getLightness() * 100);
return this.a !== 1 ? `hsla(${h},${s}%,${l}%,${this.a})` : `hsl(${h},${s}%,${l}%)`;

@@ -434,3 +437,3 @@ }

if (s <= 0) {
const rgb = Math.round(l * 255);
const rgb = round(l * 255);
this.r = rgb;

@@ -466,5 +469,5 @@ this.g = rgb;

const lightnessModification = l - chroma / 2;
this.r = Math.round((r + lightnessModification) * 255);
this.g = Math.round((g + lightnessModification) * 255);
this.b = Math.round((b + lightnessModification) * 255);
this.r = round((r + lightnessModification) * 255);
this.g = round((g + lightnessModification) * 255);
this.b = round((b + lightnessModification) * 255);
}

@@ -481,3 +484,3 @@ fromHsv({

this.a = typeof a === 'number' ? a : 1;
const vv = Math.round(v * 255);
const vv = round(v * 255);
this.r = vv;

@@ -492,5 +495,5 @@ this.g = vv;

const ff = hh - i;
const p = Math.round(v * (1.0 - s) * 255);
const q = Math.round(v * (1.0 - s * ff) * 255);
const t = Math.round(v * (1.0 - s * (1.0 - ff)) * 255);
const p = round(v * (1.0 - s) * 255);
const q = round(v * (1.0 - s * ff) * 255);
const t = round(v * (1.0 - s * (1.0 - ff)) * 255);
switch (i) {

@@ -545,3 +548,3 @@ case 0:

// Convert percentage to number. e.g. 50% -> 128
txt.includes('%') ? Math.round(num / 100 * 255) : num);
txt.includes('%') ? round(num / 100 * 255) : num);
this.r = cells[0];

@@ -548,0 +551,0 @@ this.g = cells[1];

{
"name": "@ant-design/fast-color",
"version": "2.0.3",
"version": "2.0.4",
"description": "fast and small color class",

@@ -5,0 +5,0 @@ "keywords": [

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