Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

values.js

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

values.js - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

CHANGELOG.md

498

index.js
/**
* values.js - Get the tints and shades of a color
* @version v1.0.3
* @link http://noeldelgado.github.io/Values.js/
* @link http://noeldelgado.github.io/values.js/
* @license MIT
*/
(function() {
var Utils = {
reHash : new RegExp("^#"),
reHEX : new RegExp("^(#)?([0-9a-fA-F]{3})([0-9a-fA-F]{3})?$"),
reRGB : new RegExp("rgba?\\s*\\((\\d+)\\,\\s*(\\d+)\\,\\s*(\\d+)(,\\s*((\\d+)?(\\.\\d+)?))?\\)","i"),
reHSL : new RegExp("hsla?\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%,?\\s*(?:0?(\\.\\d+)?|1(\\.0)?)?\\)","i"),
(function () {
var Utils = {
reHash: new RegExp('^#'),
reHEX: new RegExp('^(#)?([0-9a-fA-F]{3})([0-9a-fA-F]{3})?$'),
reRGB: new RegExp('rgba?\\s*\\((\\d+)\\,\\s*(\\d+)\\,\\s*(\\d+)(,\\s*((\\d+)?(\\.\\d+)?))?\\)', 'i'),
reHSL: new RegExp('hsla?\\((\\d+),\\s*([\\d.]+)%,\\s*([\\d.]+)%,?\\s*(?:0?(\\.\\d+)?|1(\\.0)?)?\\)', 'i'),
isHEX : function isHEX(value) {
return this.reHEX.test(value);
},
isHEX: function isHEX(value) {
return this.reHEX.test(value);
},
isRGB : function isRGB(value) {
var rgb = value.match(this.reRGB);
isRGB: function isRGB(value) {
var rgb = value.match(this.reRGB);
if (rgb) {
if ((rgb[1] <= 255) && (rgb[2] <= 255) && (rgb[3] <= 255)) {
return true;
}
}
if (rgb) {
if ((rgb[1] <= 255) && (rgb[2] <= 255) && (rgb[3] <= 255)) {
return true;
}
}
return false;
},
return false;
},
isHSL : function isHSL(value) {
var hsl = value.match(this.reHSL);
isHSL: function isHSL(value) {
var hsl = value.match(this.reHSL);
if (hsl) {
if ((hsl[1] <= 360) && (hsl[2] <= 100) && (hsl[3] <= 100)) {
return true;
}
}
if (hsl) {
if ((hsl[1] <= 360) && (hsl[2] <= 100) && (hsl[3] <= 100)) {
return true;
}
}
return false;
},
return false;
},
HEXtoRGB : function HEXtoRGB(hex) {
hex = hex.replace('#', '');
HEXtoRGB: function HEXtoRGB(hex) {
hex = hex.replace('#', '');
if (hex.length === 3) {
var h1 = hex.charAt(0), h2 = hex.charAt(1), h3 = hex.charAt(2);
hex = h1 + h1 + h2 + h2 + h3 + h3;
}
var bw = parseInt(hex, 16);
if (hex.length === 3) {
var h1 = hex.charAt(0), h2 = hex.charAt(1), h3 = hex.charAt(2);
hex = h1 + h1 + h2 + h2 + h3 + h3;
}
var bw = parseInt(hex, 16);
return {r: (bw >> 16) & 255, g: (bw >> 8) & 255, b: bw & 255};
},
return {r: (bw >> 16) & 255, g: (bw >> 8) & 255, b: bw & 255};
},
RGBtoHEX : function RGBtoHEX(r, g, b) {
return (0x1000000 + (r << 16) + (g << 8) + b).toString(16).slice(1);
},
RGBtoHEX: function RGBtoHEX(r, g, b) {
return (0x1000000 + (r << 16) + (g << 8) + b).toString(16).slice(1);
},
RGBtoHSL : function RGBtoHSL(r, g, b) {
var min, max, h, s, l;
RGBtoHSL: function RGBtoHSL(r, g, b) {
var min, max, h, s, l;
r = (r / 255);
g = (g / 255);
b = (b / 255);
r = (r / 255);
g = (g / 255);
b = (b / 255);
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = ((max + min) / 2);
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = ((max + min) / 2);
if (max === min) {
h = s = 0;
} else {
var d = (max - min);
s = (l > 0.5) ? (d / (2 - max - min)) : (d / (max + min));
if (max === min) {h = s = 0;}
else {
var d = (max - min);
s = (l > 0.5) ? (d / (2 - max - min)) : (d / (max + min));
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);}
h /= 6;
}
h /= 6;
}
return {h: Math.round(h * 360), s: Math.round(s * 100), l: Math.round(l * 100)};
},
return {h: Math.round(h * 360), s: Math.round(s * 100), l: Math.round(l * 100)};
},
HUEtoRGB : function HUEtoRGB(v1, v2, vh) {
if (vh < 0) {vh += 1;}
if (vh > 1) {vh -= 1;}
HUEtoRGB: function HUEtoRGB(v1, v2, vh) {
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);}
return v1;
},
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;
},
HSLtoRGB : function HSLtoRGB(h, s, l) {
var r, g, b;
HSLtoRGB: function HSLtoRGB(h, s, l) {
var r, g, b;
h /= 360;
s /= 100;
l /= 100;
h /= 360;
s /= 100;
l /= 100;
if (s === 0) {r = g = b = l;}
else {
var q = (l < 0.5) ? (l * (1 + s)) : (l + s - l * s);
var p = (2 * l - q);
r = this.HUEtoRGB(p, q, h + 1/3);
g = this.HUEtoRGB(p, q, h);
b = this.HUEtoRGB(p, q, h - 1/3);
}
if (s === 0) {r = g = b = l;} else {
var q = (l < 0.5) ? (l * (1 + s)) : (l + s - l * s);
var p = (2 * l - q);
r = this.HUEtoRGB(p, q, h + 1 / 3);
g = this.HUEtoRGB(p, q, h);
b = this.HUEtoRGB(p, q, h - 1 / 3);
}
return {r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255)};
},
return {r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255)};
},
mix : function mix(color1, color2, percentage) {
percentage = (typeof percentage === 'undefined') ? 50 : percentage;
mix: function mix(color1, color2, percentage) {
percentage = (typeof percentage === 'undefined') ? 50 : percentage;
var weight = (percentage / 100.0);
var w = (weight * 2 - 1);
var a = 0;
var weight = (percentage / 100.0);
var w = (weight * 2 - 1);
var a = 0;
var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
var w2 = (1 - w1);
var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
var w2 = (1 - w1);
var r = Math.round(color1.rgb.r * w1 + color2.rgb.r * w2);
var g = Math.round(color1.rgb.g * w1 + color2.rgb.g * w2);
var b = Math.round(color1.rgb.b * w1 + color2.rgb.b * w2);
var r = Math.round(color1.rgb.r * w1 + color2.rgb.r * w2);
var g = Math.round(color1.rgb.g * w1 + color2.rgb.g * w2);
var b = Math.round(color1.rgb.b * w1 + color2.rgb.b * w2);
return new Values(Utils.RGBtoHEX(r,g,b));
}
};
var value = new Values(Utils.RGBtoHEX(r, g, b));
value.percentage = percentage;
function Values(color) {
this.hex = '';
this.hsl = {};
this.rgb = {};
return value;
}
};
if (color) {
return this.setColor(color);
}
function Values (color) {
this.hex = '';
this.hsl = {};
this.rgb = {};
return this;
if (color) {
return this.setColor(color);
}
Values.Utils = Utils;
return this;
}
/**
Sets the base color for which all operations are based. Updates the instance's properties.
@method setColor <public> [Function]
@param color <required> [String] A valid color format (#000, rgb(0,0,0), hsl(0,0%,0%))
@return Values instance || Error [Object]
*/
Values.prototype.setColor = function(color) {
if (Utils.isHEX(color)) {
return this._setFromHexString(color);
} else if (Utils.isRGB(color)) {
return this._setFromRGBString(color);
} else if (Utils.isHSL(color)) {
return this._setFromHSLString(color);
}
Values.Utils = Utils;
return new Error('Invalid Color Format');
};
/* Sets the base color for which all operations are based. Updates the instance’s properties.
* @public
* @param {string} color - A valid color format (#000, rgb(0,0,0), hsl(0,0%,0%))
* @return {Values|Error}
*/
Values.prototype.setColor = function setColor (color) {
if (Utils.isHEX(color)) {
return this._setFromHexString(color);
} else if (Utils.isRGB(color)) {
return this._setFromRGBString(color);
} else if (Utils.isHSL(color)) {
return this._setFromHSLString(color);
}
/**
Lightens the instance by mixing it with white as specified by @percentage.
@method tint <public> [Function]
@param percentage <optional> [Number] {50}
@return new Values instance [Object]
*/
Values.prototype.tint = function tint(percentage) {
return Utils.mix({rgb:{r:255, g:255, b:255}}, this, percentage);
};
return new Error('Invalid Color Format');
};
/**
Darkens the instance color by mixing it with black as specified by @percentage.
@method shade <public> [Function]
@param percentage <optional> [Number] {50}
@return new Values instance [Object]
*/
Values.prototype.shade = function shade(percentage) {
return Utils.mix({rgb:{r:0, g:0, b:0}}, this, percentage);
};
/* Lightens the instance by mixing it with white as specified by @percentage.
* @public
* @param {number} [percentage]
* @return {Values}
*/
Values.prototype.tint = function tint (percentage) {
return Utils.mix({rgb: {r: 255, g: 255, b: 255}}, this, percentage);
};
/**
Generates the tints of the instance color as specified by @percentage.
@method tints <public> [Function]
@param percentage <optional> [Number] {10}
@return Array of Values instances [Array]
*/
Values.prototype.tints = function tint(percentage) {
var i = percentage = (percentage || 10), tints = [];
/* Darkens the instance color by mixing it with black as specified by @percentage.
* @public
* @param {number} [percentage]
* @return {Values}
*/
Values.prototype.shade = function shade (percentage) {
return Utils.mix({rgb: {r: 0, g: 0, b: 0}}, this, percentage);
};
while (i <= 100) {
tints.push(this.tint(i));
i += percentage;
}
/* Generates the tints of the instance color as specified by @percentage.
* @public
* @param {number} [percentage=10]
* @return {Array<Values>}
*/
Values.prototype.tints = function tint (percentage) {
var i = percentage = (percentage || 10)
, tints = []
, tint;
return tints;
};
while (i <= 100) {
tint = this.tint(i);
tint.isTint = true;
tints.push(tint);
i += percentage;
}
/**
Generates the shades of the instance color as specified by @percentage.
@method shades <public> [Function]
@param percentage <optional> [Number] {10}
@return Array of Values instances [Array]
*/
Values.prototype.shades = function tint(percentage) {
var i = percentage = (percentage || 10), shades = [];
return tints;
};
while (i <= 100) {
shades.push(this.shade(i));
i += percentage;
}
/* Generates the shades of the instance color as specified by @percentage.
* @public
* @param {number} [percentage=10]
* @return {Array<Values>}
*/
Values.prototype.shades = function tint (percentage) {
var i = percentage = (percentage || 10), shades = [];
return shades;
};
while (i <= 100) {
shade = this.shade(i);
shade.isShade = true;
shades.push(shade);
i += percentage;
}
/**
Generates the tints and shades of the instance color as specified by @percentage.
@method all <public> [Function]
@param percentage <optional> [Number] {10}
@return Array of Values instances [Array]
*/
Values.prototype.all = function all(percentage) {
percentage = percentage;
return shades;
};
var tints = this.tints(percentage).reverse();
var shades = this.shades(percentage);
tints.push(this);
/* Generates the tints and shades of the instance color as specified by @percentage.
* @public
* @param {number} [percentage]
* @return {Array<Values>}
*/
Values.prototype.all = function all (percentage) {
var tints = this.tints(percentage).reverse()
, shades = this.shades(percentage);
return tints.concat(shades);
};
tints.push(Object.assign(this, { isBaseColor: true }));
return tints.concat(shades);
};
/**
Calculates and returns the brightness of the instance base-color.
@return brightness [Number]
*/
Values.prototype.getBrightness = function getBrightness() {
var sum = (this.rgb.r + this.rgb.g + this.rgb.b);
return Math.round(sum / (255 * 3) * 100);
};
/* Calculates the brightness of the instance base-color.
* @return {number} the base-color brightness.
*/
Values.prototype.getBrightness = function getBrightness () {
var sum = (this.rgb.r + this.rgb.g + this.rgb.b);
return Math.round(sum / (255 * 3) * 100);
};
/**
Returns the instance color in hexadecimal string form.
@returns '#000000' [String]
*/
Values.prototype.hexString = function() {
return '#' + this.hex;
};
/* Returns the instance color in hexadecimal string form.
* @returns {string} e.g. '#000000'
*/
Values.prototype.hexString = function hexString () {
return ('#' + this.hex);
};
/**
Returns the instance color in rgb string form.
@returns 'rgb(0, 0, 0)' [String]
*/
Values.prototype.rgbString = function() {
return 'rgb(' + this.rgb.r + ', ' + this.rgb.g + ', ' + this.rgb.b + ')';
};
/* Returns the instance color in rgb string form.
* @returns {string} e.g. 'rgb(0, 0, 0)'
*/
Values.prototype.rgbString = function rgbString () {
return ('rgb(' + this.rgb.r + ', ' + this.rgb.g + ', ' + this.rgb.b + ')');
};
/**
Returns the instance color in hsl string form.
@returns 'hsl(0, 0%, 0%)' [String]
*/
Values.prototype.hslString = function() {
return 'hsl(' + this.hsl.h + ', ' + this.hsl.s + '%, ' + this.hsl.l + '%)';
};
/* Returns the instance color in hsl string form.
* @returns {string} e.g. 'hsl(0, 0%, 0%)'
*/
Values.prototype.hslString = function hslString () {
return ('hsl(' + this.hsl.h + ', ' + this.hsl.s + '%, ' + this.hsl.l + '%)');
};
/**
Updates the instance base-color properties from a valid hex string.
@method _setFromHexString <private> [Function]
@param color <required> [String]
*/
Values.prototype._setFromHexString = function _setFromHexString(color) {
this.hex = (Utils.reHash.test(color)) ? color.replace('#','') : color;
this.rgb = Utils.HEXtoRGB(color);
this.hsl = Utils.RGBtoHSL(this.rgb.r, this.rgb.g, this.rgb.b);
/* Updates the instance base-color properties from a valid hex string.
* @private
* @param {string} color
*/
Values.prototype._setFromHexString = function _setFromHexString (color) {
this.hex = (Utils.reHash.test(color)) ? color.replace('#', '') : color;
this.rgb = Utils.HEXtoRGB(color);
this.hsl = Utils.RGBtoHSL(this.rgb.r, this.rgb.g, this.rgb.b);
return this;
};
return this;
};
/**
Updates the instance base-color properties from a valid rgb string.
@method _setFromRGBString <private> [Function]
@param color <required> [String]
*/
Values.prototype._setFromRGBString = function _setFromRGBString(color) {
var rgb = color.replace(/[^\d,]/g, '').split(','),
r = parseInt(rgb[0], 10),
g = parseInt(rgb[1], 10),
b = parseInt(rgb[2], 10);
/* Updates the instance base-color properties from a valid rgb string.
* @private
* @param {string} color
*/
Values.prototype._setFromRGBString = function _setFromRGBString(color) {
var rgb = color.replace(/[^\d,]/g, '').split(',')
, r = parseInt(rgb[0], 10)
, g = parseInt(rgb[1], 10)
, b = parseInt(rgb[2], 10);
this.rgb = {r: r, g: g, b: b};
this.hex = Utils.RGBtoHEX(r, g, b);
this.hsl = Utils.RGBtoHSL(this.rgb.r, this.rgb.g, this.rgb.b);
this.rgb = {r: r, g: g, b: b};
this.hex = Utils.RGBtoHEX(r, g, b);
this.hsl = Utils.RGBtoHSL(this.rgb.r, this.rgb.g, this.rgb.b);
return this;
};
return this;
};
/**
Updates the instance base-color properties from a valid hsl string.
@method _setFromHSLString <private> [Function]
@param color <required> [String]
*/
Values.prototype._setFromHSLString = function _setFromHSLString(color) {
var hsl = color.match(Utils.reHSL),
h = Math.round(hsl[1]),
s = Math.round(hsl[2]),
l = Math.round(hsl[3]);
/* Updates the instance base-color properties from a valid hsl string.
* @private
* @param {string} color
*/
Values.prototype._setFromHSLString = function _setFromHSLString (color) {
var hsl = color.match(Utils.reHSL)
, h = Math.round(hsl[1])
, s = Math.round(hsl[2])
, l = Math.round(hsl[3]);
this.hsl = {h: h, s: s, l: l};
this.rgb = Utils.HSLtoRGB(h, s, l);
this.hex = Utils.RGBtoHEX(this.rgb.r, this.rgb.g, this.rgb.b);
this.hsl = {h: h, s: s, l: l};
this.rgb = Utils.HSLtoRGB(h, s, l);
this.hex = Utils.RGBtoHEX(this.rgb.r, this.rgb.g, this.rgb.b);
return this;
};
return this;
};
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = Values;
} else {window.Values = Values;}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = Values;
} else {window.Values = Values;}
})();
{
"name": "values.js",
"version": "1.0.3",
"version": "1.1.0",
"description": "Get the tints and shades of a color",

@@ -9,3 +9,3 @@ "license": "MIT",

"type": "git",
"url": "https://github.com/noeldelgado/Values.js.git"
"url": "https://github.com/noeldelgado/values.js.git"
},

@@ -27,8 +27,8 @@ "scripts": {

"bugs": {
"url": "https://github.com/noeldelgado/Values.js/issues"
"url": "https://github.com/noeldelgado/values.js/issues"
},
"homepage": "http://noeldelgado.github.io/Values.js/",
"homepage": "http://noeldelgado.github.io/values.js/",
"devDependencies": {
"mocha": "^1.21.4"
"mocha": "^7.1.0"
}
}

@@ -1,4 +0,6 @@

## 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)
# values.js
[![npm-image](https://img.shields.io/npm/v/values.js.svg)](https://www.npmjs.com/package/values.js)
![bower-image](https://img.shields.io/bower/v/values.js.svg)
[![Known Vulnerabilities](https://snyk.io/test/npm/values.js/1.0.3/badge.svg)](https://snyk.io/test/npm/values.js/1.0.3)
![license-image](https://img.shields.io/npm/l/values.js.svg)

@@ -9,25 +11,26 @@ The lightness or darkness of a color is called its value.

http://noeldelgado.github.io/Values.js/
## Demo
https://noeldelgado.github.io/values.js/
### Installation
## Dependencies
None
#### Node
## Installation
`npm install values.js`
**NPM**
#### Bower
```sh
npm install values.js --save
```
`bower install values.js`
**Bower**
### Usage
```js
// node
var Values = require('values.js');
```sh
bower install values.js --save
```
// browser
<script src="path-to-values/index.js"></script>
```
#### Example
## Usage Example
```js
var color = new Values('#0099ff');
var Values = require('values.js')
, color = new Values('#0099ff');

@@ -45,7 +48,7 @@ console.log(color.hex) // => "0099ff"

color.tints().forEach(function(tint) {
console.log(tint); // => [Value instance]
console.log(tint); // => [Values instance]
});
color.shades().forEach(function(shade) {
console.log(shade); // => [Value instance]
console.log(shade); // => [Values instance]
});

@@ -55,16 +58,25 @@

color.all().forEach(function(color) {
console.log(color); // => [Value instance]
console.log(color); // => [Value instance]
});
```
## Instance
```js
// console.log(new Values('#09f'))
{
hex: "09c"
hsl: { h: 195, s: 100, l: 40 }
rgb: { r: 0, g: 153, b: 204 }
...
}
```
### Methods
## Instance Methods
#### setColor
### setColor(String:color)
```js
/**
Sets the base color for which all operations are based. Updates the instance's properties.
@method setColor <public> [Function]
@param color <required> [String] A valid color format (#000, rgb(0,0,0), hsl(0,0%,0%))
@return Values instance || Error [Object]
*/
/* Sets the base color for which all operations are based. Updates the instance's properties.
* @param {string} color - A valid color format (#000, rgb(0,0,0), hsl(0,0%,0%))
* @return {Values|Error}
*/
color.setColor('ff0');

@@ -75,10 +87,8 @@ color.setColor('rgb(255,255,0)');

#### tint
### tint([Number:percentage=50])
```js
/**
Lightens the instance by mixing it with white as specified by @percentage.
@method tint <public> [Function]
@param percentage <optional> [Number] {50}
@return new Values instance [Object]
*/
/* Lightens the instance by mixing it with white as specified by @percentage.
* @param {number} [percentage=50]
* @return {Values}
*/

@@ -90,10 +100,8 @@ color.tint();

#### shade
### shade([Number:percentage=50)
```js
/**
Darkens the instance color by mixing it with black as specified by @percentage.
@method shade <public> [Function]
@param percentage <optional> [Number] {50}
@return new Values instance [Object]
*/
/* Darkens the instance color by mixing it with black as specified by @percentage.
* @param {number} [percentage=50]
* @return {Values}
*/

@@ -105,12 +113,10 @@ color.shade();

#### tints
### tints([Number:percentage=10])
````js
/**
Generates the tints of the instance color as specified by @percentage.
@method tints <public> [Function]
@param percentage <optional> [Number] {10}
@return Array of Values instances [Array]
*/
/* Generates the tints of the instance color as specified by @percentage.
* @param {number} [percentage=10]
* @return {Array<Values>}
*/
color.tints(20).forEach(function(tint) {
color.tints(20).forEach(function (tint) {
console.log(tint)

@@ -120,12 +126,10 @@ })

#### shades
### shades([Number:percentage=10])
````js
/**
Generates the shades of the instance color as specified by @percentage.
@method shades <public> [Function]
@param percentage <optional> [Number] {10}
@return Array of Values instances [Array]
/* Generates the shades of the instance color as specified by @percentage.
* @param {number} [percentage=10]
* @return {Array<Values>}
*/
color.shades(20).forEach(function(shade) {
color.shades(20).forEach(function (shade) {
console.log(shade)

@@ -135,12 +139,10 @@ })

#### all
### all([Number:percentage=10])
```js
/**
Generates the tints and shades of the instance color as specified by @percentage.
@method all <public> [Function]
@param percentage <optional> [Number] {10}
@return Array of Values instances [Array]
*/
/* Generates the tints and shades of the instance color as specified by @percentage.
* @param {number} [percentage=10]
* @return {Array<Values>}
*/
color.all().forEach(function(color) {
color.all().forEach(function (color) {
console.log(color)

@@ -150,6 +152,38 @@ })

### Values.Utils
### getBrightness()
````js
/* Calculates the brightness of the instance base-color.
* @return {number} the base-color brightness.
*/
color.getBrightness();
````
#### isHex(color)
### hexString()
```js
/* Returns the instance color in hexadecimal string form.
* @returns {string} e.g. '#000000'
*/
color.hexString();
```
### rgbString()
```js
/* Returns the instance color in rgb string form.
* @returns {string} e.g. 'rgb(0, 0, 0)'
*/
color.rgbString();
```
### hslString()
```js
/* Returns the instance color in hsl string form.
* @returns {string} e.g. 'hsl(0, 0%, 0%)'
*/
color.hslString();
```
## Static Methods (Utils)
### isHex(String:color)
```js
Values.Utils.isHEX('09c') => true

@@ -161,3 +195,3 @@ Values.Utils.isHEX('#09c') => true

#### isRGB(color)
### isRGB(String:color)
```js

@@ -169,3 +203,3 @@ Values.Utils.isRGB('rgb(0,0,0)') => true

#### isHSL(color)
### isHSL(String:color)
```js

@@ -177,6 +211,13 @@ Values.Utils.isHSL('hsl(198,58%,1%)') => true

### Dev
```bash
npm install # install dev-dependencies
npm run dev # watch for changes and run tests
## Dev
```sh
npm install # install dev-dependencies
npm test # run the tests
npm run dev # watch for changes and run tests
```
## Related
- [Shadowlord](https://github.com/noeldelgado/shadowlord) - Tints and shades generator tool
## License
MIT © [Noel Delgado](http://pixelia.me/)
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