Comparing version 1.0.2 to 1.0.3
28
index.js
/** | ||
* values.js - Get the tints and shades of a color | ||
* @version v1.0.2 | ||
* @version v1.0.3 | ||
* @link http://noeldelgado.github.io/Values.js/ | ||
@@ -75,5 +75,5 @@ * @license MIT | ||
if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)); | ||
else if (max === g) h = ((b - r) / d + 2); | ||
else if (max === b) h = ((r - g) / d + 4); | ||
if (max === r) {h = ((g - b) / d + (g < b ? 6 : 0));} | ||
else if (max === g) {h = ((b - r) / d + 2);} | ||
else if (max === b) {h = ((r - g) / d + 4);} | ||
@@ -87,8 +87,8 @@ h /= 6; | ||
HUEtoRGB : function HUEtoRGB(v1, v2, vh) { | ||
if (vh < 0) vh += 1; | ||
if (vh > 1) vh -= 1; | ||
if (vh < 0) {vh += 1;} | ||
if (vh > 1) {vh -= 1;} | ||
if ((6 * vh) < 1) return (v1 + (v2 - v1) * 6 * vh); | ||
if ((2 * vh) < 1) return v2; | ||
if ((3 * vh) < 2) return (v1 + (v2 - v1) * ((2/3) - vh) * 6); | ||
if ((6 * vh) < 1) {return (v1 + (v2 - v1) * 6 * vh);} | ||
if ((2 * vh) < 1) {return v2;} | ||
if ((3 * vh) < 2) {return (v1 + (v2 - v1) * ((2/3) - vh) * 6);} | ||
return v1; | ||
@@ -104,3 +104,3 @@ }, | ||
if (s == 0) r = g = b = l; | ||
if (s === 0) {r = g = b = l;} | ||
else { | ||
@@ -118,3 +118,3 @@ var q = (l < 0.5) ? (l * (1 + s)) : (l + s - l * s); | ||
mix : function mix(color1, color2, percentage) { | ||
percentage = percentage || 50; | ||
percentage = (typeof percentage === 'undefined') ? 50 : percentage; | ||
@@ -125,3 +125,3 @@ var weight = (percentage / 100.0); | ||
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; | ||
var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; | ||
var w2 = (1 - w1); | ||
@@ -282,3 +282,3 @@ | ||
return this | ||
return this; | ||
}; | ||
@@ -324,3 +324,3 @@ | ||
module.exports = Values; | ||
} else window.Values = Values; | ||
} else {window.Values = Values;} | ||
})(); |
{ | ||
"name": "values.js", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Get the tints and shades of a color", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
## Values.js | ||
[![npm-image](https://img.shields.io/npm/v/values.js.svg?style=flat-square)](https://www.npmjs.com/package/values.js) | ||
![bower-image](https://img.shields.io/bower/v/values.js.svg?style=flat-square) | ||
The lightness or darkness of a color is called its value. | ||
@@ -3,0 +6,0 @@ Tints are light values that are made by mixing a color with white, which increases lightness. |
14610
171