incredible-color-averager
v1.0.0
Published
Get the average color of your img element in a css-readable format
Downloads
2
Maintainers
Readme
This package provides a getAverageColor
function returns css-readable color with syntax like getAverageColour(img, type, inv)
, where img
is youre <img>
HTMLElement, type
is type of color model you choose ('RGB'
or 'HEX'
), inv
— optional parameter (set to true
if you want an inverted resulting value).
Install
$ npm install incredible-color-averager --save
Usage
const getAverageColour = require('incredible-color-averager')
// ES2015 modules
import getAverageColour from 'incredible-color-averager'
const img = document.querySelector('img')
const rgbColor = getAverageColour(img, "RGB")
console.log(rgbColor)
/// rgb(255, 255, 255)
const invertHexColor = getAverageColour(img, "HEX", true)
console.log(invertHexColor)
/// #000000
License
MIT