https://github.com/rileyjshaw/average-color
:tada: Returns the average color from a list of HSL arrays
https://github.com/rileyjshaw/average-color
Last synced: 30 days ago
JSON representation
:tada: Returns the average color from a list of HSL arrays
- Host: GitHub
- URL: https://github.com/rileyjshaw/average-color
- Owner: rileyjshaw
- License: mit
- Created: 2016-06-17T00:16:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-16T00:34:05.000Z (almost 8 years ago)
- Last Synced: 2025-08-24T16:36:37.536Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/average-color
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```
###############################################################################
################################ average-color ################################
###############################################################################Returns the average color from a list of HSL arrays.
HSL colors are converted from cylindrical coordinates to Cartesian
coordinates, averaged, and converted back to HSL.To retain consistent saturation, the Cartesian average is ignored and a
simple arithmetic mean is returned. This is an aesthetic choice; either value
could be considered valid.For both input and output, the expected range is: H => [0, 360]
S => [0, 100]
L => [0, 100]An additional `averageColorNormalized` function is provided that expects
similar input ranges, but outputs component values in the [0, 1] range.@param {[H, S, L][]} colors A list of HSL value arrays (colors can also
be passed in as separate arguments).@return {[H, S, L]} The average color.
Installation
------------npm i average-color
Usage
-----import averageColor, {averageColorNormalized} from 'average-color';
const newColor = averageColor([20, 70, 40], [355, 70, 60]);
// Result: [7.5, 70, 50]const normalizedColor = averageColorNormalized([20, 70, 40], [355, 70, 60]);
// Result: [0.02083, 0.7, 0.5]-------------------------------------------------------------------------------
Licensed under MIT:
https://github.com/rileyjshaw/average-color/blob/master/LICENSECreated by rileyjshaw:
http://rileyjshaw.com/
```