color-rgba
Advanced tools
Comparing version 2.1.1 to 2.2.0
12
index.js
@@ -7,5 +7,7 @@ /** @module color-rgba */ | ||
var hsl = require('color-space/hsl') | ||
var clamp = require('clamp') | ||
module.exports = function rgba (color) { | ||
// template literals | ||
if (Array.isArray(color) && color.raw) color = String.raw(...arguments) | ||
var values, i, l | ||
@@ -19,5 +21,5 @@ | ||
values = Array(3) | ||
values[0] = clamp(parsed.values[0], 0, 255) | ||
values[1] = clamp(parsed.values[1], 0, 255) | ||
values[2] = clamp(parsed.values[2], 0, 255) | ||
values[0] = Math.min(Math.max(parsed.values[0], 0), 255) | ||
values[1] = Math.min(Math.max(parsed.values[1], 0), 255) | ||
values[2] = Math.min(Math.max(parsed.values[2], 0), 255) | ||
@@ -28,5 +30,5 @@ if (parsed.space[0] === 'h') { | ||
values.push(clamp(parsed.alpha, 0, 1)) | ||
values.push(Math.min(Math.max(parsed.alpha, 0), 1)) | ||
return values | ||
} |
{ | ||
"name": "color-rgba", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Convert color string (or parseable argument) to RGBA array", | ||
"main": "index.js", | ||
"module": "./index.mjs", | ||
"scripts": { | ||
"test": "node test" | ||
"test": "node test.mjs" | ||
}, | ||
"exports": { | ||
"import": "./index.mjs", | ||
"require": "./index.js" | ||
}, | ||
"repository": { | ||
@@ -28,6 +33,5 @@ "type": "git", | ||
"dependencies": { | ||
"clamp": "^1.0.1", | ||
"color-parse": "^1.3.8", | ||
"color-parse": "^1.4.1", | ||
"color-space": "^1.14.6" | ||
} | ||
} |
@@ -16,2 +16,3 @@ # color-rgba [![Build Status](https://travis-ci.org/colorjs/color-rgba.png)](https://travis-ci.org/colorjs/color-rgba) | ||
rgba('hsla(109, 50%, 50%, .75)') // [87.125, 191.25, 63.75, .75] | ||
rgba`rgb(80 120, 160 / 50%)` // [80, 120, 160, .5] | ||
``` | ||
@@ -18,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
4689
2
353936
34
60
- Removedclamp@^1.0.1
- Removedclamp@1.0.1(transitive)
Updatedcolor-parse@^1.4.1