@types/d3-color
- Version 3.1.3
- Published
- 27.9 kB
- No dependencies
- MIT license
Install
npm i @types/d3-color
yarn add @types/d3-color
pnpm add @types/d3-color
Overview
TypeScript definitions for d3-color
Index
Variables
Interfaces
Type Aliases
Variables
variable color
const color: ColorFactory;
A Color factory object, which may also be used with instanceof to test if an object is a color instance.
variable cubehelix
const cubehelix: CubehelixColorFactory;
A color factory object for Dave Green's Cubehelix colors, which may also be used with instanceof to test if an object is a Cubehelix color instance.
variable gray
const gray: GrayColorFactory;
A gray color factory for Lab (CIELAB) colors.
variable hcl
const hcl: HCLColorFactory;
An HCL (CIELCH) color factory object, which may also be used with instanceof to test if an object is an HCL color instance.
variable hsl
const hsl: HSLColorFactory;
An HSL color factory object, which may also be used with instanceof to test if an object is an HSL color instance.
variable lab
const lab: LabColorFactory;
A Lab (CIELAB) color factory object, which may also be used with instanceof to test if an object is a Lab color instance.
variable lch
const lch: LCHColorFactory;
An LCH (CIELCH) color factory function to create an HCL color object.
variable rgb
const rgb: RGBColorFactory;
An RGB color factory object, which may also be used with instanceof to test if an object is an RGB color instance.
Interfaces
interface Color
interface Color {}
A Color object which serves as a base class for colorspace-specific sub-class implementations.
method displayable
displayable: () => boolean;
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, or if the opacity is not in the range [0, 1].
method formatHex
formatHex: () => string;
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.
method formatHex8
formatHex8: () => string;
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.
method formatHsl
formatHsl: () => string;
Returns a string representing this color according to the CSS Color Module Level 3 specification, 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].
method formatRgb
formatRgb: () => string;
Returns a string representing this color according to the CSS Object Model specification, 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].
method hex
hex: () => string;
Deprecated
Use color.formatHex.
method toString
toString: () => string;
Returns a string representing this color according to the CSS Object Model specification, 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. For example, RGB channel values greater than 255 are clamped to 255.
interface ColorCommonInstance
interface ColorCommonInstance {}
A helper interface of methods common to color objects (including colors defined outside the d3-color standard module, e.g. in d3-hsv). This interface
method brighter
brighter: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much brighter the returned color should be.
method darker
darker: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much darker the returned color should be.
method displayable
displayable: () => boolean;
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, or if the opacity is not in the range [0, 1].
method hex
hex: () => string;
Returns a hexadecimal string representing this color. 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.
method rgb
rgb: () => RGBColor;
Returns the RGB equivalent of this color. For RGB colors, that’s "this".
method toString
toString: () => string;
Returns a string representing this color according to the CSS Object Model specification, 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. For example, RGB channel values greater than 255 are clamped to 255.
interface ColorFactory
interface ColorFactory extends Function {}
A Color factory object, which may also be used with instanceof to test if an object is a color instance.
property prototype
readonly prototype: Color;
Prototype of the factory, which can be used for instanceof testing
call signature
(cssColorSpecifier: string): RGBColor | HSLColor | null;
Parses the specified CSS Color Module Level 3 specifier string, returning an RGB or HSL color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS Color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): RGBColor | HSLColor;
Converts the provided color instance and returns an RGB or HSL color.
Parameter color
A permissible color space instance.
interface CubehelixColor
interface CubehelixColor extends Color {}
Dave Green’s Cubehelix color object.
property h
h: number;
Hue channel value.
property l
l: number;
Lightness channel value.
property opacity
opacity: number;
Opacity value.
property s
s: number;
Saturation channel value.
method brighter
brighter: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much brighter the returned color should be.
method copy
copy: (values?: { h?: number | undefined; s?: number | undefined; l?: number | undefined; opacity?: number | undefined;}) => this;
Returns a copy of this color.
Parameter values
If values is specified, any enumerable own properties of values are assigned to the new returned color.
method darker
darker: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much darker the returned color should be.
method rgb
rgb: () => RGBColor;
Returns the RGB color equivalent of this color.
interface CubehelixColorFactory
interface CubehelixColorFactory extends Function {}
A color factory object for Dave Green's Cubehelix colors, which may also be used with instanceof to test if an object is a Cubehelix color instance.
property prototype
readonly prototype: CubehelixColor;
Prototype of the factory, which can be used for instanceof testing
call signature
(h: number, s: number, l: number, opacity?: number): CubehelixColor;
Constructs a new Cubehelix color based on the specified channel values and opacity.
Parameter h
Hue channel value.
Parameter s
Saturation channel value.
Parameter l
Lightness channel value.
Parameter opacity
Optional opacity value, defaults to 1.
call signature
(cssColorSpecifier: string): CubehelixColor;
Parses the specified CSS Color Module Level 3 specifier string, returning an Cubehelix color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS Color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): CubehelixColor;
Converts the provided color instance and returns a Cubehelix color. The color instance is specified, it is converted to the RGB color space using color.rgb and then converted to Cubehelix. (Colors already in the Cubehelix color space skip the conversion to RGB.)
Parameter color
A permissible color space instance.
interface HCLColor
interface HCLColor extends Color {}
An HCL (CIELCH) color object.
property c
c: number;
Chroma channel value typically in [0, 230].
property h
h: number;
Hue channel value typically in [0, 360).
property l
l: number;
Luminance channel value typically in the range [0, 100].
property opacity
opacity: number;
Opacity value
method brighter
brighter: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much brighter the returned color should be.
method copy
copy: (values?: { h?: number | undefined; c?: number | undefined; l?: number | undefined; opacity?: number | undefined;}) => this;
Returns a copy of this color.
Parameter values
If values is specified, any enumerable own properties of values are assigned to the new returned color.
method darker
darker: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much darker the returned color should be.
method rgb
rgb: () => RGBColor;
Returns the RGB color equivalent of this color.
interface HCLColorFactory
interface HCLColorFactory extends Function {}
An HCL (CIELCH) color factory object, which may also be used with instanceof to test if an object is an HCL color instance.
property prototype
readonly prototype: HCLColor;
Prototype of the factory, which can be used for instanceof testing
call signature
(h: number, c: number, l: number, opacity?: number): HCLColor;
Constructs a new HCL color based on the specified channel values and opacity.
Parameter h
Hue channel value typically in [0, 360).
Parameter c
Chroma channel value typically in [0, 230].
Parameter l
Luminance channel value typically in the range [0, 100].
Parameter opacity
Optional opacity value, defaults to 1.
call signature
(cssColorSpecifier: string): HCLColor;
Parses the specified CSS Color Module Level 3 specifier string, returning an HCL color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS Color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): HCLColor;
Converts the provided color instance and returns an HCL color. The color instance is converted to the RGB color space using color.rgb and then converted to HCL. (Colors already in the HCL color space skip the conversion to RGB, and colors in the Lab color space are converted directly to HCL.)
Parameter color
A permissible color space instance.
interface HSLColor
interface HSLColor extends Color {}
An HSL color object.
property h
h: number;
Hue channel value.
property l
l: number;
Lightness channel value.
property opacity
opacity: number;
Opacity value.
property s
s: number;
Saturation channel value.
method brighter
brighter: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much brighter the returned color should be.
method clamp
clamp: () => this;
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].
method copy
copy: (values?: { h?: number | undefined; s?: number | undefined; l?: number | undefined; opacity?: number | undefined;}) => this;
Returns a copy of this color.
Parameter values
If values is specified, any enumerable own properties of values are assigned to the new returned color.
method darker
darker: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much darker the returned color should be.
method rgb
rgb: () => RGBColor;
Returns the RGB color equivalent of this color.
interface HSLColorFactory
interface HSLColorFactory extends Function {}
An HSL color factory object, which may also be used with instanceof to test if an object is an HSL color instance.
property prototype
readonly prototype: HSLColor;
Prototype of the factory, which can be used for instanceof testing
call signature
(h: number, s: number, l: number, opacity?: number): HSLColor;
Constructs a new HSL color based on the specified channel values and opacity.
Parameter h
Hue channel value.
Parameter s
Saturation channel value.
Parameter l
Lightness channel value.
Parameter opacity
Optional opacity value, defaults to 1.
call signature
(cssColorSpecifier: string): HSLColor;
Parses the specified CSS Color Module Level 3 specifier string, returning an HSL color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS Color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): HSLColor;
Converts the provided color instance and returns an HSL color. The color instance is converted to the RGB color space using color.rgb and then converted to HSL. (Colors already in the HSL color space skip the conversion to RGB.)
Parameter color
A permissible color space instance.
interface LabColor
interface LabColor extends Color {}
A Lab (CIELAB) color object.
property a
a: number;
Position between red/magenta and green typically in [-160, +160].
property b
b: number;
Position between yellow and blue typically in [-160, +160].
property l
l: number;
Lightness typically in the range [0, 100].
property opacity
opacity: number;
Opacity value
method brighter
brighter: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much brighter the returned color should be.
method copy
copy: (values?: { l?: number | undefined; a?: number | undefined; b?: number | undefined; opacity?: number | undefined;}) => this;
Returns a copy of this color.
Parameter values
If values is specified, any enumerable own properties of values are assigned to the new returned color.
method darker
darker: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much darker the returned color should be.
method rgb
rgb: () => RGBColor;
Returns the RGB color equivalent of this color.
interface LabColorFactory
interface LabColorFactory extends Function {}
A Lab (CIELAB) color factory object, which may also be used with instanceof to test if an object is a Lab color instance.
property prototype
readonly prototype: LabColor;
Prototype of the factory, which can be used for instanceof testing
call signature
(l: number, a: number, b: number, opacity?: number): LabColor;
Constructs a new CIELAB color based on the specified channel values and opacity.
Parameter l
Lightness typically in the range [0, 100].
Parameter a
Position between red/magenta and green typically in [-160, +160].
Parameter b
Position between yellow and blue typically in [-160, +160].
Parameter opacity
Optional opacity value, defaults to 1.
call signature
(cssColorSpecifier: string): LabColor;
Parses the specified CSS Color Module Level 3 specifier string, returning a Lab color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS Color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): LabColor;
Converts the provided color instance and returns a Lab color. The color instance is converted to the RGB color space using color.rgb and then converted to CIELAB. (Colors already in the Lab color space skip the conversion to RGB, and colors in the HCL color space are converted directly to CIELAB.)
Parameter color
A permissible color space instance.
interface LCHColorFactory
interface LCHColorFactory {}
An LCH (CIELCH) color factory function to create an HCL color object.
call signature
(l: number, c: number, h: number, opacity?: number): HCLColor;
Constructs a new HCL color based on the specified channel values and opacity.
Parameter l
Luminance channel value typically in the range [0, 100].
Parameter c
Chroma channel value typically in [0, 230].
Parameter h
Hue channel value typically in [0, 360).
Parameter opacity
Optional opacity value, defaults to 1.
call signature
(cssColorSpecifier: string): HCLColor;
Parses the specified CSS Color Module Level 3 specifier string, returning an HCL color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): HCLColor;
Converts the provided color instance and returns an HCL color. The color instance is converted to the RGB color space using color.rgb and then converted to HCL. (Colors already in the HCL color space skip the conversion to RGB, and colors in the Lab color space are converted directly to HCL.)
Parameter color
A permissible color space instance.
interface RGBColor
interface RGBColor extends Color {}
An RGB color object.
property b
b: number;
Value of blue channel
property g
g: number;
Value of green channel
property opacity
opacity: number;
Opacity value
property r
r: number;
Value of red channel
method brighter
brighter: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much brighter the returned color should be.
method clamp
clamp: () => this;
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].
method copy
copy: (values?: { r?: number | undefined; g?: number | undefined; b?: number | undefined; opacity?: number | undefined;}) => this;
Returns a copy of this color.
Parameter values
If values is specified, any enumerable own properties of values are assigned to the new returned color.
method darker
darker: (k?: number) => this;
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.
Parameter k
A color space dependent number to determine, how much darker the returned color should be.
method rgb
rgb: () => this;
Returns the RGB equivalent of this color.
interface RGBColorFactory
interface RGBColorFactory extends Function {}
An RGB color factory object, which may also be used with instanceof to test if an object is an RGB color instance.
property prototype
readonly prototype: RGBColor;
Prototype of the factory, which can be used for instanceof testing
call signature
(r: number, g: number, b: number, opacity?: number): RGBColor;
Constructs a new RGB color based on the specified channel values and opacity.
Parameter r
Red channel value.
Parameter g
Green channel value.
Parameter b
Blue channel value.
Parameter opacity
Optional opacity value, defaults to 1.
call signature
(cssColorSpecifier: string): RGBColor;
Parses the specified CSS Color Module Level 3 specifier string, returning an RGB color. If the specifier was not valid, null is returned.
Parameter cssColorSpecifier
A CSS Color Module Level 3 specifier string.
call signature
(color: ColorSpaceObject | ColorCommonInstance): RGBColor;
Converts the provided color instance and returns an RGB color. The color instance is converted to the RGB color space using color.rgb. Note that unlike color.rgb this method always returns a new instance, even if color is already an RGB color.
Parameter color
A permissible color space instance.
Type Aliases
type ColorSpaceObject
type ColorSpaceObject = RGBColor | HSLColor | LabColor | HCLColor | CubehelixColor;
Type allowing for color objects from a specified color space
type GrayColorFactory
type GrayColorFactory = /** * Constructs a new CIELAB color with the specified l value and a = b = 0. * * @param l Lightness typically in the range [0, 100]. * @param opacity Optional opacity value, defaults to 1. */ (l: number, opacity?: number) => LabColor;
A gray color factory for Lab (CIELAB) colors.
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/d3-color
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/d3-color)
- HTML<a href="https://www.jsdocs.io/package/@types/d3-color"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1882 ms. - Missing or incorrect documentation? Open an issue for this package.