Coder Social home page Coder Social logo

duanruilong / react-color-thief Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chensiun/react-color-thief

0.0 1.0 0.0 2.01 MB

A React component for grabbing the color palette from an image(一个提取图片主要颜色的React组件)

Home Page: https://chensiun.github.io/react-color-thief/

License: MIT License

JavaScript 90.41% HTML 1.59% CSS 8.01%

react-color-thief's Introduction

React-Color-Thief

🎨 A React component for grabbing the color palette from an image. See a Demo

It is based on Lokesh's color-thief.

How to use

可以把src/ColorThief.js文件拷贝到自己的项目下,直接使用。

Get the dominant color from an image

const colorThief = new ColorThief()
colorThief.getColor(imgDom) //需要在Image onload完成后调用
colorThief.getColorFromUrl(imgUrl).then(...) //异步方法,返回一个Promise

Build a color palette from an image

In this example, we build an 8 color palette.

const colorThief = new ColorThief()
colorThief.getPalette(imgDom, 8) //需要在Image onload完成后调用

ColorThief Methods

function returns
getColor(imgDom[, quality]) [r, g, b]
getPalette(imgDom[, colorCount, quality]) [ [r, g, b], [r, g, b], ...]
getColorFromUrl(imgUrl[, quality]) [r, g, b]
getColorAsync(imgUrl[, quality]) [r, g, b]
convertColorRgb(rgbArray) "rgb(r, g, b)"

colorCount determines the size of the palette, the number of colors returned. If not set, it defaults to 10.
quality is an optional argument. It needs to be an integer. 1 is the highest quality settings. 10 is the default. There is a trade-off between quality and speed. The bigger the number, the faster the palette generation but the greater the likelihood that colors will be missed.

react-color-thief's People

Contributors

chensiun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.