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

good-friends-colors

v1.0.0

Published

Find the color difference between the two colors and determine if they are similar

Downloads

740

Readme

test

good-friends-colorsは2つの色が似た色かどうかを判定する事が出来ます。

インストール

npm:

$ npm install good-friends-colors

yarn:

$ yarn add good-friends-colors

使い方

2つの色が似ているかの判定

人の目で違う色と判断しづらいもの」をCIEDE2000色素式と呼ばれる計算式で判定します。

import gf from 'good-friends-colors'

const c1 = { r: 20, g: 192, b: 59 }
const c2 = { r: 30, g: 188, b: 63 }

const result = gf(c1).isGoodFriend(c2)
console.log(result)
// => true

import gf from 'good-friends-colors'

const c1 = { r: 20, g: 192, b: 59 }
const c2 = { r: 255, g: 188, b: 63 }

const result = gf(c1).isGoodFriend(c2)
console.log(result)
// => false

2つの色の差を求める

2つの色の差を求めます。
こちらでもCIEDE2000色素式を使用しています。

import gf from 'good-friends-colors'

const c1 = { r: 20, g: 192, b: 59 }
const c2 = { r: 30, g: 188, b: 63 }

const result = gf(c1).diff(c2)
console.log(result)
// => 1.238409519990517

import gf from 'good-friends-colors'

const c1 = { r: 20, g: 192, b: 59 }
const c2 = { r: 255, g: 188, b: 63 }

const result = gf(c1).diff(c2)
console.log(result)
// => 40.10746575803398

オプション

似た色かを判定する際の許容値を変更出来ます。

default: 2

import gf from 'good-friends-colors'

const c1 = { r: 20, g: 192, b: 59 }
const c2 = { r: 5, g: 192, b: 120 }

const diff = gf(c1).diff(c2)
console.log(diff)
// => 9.302586534325725


const result1 = gf(c1).isGoodFriend(c2)
console.log(result1)
// => false

const result2 = gf(c1).isGoodFriend(c2, 10)
console.log(result2)
// => true