@palett/convert
Advanced tools
Comparing version 0.1.7 to 0.2.0
@@ -16,17 +16,2 @@ 'use strict'; | ||
const hue = (r, g, b, max, dif) => { | ||
if (dif === 0) return 0; | ||
switch (max) { | ||
case r: | ||
return ((g - b) / dif + (g < b ? 6 : 0)) % 6; | ||
case g: | ||
return (b - r) / dif + 2; | ||
case b: | ||
return (r - g) / dif + 4; | ||
} | ||
}; | ||
const bound = ([r, g, b]) => { | ||
@@ -51,3 +36,18 @@ let ma = r, | ||
const THSD = 1000; | ||
const hue = (r, g, b, max, dif) => { | ||
if (dif === 0) return 0; | ||
switch (max) { | ||
case r: | ||
return ((g - b) / dif + (g < b ? 6 : 0)) % 6; | ||
case g: | ||
return (b - r) / dif + 2; | ||
case b: | ||
return (r - g) / dif + 4; | ||
} | ||
}; | ||
const THOUSAND = 1000; | ||
/** | ||
@@ -73,3 +73,3 @@ * !dif: dif===0 | ||
l = sum / 2; | ||
return [aryth.round(h), aryth.round(s * THSD) / 10, aryth.round(l * THSD) / 10]; | ||
return [aryth.round(h), aryth.round(s * THOUSAND) / 10, aryth.round(l * THOUSAND) / 10]; | ||
} | ||
@@ -76,0 +76,0 @@ |
@@ -12,17 +12,2 @@ import { round } from 'aryth'; | ||
const hue = (r, g, b, max, dif) => { | ||
if (dif === 0) return 0; | ||
switch (max) { | ||
case r: | ||
return ((g - b) / dif + (g < b ? 6 : 0)) % 6; | ||
case g: | ||
return (b - r) / dif + 2; | ||
case b: | ||
return (r - g) / dif + 4; | ||
} | ||
}; | ||
const bound = ([r, g, b]) => { | ||
@@ -47,3 +32,18 @@ let ma = r, | ||
const THSD = 1000; | ||
const hue = (r, g, b, max, dif) => { | ||
if (dif === 0) return 0; | ||
switch (max) { | ||
case r: | ||
return ((g - b) / dif + (g < b ? 6 : 0)) % 6; | ||
case g: | ||
return (b - r) / dif + 2; | ||
case b: | ||
return (r - g) / dif + 4; | ||
} | ||
}; | ||
const THOUSAND = 1000; | ||
/** | ||
@@ -69,3 +69,3 @@ * !dif: dif===0 | ||
l = sum / 2; | ||
return [round(h), round(s * THSD) / 10, round(l * THSD) / 10]; | ||
return [round(h), round(s * THOUSAND) / 10, round(l * THOUSAND) / 10]; | ||
} | ||
@@ -72,0 +72,0 @@ |
{ | ||
"name": "@palett/convert", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"description": "A color converter among RGB, HEX and HSL.", | ||
@@ -43,3 +43,3 @@ "main": "dist/index.cjs.js", | ||
"homepage": "https://github.com/hoyeungw/palett/rgb#readme", | ||
"gitHead": "08919265b1eb16e7de3219b0d1c45c680f91ca5d" | ||
"gitHead": "acea3e999df4d67303b6d04c7b713849a943b74c" | ||
} |
@@ -0,0 +0,0 @@ ## @palett/convert |
Sorry, the diff of this file is not supported yet
8645