diff --git a/README.md b/README.md index a7f2d52..ee82b00 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ const steelblue = d3.rgb("steelblue"); ## API Reference -# d3.color(specifier) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# d3.color(specifier) [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Parses the specified [CSS Color Module Level 3](http://www.w3.org/TR/css3-color/#colorunits) *specifier* string, returning an [RGB](#rgb) or [HSL](#hsl) color, along with [CSS Color Module Level 4 hex](https://www.w3.org/TR/css-color-4/#hex-notation) *specifier* strings. If the specifier was not valid, null is returned. Some examples: @@ -104,11 +104,11 @@ Note: this function may also be used with `instanceof` to test if an object is a This color’s opacity, typically in the range [0, 1]. -# *color*.rgb() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.rgb() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns the [RGB equivalent](#rgb) of this color. For RGB colors, that’s `this`. -# color.copy([values]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# color.copy([values]) [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a copy of this color. If *values* is specified, any enumerable own properties of *values* are assigned to the new returned color. For example, to derive a copy of a *color* with opacity 0.5, say @@ -116,35 +116,39 @@ Returns a copy of this color. If *values* is specified, any enumerable own prope color.copy({opacity: 0.5}) ``` -# *color*.brighter([k]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.brighter([k]) [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a brighter copy of this color. If *k* is specified, it controls how much brighter the returned color should be. If *k* is not specified, it defaults to 1. The behavior of this method is dependent on the implementing color space. -# *color*.darker([k]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.darker([k]) [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a darker copy of this color. If *k* is specified, it controls how much darker the returned color should be. If *k* is not specified, it defaults to 1. The behavior of this method is dependent on the implementing color space. -# *color*.displayable() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.displayable() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns true if and only if the color is displayable on standard hardware. For example, this returns false for an RGB color if any channel value is less than zero or greater than 255 when rounded, or if the opacity is not in the range [0, 1]. -# *color*.formatHex() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.formatHex() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a hexadecimal string representing this color in RGB space, such as `#f7eaba`. If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255. -# *color*.formatHsl() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.formatHex8() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") + +Returns a hexadecimal string representing this color in RGBA space, such as `#f7eaba90`. If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255. + +# *color*.formatHsl() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a string representing this color according to the [CSS Color Module Level 3 specification](https://www.w3.org/TR/css-color-3/#hsl-color), such as `hsl(257, 50%, 80%)` or `hsla(257, 50%, 80%, 0.2)`. If this color is not displayable, a suitable displayable color is returned instead by clamping S and L channel values to the interval [0, 100]. -# *color*.formatRgb() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.formatRgb() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a string representing this color according to the [CSS Object Model specification](https://drafts.csswg.org/cssom/#serialize-a-css-component-value), such as `rgb(247, 234, 186)` or `rgba(247, 234, 186, 0.2)`. If this color is not displayable, a suitable displayable color is returned instead by clamping RGB channel values to the interval [0, 255]. -# *color*.toString() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *color*.toString() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") An alias for [*color*.formatRgb](#color_formatRgb). -# d3.rgb(r, g, b[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source")
+# d3.rgb(r, g, b[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source")
# d3.rgb(specifier)
# d3.rgb(color)
@@ -152,11 +156,11 @@ Constructs a new [RGB](https://en.wikipedia.org/wiki/RGB_color_model) color. The If *r*, *g* 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 specified, it is parsed and then converted to the RGB color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb). Note that unlike [*color*.rgb](#color_rgb) this method *always* returns a new instance, even if *color* is already an RGB color. -# *rgb*.clamp() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *rgb*.clamp() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a new RGB color where the `r`, `g`, and `b` channels are clamped to the range [0, 255] and rounded to the nearest integer value, and the `opacity` is clamped to the range [0, 1]. -# d3.hsl(h, s, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source")
+# d3.hsl(h, s, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source")
# d3.hsl(specifier)
# d3.hsl(color)
@@ -164,11 +168,11 @@ Constructs a new [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV) color. The cha If *h*, *s* and *l* 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 HSL color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to HSL. (Colors already in the HSL color space skip the conversion to RGB.) -# *hsl*.clamp() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") +# *hsl*.clamp() [<>](https://github.com/d3/d3-color/blob/main/src/color.js "Source") Returns a new HSL color where the `h` channel is clamped to the range [0, 360), and the `s`, `l`, and `opacity` channels are clamped to the range [0, 1]. -# d3.lab(l, a, b[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
+# d3.lab(l, a, b[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/lab.js "Source")
# d3.lab(specifier)
# d3.lab(color)
@@ -176,17 +180,17 @@ Constructs a new [CIELAB](https://en.wikipedia.org/wiki/Lab_color_space#CIELAB) If *l*, *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 specified, it is parsed and then converted to the CIELAB color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to CIELAB. (Colors already in the CIELAB color space skip the conversion to RGB, and colors in the HCL color space are converted directly to CIELAB.) -# d3.gray(l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
+# d3.gray(l[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/lab.js "Source")
Constructs a new [CIELAB](#lab) color with the specified *l* value and *a* = *b* = 0. -# d3.hcl(h, c, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
+# d3.hcl(h, c, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/lab.js "Source")
# d3.hcl(specifier)
# d3.hcl(color)
Equivalent to [d3.lch](#lch), but with reversed argument order. -# d3.lch(l, c, h[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
+# d3.lch(l, c, h[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/lab.js "Source")
# d3.lch(specifier)
# d3.lch(color)
@@ -194,7 +198,7 @@ Constructs a new [CIELChab](https://en.wikipedia.org/wiki/CIELAB_colo If *l*, *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 specified, it is parsed and then converted to CIELChab color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to CIELChab. (Colors already in CIELChab color space skip the conversion to RGB, and colors in CIELAB color space are converted directly to CIELChab.) -# d3.cubehelix(h, s, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/cubehelix.js "Source")
+# d3.cubehelix(h, s, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/main/src/cubehelix.js "Source")
# d3.cubehelix(specifier)
# d3.cubehelix(color)