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

clipboard-colorspace-conversion

v1.0.7

Published

Convert higher color space to srgb on cmd+c and update it in the clipboard.

Downloads

12

Readme

Flowchart to JSON Illustration

Note: This plugin is aimed at developers/designers working with a environment/monitor that supports a color space with a wider gamut than sRGB. E.g. Figma running in a browser is limited to sRGB currently, however the desktop app supports the option to use the native OS one. You may need to enable this in the settings under: Figma > Preferences > Color Space > Unmanaged.

When working in a wider color gamut (like the display of a modern macbook, supporting p3) and coping colors to be rendered on the web you may find them to look different (notably less saturated), to what you designed. While this is to some extent a invadable consequence of converting to a smaller color gamut (sRGB), as some colors simply cannot be represented there, we can do better than clipping off the values that are out of range (which undermines all deltas of colors not inside the range) as well as linearly interpolating from the respective corners of the gamut (which is not perceptually uniform). There are better ways of converting colors to a lower color space while respecting both concerns. The specific implementation is explained here on colorjs.io. The result is by the nature of the problem not perfect but much more sensible. Especially as we are, as of recently, not limited to sRGB anymore on the web. The new CSS Color Module Level 4 specifies the color() function with which we can represent colors in wider color spaces, when supported. As this feature is decently new we provide a fallback sRGB representation as well, which is gamut mapped as explained above.

Installation

 $ npm i clipboard-colorspace-conversion

Or for CLI usage:

 $ npm i -g clipboard-colorspace-conversion

Usage

This library can be used as JS module (= API), as CLI or as a Figma plugin.

CLI

One time usage

The result will be copied to your clipboard if possible and logged to the console.

ccc <color>

color can be any HEX or rgb string copied from somewhere. Here are some examples that work: 0.2, 0.1, 1, 233 100 0, rgb(0, 0, 255), ff00ff, #f0f, #ff00ff00.

An example output would be:

`background: rgb(21.596% 9.3558% 100%);
background: color(display-p3 0.2 0.1 1);`

Watch mode

ccc

This will watch your clipboard, anything matching a color-code regex (see examples above), will be converted overridden in your clipboard. Whenever this happens a OS level notification will show. Clicking on it will undo the change.

Notifications depend on node-notifier. Hence the requirements are:

  • macOS: >= 10.8 for native notifications, or Growl if earlier.
  • Linux: notify-osd or libnotify-bin installed (Ubuntu should have this by default)
  • Windows: >= 8, or task bar balloons for Windows < 8. Growl as fallback. Growl takes precedence over Windows balloons.
  • General Fallback: Growl

Options

  • --inputColorSpace What is the colorspace of the input (your displays colorspace if the app where you got the color from does not do the conversion). Can be one of these. Defaults to p3 (as in the m1 mbp's display)

API

For one time usage:

import clipboardColorspaceConversion from "clipboard-colorspace-conversion"

const colorString = "0.2, 0.1, 1"
const attrb = "background: " // optional
const fromColorSpace = "p3"  // optional

const convertedStr = clipboardColorspaceConversion(colorString, attrb, fromColorSpace)

console.log(convertedStr) // 'background: rgb(21.596% 9.3558% 100%);\n' +
                          // 'background: color(display-p3 0.2 0.1 1);'

Contribute

All feedback is appreciated. Create a pull request or write an issue.