GithubHelp home page GithubHelp logo

denisrybalka / detect-color Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 61 KB

Takes a string representing rgb code as input and outputs an object with the name of closest detected color.

Home Page: https://www.npmjs.com/package/detect-color

JavaScript 100.00%
rgb hex colors css-colors color-names

detect-color's Introduction

detect-color

Takes a string representing RGB or HEX code as input and outputs an object with the name of closest detected CSS color name. Also it can detect shades of all basic colors (for example: indianred, darkred and tomate are the shades of red color). It uses Euclid's distance formula in RGB dimension to calculate distance to closest color.

gif

Install


$ npm install detect-color

Usage


import { detectCssColor } from 'detect-color';

let color = detectCssColor("rgb(70,130,180)");
let color2 = detectCssColor("#00ff7f");

console.log(color.detectedColor); // => steelblue
console.log(color2.detectedColor); // => springgreen

Detecting shades


As I said before, you can also detect shades of all basic colors. For example if you want to know if palegreen is a shade of green color, you can simply use detectColor() function. It takes rgb or hex code of your shade color and returns closest found color.

import { detectColor } from 'detect-color';

let color = detectColor("#32cd32"); // limegreen
let color2 = detectColor("rgb(34,139,34)"); // forestgreen

console.log(color.detectedColor); // => green
console.log(color2.detectedColor); // => green

detect-color's People

Contributors

denisrybalka avatar

Stargazers

 avatar  avatar  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.