Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

get-best-contrast-color

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Issues
File Explorer

Advanced tools

get-best-contrast-color

Calculate the color in an array of colors that gives the highest contrast to another color.

    0.3.1latest
    GitHub

Version published
Maintainers
1
Weekly downloads
959
increased by19.13%

Weekly downloads

Readme

Source

Get best contrast color

Greenkeeper badge

get-best-contrast-color calculates which color in an array of colors gives the highest contrast to another color.

Doesn't handle transparency as of yet.

Installation

$ npm install get-best-contrast-color

Usage

import bestContrast from 'get-best-contrast-color'; // If you're not using EMS but CommonJS: // const bestContrast = require('get-best-contrast-color').default; const background1 = 'palevioletred'; const background2 = 'saddlebrown'; const colors = [ '#222', 'blue', 'rgb(255, 255, ,255)', ]; bestContrast(background1, colors); // '#222' bestContrast(background2, colors); // 'rgb(255, 255, 255)'

Signature

(background: string, colors: array) => string

Contributing

I appreciate your issues and PRs on Github!

Testing

yarn build && yarn test

Releasing

This project uses np.

  1. Make sure your changes are in master
  2. Run yarn release
  3. Follow the interactive release guide

Keywords

FAQs

Last updated on 16 Jul 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc