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

d3-cam02

v0.1.5

Published

CAM02 color space.

Downloads

6,840

Readme

d3-cam02

To access the latest version of d3-cam02, grab it on unpkg.

This module extends D3's native color support to also include CIECAM02 color. CIECAM02 is an updated color model that serves as an alternative to perceptually modeled spaces like CIELAB and CIELCh. One large difference compared to other perceptual color spaces is that it models colors after transforming them through the CAT02 chromatic adaptation transform which simulates responses from the eye's long, medium, and short cone responses (LMS). Both Jab and JCh assume average viewing conditions for the purposes of computing CAM02 color.

Before using this library, note that Jab and JCh are not Cartesian/polar space correlates of one another, because the J in CIECAM02's JCh and in CIECAM02-UCS's Jab are not equivalent. Jab is calculated via M.R. Luo and C. Li's uniform color space transform to better approximate perceptual uniformity. For an overview of CIECAM02, their transform, and comparisons to CIELAB, we recommend Luo and Li's paper entitled "CIECAM02 and Its Recent Developments".

d3-cam02 follows the same rules as d3-color. For example, to get the CIECAM02-UCS Jab representation of "steelblue":

var c = d3.jab("steelblue"); // {r: 70, g: 130, b: 180, opacity: 1}

You can also define Jab or JCh colors directly:

var c1 = d3.jab(80, 30, 10),
    c2 = d3.jch(50, 70, 270);

Just as in d3-color, you can also directly manipulate colors once they are initialized:

var c = d3.jab(80, 30, 10);
c.J += 5;
var hue = (180 / Math.PI) * Math.atan2(c.b, c.a);
c + ""; // transforms to RGB string formatting

Installation

After downloading the repo, run npm install, which will install any dependencies. You can optionally install from npm opposed to cloning directly from GitHub. Make sure to load d3-cam02 after d3-color.

Dependencies: d3-color

API Reference

Because this package extends d3-color, previously available color functions are similarly available in d3-cam02 (e.g., color.{rgb, brighter, darker, displayable}).

# d3.jab(J, a, b[, opacity]) <> # d3.jab(specifier) # d3.jab(color)

Constructs a new CIECAM02-UCS Jab color. The channel values are exposed as J, a and b properties on the returned instance. J refers to lightness, a refers to redness-to-greenness, and b refers to blueness-to-yellowness.

If J, a, and b are specified, these represent the channel values of the returned color; an opacity may also be specified. If a CSS Color Module Level 3 specifier string is provided, it is parsed and then converted to the Lab color space. See d3-color for examples. If a color instance is specified, it is converted to the RGB color space using color.rgb and then converted to Jab. (Colors already in the Jab color space skip the conversion to RGB.)

# d3.jch(J, C, h[, opacity]) <> # d3.jch(specifier) # d3.jch(color)

Constructs a new CIECAM02 JCh color. The channel values are exposed as J, C, and h properties on the returned instance. J refers to a lightness definition different than d3.jab, C refers to chroma, and h refers to hue. Jab transform's JCh lightness with the following transform: Jab.J = JCh.J / (1.0 + 0.007*(100.0 - JCh.J)).

If J, C and h are specified, these represent the channel values of the returned color; an opacity may also be specified. If a CSS Color Module Level 3 specifier string is provided, it is parsed and then converted to the Lab color space. See d3-color for examples. If a color instance is specified, it is converted to the RGB color space using color.rgb and then converted to JCh. (Colors already in the JCh color space skip the conversion to RGB.)