npm install --save react-eyedropperimportReact,{Component}from'react'importEyeDropperfrom'react-eyedropper'classAppextendsComponent{state={r: 255,g: 255,b: 255}setColor=({ r, g, b })=>{this.setState({ r, g, b })}render(){const{r, g, b}=this.statereturn(<div><divclassName="main"><divclassName="container first">rgb(106, 0, 0)</div><divclassName="container second">rgb(106, 124, 0)</div><divclassName="container third">rgb(106, 124, 138)</div><divclassName="container fourth">rgb(15, 124, 138)</div><divclassName="container fifth">rgb(15, 44, 138)</div><divclassName="container sixth">rgb(219, 238, 97)</div><divclassName="container seventch">gradient</div></div><divclassName="result"><divclassName="container "style={{backgroundColor: `rgb(${r}, ${g}, ${b})`}}>rgb({r}, {g}, {b})</div></div><divclassName="eye-drop-container"><EyeDropperinitializedColor={this.setColor}/></div><divid="container"><imgsrc="./test.jpg"id="sample"/></div></div>)}}| props | description |
|---|---|
initializedColor | Type: function , requiredcallback, arg is object {r,g,b} |
onInit | Type: function , pre condition |
className | Type: string, for style |
title | Type: string, title |
https://github.com/bfred-it/get-canvas-pixel-color/
https://github.com/niklasvh/html2canvas
ISC
