Skip to content

Repository files navigation

react-eyedropper

##Screenshots

Install

npm install --save react-eyedropper

Usage

importReact,{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>)}}

API

<EyeDropper initializedColor={this.setColor}/>

propsdescription
initializedColorType: function , required
callback, arg is object {r,g,b}
onInitType: function ,
pre condition
classNameType: string,
for style
titleType: string,
title

Dependencies

https://github.com/bfred-it/get-canvas-pixel-color/
https://github.com/niklasvh/html2canvas

License

ISC

About

Simple react component for get color from image or html colored element

Topics

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages