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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sky-color

v0.0.0

Published

A powerful JavaScript color processing library supporting multiple color spaces conversion

Readme

Sky Color - JavaScript 颜色处理库

Sky Color 是一个功能强大的 JavaScript 颜色处理库,支持多种颜色空间之间的转换,包括 RGB、CMYK、HSL、HSV、HSI、HSY、LAB、LCH 等。

功能特性

  • 多种颜色空间转换支持
  • 颜色对象封装
  • 十六进制、数字格式颜色解析
  • 颜色值格式化输出

安装

npm i sky-color

支持的颜色空间转换

创建颜色对象

  • rgb(r, g, b) - 创建 RGB 颜色
  • rgba(r, g, b, a) - 创建 RGBA 颜色
  • hsl(h, s, l) - 通过 HSL 创建颜色
  • hsla(h, s, l, a) - 通过 HSLA 创建颜色
  • hsv(h, s, v) - 通过 HSV 创建颜色
  • hsi(h, s, i) - 通过 HSI 创建颜色
  • hsy(h, s, y) - 通过 HSY 创建颜色
  • lab(l, a, b) - 通过 LAB 创建颜色
  • lch(l, c, h) - 通过 LCH 创建颜色
  • lcha(l, c, h, a) - 通过 LCHA 创建颜色
  • hcl(h, c, l) - 通过 HCL 创建颜色
  • hcla(h, c, l, a) - 通过 HCLA 创建颜色

解析颜色字符串

  • parseColor(hex) - 解析十六进制颜色字符串或数字

颜色转换函数

  • rgb2cmyk(r, g, b) - RGB 转 CMYK
  • cmyk2rgb(c, m, y, k) - CMYK 转 RGB
  • rgb2hsl(r, g, b) - RGB 转 HSL
  • hsl2rgb(h, s, l) - HSL 转 RGB
  • rgb2hsi(r, g, b) - RGB 转 HSI
  • hsi2rgb(h, s, i) - HSI 转 RGB
  • hsv2rgb(h, s, v) - HSV 转 RGB
  • rgb2hsv(r, g, b) - RGB 转 HSV
  • rgb2xyz(r, g, b) - RGB 转 XYZ
  • rgb2lab(r, g, b) - RGB 转 LAB
  • lab2rgb(l, a, b) - LAB 转 RGB
  • lab2lch(l, a, b) - LAB 转 LCH
  • rgb2lch(r, g, b) - RGB 转 LCH
  • lch2lab(l, c, h) - LCH 转 LAB
  • lch2rgb(l, c, h) - LCH 转 RGB
  • hsy2rgb(h, s, y) - HSY 转 RGB
  • rgb2hsy(r, g, b) - RGB 转 HSY
  • hcl2rgb(h, c, l) - HCL 转 RGB

Color 类

Color 类提供了面向对象的颜色处理方式:

// 创建颜色实例
const color = new Color(r, g, b, a);

// 获取颜色属性
color.rgb()     // 获取 RGB 值
color.rgba()    // 获取 RGBA 值
color.alpha()   // 获取透明度值
color.hex()     // 获取十六进制表示
color.num()     // 获取数字表示
color.toString() // 转换为字符串(十六进制)

使用示例

// 引入库
import { rgb2hsl, hsl2rgb, Color } from './color.js';

// 颜色空间转换
const hsl = rgb2hsl(255, 0, 0); // RGB 转 HSL
const rgb = hsl2rgb(0, 1, 0.5); // HSL 转 RGB

// 使用 Color 类
const color = new Color(255, 0, 0, 1);
console.log(color.hex()); // "#ff0000"
console.log(color.rgb()); // [255, 0, 0]

// 使用快捷函数创建颜色
const red = rgb(255, 0, 0);
const blue = hsl(240, 1, 0.5);

许可证

MIT