šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

get-best-contrast-color

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-best-contrast-color

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

0.3.1
latest
Source
npm
Version published
Weekly downloads
343
2.39%
Maintainers
1
Weekly downloads
Ā 
Created
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.

  • Make sure your changes are in master
  • Run yarn release
  • Follow the interactive release guide

Keywords

color

FAQs

Package last updated on 16 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts