Coder Social home page Coder Social logo

claytonmccray / react-native-get-pixel-color Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dudyn5ky1/react-native-get-pixel-color

0.0 1.0 2.0 34 KB

Get HEX color value from image in React Native

Java 37.96% JavaScript 14.68% Objective-C 35.77% Ruby 11.60%

react-native-get-pixel-color's Introduction

react-native-get-pixel-color

npm version npm

Description

Get HEX color value from image in React Native. Works both for iOS and Android.

Getting started

$ npm install react-native-get-pixel-color --save

or

$ yarn add react-native-get-pixel-color

Important note

For iOS you should pass the path to the file, however for Android you should pass base64 string of the image. In the near future both implementations would be unified to both use only one of these options.

Usage (iOS)

import GetPixelColor from 'react-native-get-pixel-color';

// upload image
GetPixelColor.setImage(pathToFile)
  .then(() => {
    // your callback if needed
  })
  .catch(err => {
    // Handle errors
  });

// pick a color at X, Y
GetPixelColor.pickColorAt(x, y)
  .then((color) => {
    // HEX color value returned
  })
  .catch(err => {
    // Handle errors
  });

Usage (Android)

import GetPixelColor from 'react-native-get-pixel-color';

// upload image
GetPixelColor.init(base64)
  .then(() => {
    // your callback if needed
  })
  .catch(err => {
    // Handle errors
  });

// pick a color at X, Y
GetPixelColor.pickColorAt(x, y)
  .then((color) => {
    // HEX color value returned
  })
  .catch(err => {
    // Handle errors
  });

Disclaimer

At this moment iOS implementation of this module is forked from https://github.com/crispipear/react-native-pixel-color.

The main difference is that we upload an image only once and picking colors by coordinates as many times as we want. In the original implementation the new image was uploaded each time we want to pick 1 pixel

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.