Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including d3-hcg with all npm packages installed. Try it out:

var d3Hcg = require("d3-hcg")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

d3-hcg v0.0.10

The HCG (Hue, Chroma, Grayness) color space.


This module implements the HCG (Hue, Chroma, Grayness) color space.


If you use NPM, npm install d3-hcg. Otherwise, download the latest release. You can also load directly from as a standalone library. AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:

<script src=""></script>
<script src=""></script>

var yellow = d3.hcg("yellow"); // {h: 60, c: 1, g: 0, opacity: 1}


Try d3-hcg in your browser.

API Reference

# d3.hcg(h, c, g[, opacity])
# d3.hcg(specifier)
# d3.hcg(color)

Constructs a new HCG color. The channel values are exposed as h, c and g properties on the returned instance.

If h, c and g 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 specified, it is parsed and then converted to the HCG 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 HCG.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free