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

colorpath

v0.1.4

Published

Find path for colors

Downloads

17

Readme

安装

npm install colorpath

使用

colorpath 支持以下三个函数的运算和逆运算:

  • tint
  • shade
  • mix

引入 colorpath:

import clp from 'colorpath'

接下来就可以使用以下 API(参数中的 sourceColordestinationColormixer 均支持十六进制和 RGB 两种表示法):

  • tint(sourceColor, percentage)
clp.tint('#ff08d5', 0.4) //[255, 107, 230]
  • findTint(sourceColor, destinationColor)
clp.findTint('#ff08d5', '#ff6be6') //0.4028
  • shade(sourceColor, percentage)
clp.shade('#ffc8d5', 0.4) //[153, 120, 128]
  • findShade(sourceColor, destinationColor)
clp.findShade('#ffc8d5', '#997880') //0.3997
  • mix(sourceColor, mixer, percentage)
clp.mix('#ffc8d5', 'd3985a', 0.4) //[229, 171, 139]
  • findMixer(sourceColor, destinationColor)
clp.findMixer('#ffc8d5', '#e5ab8b') //{ mixer: [ 180, 117, 0 ], percentage: 0.6526 }
  • findPath(sourceColor, destinationColor)
clp.findPath('#ff08d5', '#ff6be6') //{ method: 'tint', percentage: 0.4028 }
clp.findPath('#ffc8d5', '#997880') //{ method: 'shade', percentage: 0.3997 }
clp.findPath('#ffc8d5', '#e5ab8b') //{ method: 'mix', mixer: [ 180, 117, 0 ], percentage: 0.6526 }

注意:若 findTintfindShade 无解,则会抛出一个错误;而 findPath 会先尝试调用 findTintfindShade,若发现无解会调用 findMixer。因此,如果不确定两种颜色之间是否存在 tint 或 shade 的关系,建议直接使用 findPath

命令行工具

安装

npm install -g colorpath

使用

$ clp <arguments> <method>

其中 arguments 为调用参数,method 为调用方法。上述例子中的 clp.findPath('#ffc8d5', '#e5ab8b') 对应的命令行调用为:

$ clp ffc8d5 e5ab8b --find-path