Initial Commit
This commit is contained in:
31
node_modules/color-rgba/.github/workflows/test.js.yml
generated
vendored
Normal file
31
node_modules/color-rgba/.github/workflows/test.js.yml
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
||||
|
||||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x, 16.x, 18.x]
|
||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- run: npm run build --if-present
|
||||
- run: npm test
|
||||
3
node_modules/color-rgba/.travis.yml
generated
vendored
Normal file
3
node_modules/color-rgba/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "stable"
|
||||
33
node_modules/color-rgba/index.js
generated
vendored
Normal file
33
node_modules/color-rgba/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/** @module color-rgba */
|
||||
import parse from 'color-parse'
|
||||
import rgb from 'color-space/rgb.js'
|
||||
import hsl from 'color-space/hsl.js'
|
||||
|
||||
export default function rgba(color) {
|
||||
// template literals
|
||||
if (Array.isArray(color) && color.raw) color = String.raw(...arguments)
|
||||
if (color instanceof Number) color = +color
|
||||
|
||||
var values, i, l
|
||||
|
||||
//attempt to parse non-array arguments
|
||||
var parsed = parse(color)
|
||||
|
||||
if (!parsed.space) return []
|
||||
|
||||
const min = parsed.space[0] === 'h' ? hsl.min : rgb.min
|
||||
const max = parsed.space[0] === 'h' ? hsl.max : rgb.max
|
||||
|
||||
values = Array(3)
|
||||
values[0] = Math.min(Math.max(parsed.values[0], min[0]), max[0])
|
||||
values[1] = Math.min(Math.max(parsed.values[1], min[1]), max[1])
|
||||
values[2] = Math.min(Math.max(parsed.values[2], min[2]), max[2])
|
||||
|
||||
if (parsed.space[0] === 'h') {
|
||||
values = hsl.rgb(values)
|
||||
}
|
||||
|
||||
values.push(Math.min(Math.max(parsed.alpha, 0), 1))
|
||||
|
||||
return values
|
||||
}
|
||||
34
node_modules/color-rgba/package.json
generated
vendored
Normal file
34
node_modules/color-rgba/package.json
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "color-rgba",
|
||||
"version": "3.0.0",
|
||||
"description": "Convert color string (or parseable argument) to RGBA array",
|
||||
"main": "index.js",
|
||||
"browser": "index.js",
|
||||
"type": "module",
|
||||
"module": "./index.js",
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/colorjs/color-rgba.git"
|
||||
},
|
||||
"keywords": [
|
||||
"color",
|
||||
"colorjs",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"color-space",
|
||||
"css"
|
||||
],
|
||||
"author": "Dmitry Iv <dfcreative@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/colorjs/color-rgba/issues"
|
||||
},
|
||||
"homepage": "https://github.com/colorjs/color-rgba#readme",
|
||||
"dependencies": {
|
||||
"color-parse": "^2.0.0",
|
||||
"color-space": "^2.0.0"
|
||||
}
|
||||
}
|
||||
33
node_modules/color-rgba/readme.md
generated
vendored
Normal file
33
node_modules/color-rgba/readme.md
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# color-rgba [](https://github.com/colorjs/color-rgba/actions/workflows/test.js.yml) [](https://bundlephobia.com/result?p=color-rgba) 
|
||||
|
||||
Convert color string to array with rgba channel values: `"rgba(127,127,127,.1)"` → `[127,127,127,.1]`.
|
||||
|
||||
## Usage
|
||||
|
||||
[](https://npmjs.org/package/color-rgba/)
|
||||
|
||||
```js
|
||||
const rgba = require('color-rgba')
|
||||
|
||||
rgba('red') // [255, 0, 0, 1]
|
||||
rgba('rgb(80, 120, 160)') // [80, 120, 160, 1]
|
||||
rgba('rgba(80, 120, 160, .5)') // [80, 120, 160, .5]
|
||||
rgba('hsla(109, 50%, 50%, .75)') // [87.125, 191.25, 63.75, .75]
|
||||
rgba`rgb(80 120 160 / 50%)` // [80, 120, 160, .5]
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `let [r, g, b, alpha] = rgba(color)`
|
||||
|
||||
Returns channels values as they are in the input `color` string argument. `alpha` is always from `0..1` range. `color` can be a CSS color string, an array with channel values, an object etc., see [color-parse](https://ghub.io/color-parse).
|
||||
|
||||
## Related
|
||||
|
||||
* [color-normalize](https://github.com/colorjs/color-normalize) − convert any input color argument into a defined output format.
|
||||
* [color-alpha](https://github.com/colorjs/color-alpha) − change alpha of a color string.
|
||||
* [color-interpolate](https://github.com/colorjs/color-interpolate) − interpolate by color palette.
|
||||
|
||||
## License
|
||||
|
||||
(c) 2017 Dima Yv. MIT License
|
||||
26
node_modules/color-rgba/test.js
generated
vendored
Normal file
26
node_modules/color-rgba/test.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import assert from 'assert'
|
||||
import rgba from './index.js'
|
||||
|
||||
assert.deepEqual(rgba('rgba(1,2,3,.5)'), [1, 2, 3, .5])
|
||||
assert.deepEqual(rgba('rgba(0,0,0,0)'), [0, 0, 0, 0])
|
||||
assert.deepEqual(rgba('hsla(0,0,0,1)'), [0, 0, 0, 1])
|
||||
assert.deepEqual(rgba('rgba(-300,-300,-300,-1)'), [0, 0, 0, 0])
|
||||
|
||||
assert.deepEqual(rgba('red'), [255, 0, 0, 1])
|
||||
assert.deepEqual(rgba('rgb(80, 120, 160)'), [80, 120, 160, 1])
|
||||
assert.deepEqual(rgba('rgba(80, 120, 160, .5)'), [80, 120, 160, .5])
|
||||
assert.deepEqual(rgba('rgba(80 120 160 / .5)'), [80, 120, 160, .5])
|
||||
assert.deepEqual(rgba('hsl(291 80% 50%)'), [198.89999999999995, 25.499999999999993, 229.5, 1])
|
||||
assert.deepEqual(rgba('hsl(0.8083333333333333turn 80% 50%)'), [198.89999999999995, 25.499999999999993, 229.5, 1])
|
||||
assert.deepEqual(rgba('hsla(109, 50%, 50%, .75)'), [87.125, 191.25, 63.75, 0.75])
|
||||
assert.deepEqual(rgba('#f00'), [255, 0, 0, 1])
|
||||
assert.deepEqual(rgba`#f00`, [255, 0, 0, 1])
|
||||
|
||||
assert.deepEqual(rgba('xyz'), [])
|
||||
// console.log(rgba('hsla(170, 50%, 45%, 1)'))
|
||||
|
||||
assert.deepEqual(rgba(0x00ff00), [0, 255, 0, 1])
|
||||
assert.deepEqual(rgba(new Number(0x00ff00)), [0, 255, 0, 1])
|
||||
|
||||
assert.deepEqual(rgba([1, 1, 1, 1]), [1, 1, 1, 1])
|
||||
assert.deepEqual(rgba(new Uint8Array([255, 255, 255, 255])), [255, 255, 255, 1])
|
||||
Reference in New Issue
Block a user