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-hsluv with all npm packages installed. Try it out:

var d3Hsluv = require("d3-hsluv")

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

d3-hsluv v0.1.2

HSLuv, the human-friendly HSl (Hue, Saturation, Lightness) color space.

d3-hsluv

This module implements the HSLuv (Hue, Saturation, Lightness) color space.

Installing

If you use NPM, npm install d3-hsluv. AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:

<script src="https://d3js.org/d3-color.v1.min.js"></script>
<script>

var yellow = d3.hsluv("yellow"); // {l: 85.9, u: 100, v: 97.1, opacity: 1}

</script>

Try d3-hsluv in your browser.

API Reference

# d3.hsluv(l, u, v[, opacity])
# d3.hsluv(specifier)
# d3.hsluv(color)

Constructs a new hsluv color. The channel values are exposed as l, u and v properties on the returned instance.

If l, u and v 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 hsluv 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 hsluv.

# d3.interpolateHsluv(a, b) <>

Returns an HSLuv color space interpolator between the two colors a and b. The colors a and b need not be in HSLuv; they will be converted to HSLuv using d3.hsluv. If either color’s hue or chroma is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is an RGB string.

# d3.interpolateHsluvLong(a, b) <>

Like interpolateHsluv, but does not use the shortest path between hues.

Metadata

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