npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

safe-dye

v1.0.4

Published

Check color similarity in a color-blind safe way

Downloads

9

Readme

safe-dye

What is this?

A small Javascript package that helps identify if two colors are distinguishable to individuals with different kinds of color blindness.

How this works

Given two Hex RGB codes, we can create two simulated RGB codes. These would be the colors seen by a color blind person, depending on color blindness type. Using DeltaE2000 algorithm, we determine if the simulated colors are distingushable. If two simulated colors are not distinguishable, we say that the original colors are not distingushable to the color blind.

Installation & Usage

Install with npm

npm install safe-dye

Usage

After requiring, use any of the available validation functions on a set of 2 colors in HEX, i.e #00A55A. The function will return true if the colors are distinguishable or false otherwise.

const SafeDye = require('safe-dye');

// Will return true if color1 and color2 are distinguishable for red-green type color blindness (Protanopia)
SafeDye.validateRedGreen(color1, color2);

// Will return true if color1 and color2 are distinguishable for blue-yellow type color blindness (Tritanopia)
SafeDye.validateBlueYellow(color1, color2);

// Will return true if both validateRedGreen and validateBlueYellow return true
SafeDye.validate(color1, color2);

// Will return true if color1 and color2 are distinguishable for normal color vision
SafeDye.validateNormal(color1, color2);

Why I made this

As a frontend developer, I sometimes find myself working on interfaces that allow users to customize color related options. As a simple example, consider choosing the color of text over a different background color for a blog post. While there are various tools out there to simulate color blind vision, we cannot expect our end users to use them when writing a colorful blog post :) With this library, we can provide users with feedback and let them know that certain color combinations can be problematic for some audiences.

Attributions

This library uses color-blind and DeltaE, which makes this package very simple. Both do a great job in educating about color blindness and visual perceptions of colors - super cool and worth checking out :)

References

  1. About the DeltaE algorithm
  2. Designing Colorblind Friendly Websites