Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

43
node_modules/hsl-to-rgb-for-reals/README.md generated vendored Normal file
View File

@@ -0,0 +1,43 @@
# hsl-to-rgb-for-reals
##HSL -> RGB
Convert HSL values (hue, saturation, light) to RGB values (red, green, blue).
Expected values:
Hue: [0, 360[
Saturation: [0, 1]
Lightness: [0, 1]
## For Reals?
Author forgot to export their function in the hsl-to-rgb module,
there's a PR that's been sitting for over a year (at time of writing).
Let's use `hsl-to-rgb-for-reals` until original author merges. Huzzah!
Funny story - I forgot to module export in v1.0.0 too! Don't use 1.0.0.
Getting started:
```sh
npm install hsl-to-rgb-for-reals --save
```
Use:
```js
var converter = require('hsl-to-rgb-for-reals');
var slateBlue = converter(223, 0.44, 0.56);
console.log(slateBlue);
// logs [93, 121, 192]
```
## Problems
Bug the original author :D
<https://github.com/kayellpeee/hsl_rgb_converter/issues>
## Acknowledgements
* kayellpeee
* sponsored by [nearForm](http://nearform.com)

58
node_modules/hsl-to-rgb-for-reals/converter.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
// expected hue range: [0, 360)
// expected saturation range: [0, 1]
// expected lightness range: [0, 1]
var hslToRgb = function(hue, saturation, lightness){
// based on algorithm from http://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
if( hue == undefined ){
return [0, 0, 0];
}
var chroma = (1 - Math.abs((2 * lightness) - 1)) * saturation;
var huePrime = hue / 60;
var secondComponent = chroma * (1 - Math.abs((huePrime % 2) - 1));
huePrime = Math.floor(huePrime);
var red;
var green;
var blue;
if( huePrime === 0 ){
red = chroma;
green = secondComponent;
blue = 0;
}else if( huePrime === 1 ){
red = secondComponent;
green = chroma;
blue = 0;
}else if( huePrime === 2 ){
red = 0;
green = chroma;
blue = secondComponent;
}else if( huePrime === 3 ){
red = 0;
green = secondComponent;
blue = chroma;
}else if( huePrime === 4 ){
red = secondComponent;
green = 0;
blue = chroma;
}else if( huePrime === 5 ){
red = chroma;
green = 0;
blue = secondComponent;
}
var lightnessAdjustment = lightness - (chroma / 2);
red += lightnessAdjustment;
green += lightnessAdjustment;
blue += lightnessAdjustment;
return [
Math.abs(Math.round(red * 255)),
Math.abs(Math.round(green * 255)),
Math.abs(Math.round(blue * 255))
];
};
module.exports = hslToRgb;

32
node_modules/hsl-to-rgb-for-reals/package.json generated vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"name": "hsl-to-rgb-for-reals",
"version": "1.1.1",
"description": "simple HSL to RGB converter",
"main": "converter.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "https://github.com/davidmarkclements/hsl_rgb_converter/"
},
"keywords": [
"hsl",
"rgb",
"color",
"converter",
"convert",
"hue",
"saturation",
"light"
],
"license": "ISC",
"bugs": {
"url": "https://github.com/kayellpeee/hsl_rgb_converter/issues"
},
"homepage": "https://github.com/davidmarkclements/hsl_rgb_converter/",
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^6.2.0"
}
}

View File

@@ -0,0 +1,12 @@
const sample = require('./sample');
const hslToRgb = require('../converter');
const expect = require('chai').expect;
describe('hslToRgb', function () {
sample.forEach(v => {
it(`converts hsl(${v.hsl.h}, ${v.hsl.s}%, ${v.hsl.l}%) to rgb(${v.rgb.r}, ${v.rgb.g}, ${v.rgb.b})`, () => {
const converted = hslToRgb(Number(v.hsl.h), Number(v.hsl.s)/100, Number(v.hsl.l)/100);
expect(converted).to.eql([Number(v.rgb.r), Number(v.rgb.g), Number(v.rgb.b)]);
})
});
});

1
node_modules/hsl-to-rgb-for-reals/test/sample.json generated vendored Normal file

File diff suppressed because one or more lines are too long