https://github.com/d3/d3-hcg
The HCG (Hue, Chroma, Grayness) color space derived from the Munsell color system.
https://github.com/d3/d3-hcg
Last synced: 8 months ago
JSON representation
The HCG (Hue, Chroma, Grayness) color space derived from the Munsell color system.
- Host: GitHub
- URL: https://github.com/d3/d3-hcg
- Owner: d3
- License: bsd-3-clause
- Created: 2016-07-01T18:37:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-02T08:23:44.000Z (over 6 years ago)
- Last Synced: 2025-01-30T15:25:22.696Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 21
- Watchers: 11
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# d3-hcg
This module implements the [HCG](https://github.com/acterhd/hcg-color) (Hue, Chroma, Grayness) color space.
## Installing
If you use NPM, `npm install d3-hcg`. Otherwise, download the [latest release](https://github.com/d3/d3-hcg/releases/latest). You can also load directly from [d3js.org](https://d3js.org) as a [standalone library](https://d3js.org/d3-hcg.v0.0.min.js). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
var yellow = d3.hcg("yellow"); // {h: 60, c: 1, g: 0, opacity: 1}
```
[Try d3-hcg in your browser.](https://tonicdev.com/npm/d3-hcg)
## 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](https://github.com/d3/d3-color#color) for examples. If a [*color*](https://github.com/d3/d3-color#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](https://github.com/d3/d3-color#color_rgb) and then converted to HCG.