ant-design-palettes
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,2 +0,2 @@ | ||
import { generate, presetPalettes } from './'; | ||
import { generate, presetPalettes } from './src'; | ||
@@ -14,3 +14,3 @@ const blueColors = [ | ||
'#002766', | ||
]; | ||
].map(color => color.toLowerCase()); | ||
@@ -17,0 +17,0 @@ test('Generate palettes from a given color', () => { |
@@ -8,5 +8,5 @@ 'use strict'; | ||
var _color = require('color'); | ||
var _tinycolor = require('tinycolor2'); | ||
var _color2 = _interopRequireDefault(_color); | ||
var _tinycolor2 = _interopRequireDefault(_tinycolor); | ||
@@ -26,6 +26,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// 根据色相不同,色相转向不同 | ||
if (hsv.color[0] >= 60 && hsv.color[0] <= 240) { | ||
hue = light ? hsv.color[0] - hueStep * i : hsv.color[0] + hueStep * i; | ||
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) { | ||
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i; | ||
} else { | ||
hue = light ? hsv.color[0] + hueStep * i : hsv.color[0] - hueStep * i; | ||
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i; | ||
} | ||
@@ -43,7 +43,7 @@ if (hue < 0) { | ||
if (light) { | ||
saturation = hsv.color[1] - saturationStep * i; | ||
saturation = Math.round(hsv.s * 100) - saturationStep * i; | ||
} else if (i === darkColorCount) { | ||
saturation = hsv.color[1] + saturationStep; | ||
saturation = Math.round(hsv.s * 100) + saturationStep; | ||
} else { | ||
saturation = hsv.color[1] + saturationStep2 * i; | ||
saturation = Math.round(hsv.s * 100) + saturationStep2 * i; | ||
} | ||
@@ -66,5 +66,5 @@ // 边界值修正 | ||
if (light) { | ||
return hsv.color[2] + brightnessStep1 * i; | ||
return Math.round(hsv.v * 100) + brightnessStep1 * i; | ||
} | ||
return hsv.color[2] - brightnessStep2 * i; | ||
return Math.round(hsv.v * 100) - brightnessStep2 * i; | ||
} | ||
@@ -74,20 +74,20 @@ | ||
var patterns = []; | ||
var pColor = (0, _color2.default)(color); | ||
var pColor = (0, _tinycolor2.default)(color); | ||
for (var i = lightColorCount; i > 0; i -= 1) { | ||
var hsv = pColor.hsv().round(); | ||
var colorString = (0, _color2.default)({ | ||
var hsv = pColor.toHsv(); | ||
var colorString = (0, _tinycolor2.default)({ | ||
h: getHue(hsv, i, true), | ||
s: getSaturation(hsv, i, true), | ||
v: getValue(hsv, i, true) | ||
}).hex(); | ||
}).toHexString(); | ||
patterns.push(colorString); | ||
} | ||
patterns.push(pColor.hex()); | ||
patterns.push(pColor.toHexString()); | ||
for (var _i = 1; _i <= darkColorCount; _i += 1) { | ||
var _hsv = pColor.hsv().round(); | ||
var _colorString = (0, _color2.default)({ | ||
var _hsv = pColor.toHsv(); | ||
var _colorString = (0, _tinycolor2.default)({ | ||
h: getHue(_hsv, _i), | ||
s: getSaturation(_hsv, _i), | ||
v: getValue(_hsv, _i) | ||
}).hex(); | ||
}).toHexString(); | ||
patterns.push(_colorString); | ||
@@ -94,0 +94,0 @@ } |
{ | ||
"name": "ant-design-palettes", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Color palettes calculator of Ant Design", | ||
"main": "lib/index.js", | ||
"module": "src/index.js", | ||
"module": "es/index.js", | ||
"repository": { | ||
@@ -14,4 +14,2 @@ "type": "git", | ||
}, | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"scripts": { | ||
@@ -25,3 +23,3 @@ "compile": "babel src --out-dir lib", | ||
"dependencies": { | ||
"color": "^3.0.0" | ||
"tinycolor2": "^1.4.1" | ||
}, | ||
@@ -28,0 +26,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
import Color from 'color'; | ||
import tinycolor from 'tinycolor2'; | ||
@@ -14,6 +14,6 @@ const hueStep = 2; // 色相阶梯 | ||
// 根据色相不同,色相转向不同 | ||
if (hsv.color[0] >= 60 && hsv.color[0] <= 240) { | ||
hue = light ? hsv.color[0] - (hueStep * i) : hsv.color[0] + (hueStep * i); | ||
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) { | ||
hue = light ? Math.round(hsv.h) - (hueStep * i) : Math.round(hsv.h) + (hueStep * i); | ||
} else { | ||
hue = light ? hsv.color[0] + (hueStep * i) : hsv.color[0] - (hueStep * i); | ||
hue = light ? Math.round(hsv.h) + (hueStep * i) : Math.round(hsv.h) - (hueStep * i); | ||
} | ||
@@ -31,7 +31,7 @@ if (hue < 0) { | ||
if (light) { | ||
saturation = hsv.color[1] - (saturationStep * i); | ||
saturation = Math.round(hsv.s * 100) - (saturationStep * i); | ||
} else if (i === darkColorCount) { | ||
saturation = hsv.color[1] + (saturationStep); | ||
saturation = Math.round(hsv.s * 100) + (saturationStep); | ||
} else { | ||
saturation = hsv.color[1] + (saturationStep2 * i); | ||
saturation = Math.round(hsv.s * 100) + (saturationStep2 * i); | ||
} | ||
@@ -54,5 +54,5 @@ // 边界值修正 | ||
if (light) { | ||
return hsv.color[2] + (brightnessStep1 * i); | ||
return Math.round(hsv.v * 100) + (brightnessStep1 * i); | ||
} | ||
return hsv.color[2] - (brightnessStep2 * i); | ||
return Math.round(hsv.v * 100) - (brightnessStep2 * i); | ||
} | ||
@@ -62,20 +62,20 @@ | ||
const patterns = []; | ||
const pColor = Color(color); | ||
const pColor = tinycolor(color); | ||
for (let i = lightColorCount; i > 0; i -= 1) { | ||
const hsv = pColor.hsv().round(); | ||
const colorString = Color({ | ||
const hsv = pColor.toHsv(); | ||
const colorString = tinycolor({ | ||
h: getHue(hsv, i, true), | ||
s: getSaturation(hsv, i, true), | ||
v: getValue(hsv, i, true), | ||
}).hex(); | ||
}).toHexString(); | ||
patterns.push(colorString); | ||
} | ||
patterns.push(pColor.hex()); | ||
patterns.push(pColor.toHexString()); | ||
for (let i = 1; i <= darkColorCount; i += 1) { | ||
const hsv = pColor.hsv().round(); | ||
const colorString = Color({ | ||
const hsv = pColor.toHsv(); | ||
const colorString = tinycolor({ | ||
h: getHue(hsv, i), | ||
s: getSaturation(hsv, i), | ||
v: getValue(hsv, i), | ||
}).hex(); | ||
}).toHexString(); | ||
patterns.push(colorString); | ||
@@ -82,0 +82,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8910
+ Addedtinycolor2@^1.4.1
+ Addedtinycolor2@1.6.0(transitive)
- Removedcolor@^3.0.0
- Removedcolor@3.2.1(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcolor-string@1.9.1(transitive)
- Removedis-arrayish@0.3.2(transitive)
- Removedsimple-swizzle@0.2.2(transitive)