1.1. Basic usage
Get image colors.
import React from 'react'; import ReactDOM from 'react-dom'; import Chameleon from 'react-chameleon'; const ColorsRenderer = function(props) { const { reactChameleonColors } = props; const getColor = c => `rgba(${c.r},${c.g},${c.b},${c.alpha})`; if (!reactChameleonColors) { return <p>Parse colors...</p>; } return <ul> {reactChameleonColors.map(color => <li style={{ paddingLeft: '10px', borderLeft: `15px solid ${getColor(color)}`, listStyleType: 'none' }}> <code>{JSON.stringify(color, null, 2)}</code> </li> )} </ul>; }; const ChameleonColorsRenderer = Chameleon(ColorsRenderer); ReactDOM.render( <ChameleonColorsRenderer img={./path/to/img.png} colorDifference={50} />, document.querySelector('body') );