#25583 : update d3-color to 1.2.0

Added hex method
This commit is contained in:
Hugues Stefanski
2018-05-07 21:22:21 +02:00
parent d12082bfdf
commit 22c541a2ba
2 changed files with 40 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ cRGB = cRGB.darker(0.2);
cRGB = cRGB.rgb();
displayable = cRGB.displayable();
cString = cRGB.toString();
cString = cRGB.hex();
console.log('Channels = (r : %d, g: %d, b: %d)', cRGB.r, cRGB.g, cRGB.b);
console.log('Opacity = %d', cRGB.opacity);
@@ -51,6 +52,7 @@ cHSL = cHSL.darker(0.2);
cRGB = cHSL.rgb();
displayable = cHSL.displayable();
cString = cHSL.toString();
cString = cHSL.hex();
console.log('Channels = (h : %d, s: %d, l: %d)', cHSL.h, cHSL.s, cHSL.l);
console.log('Opacity = %d', cHSL.opacity);
@@ -70,6 +72,7 @@ cLab = cLab.darker(0.2);
cRGB = cLab.rgb();
displayable = cLab.displayable();
cString = cLab.toString();
cString = cLab.hex();
console.log('Channels = (l : %d, a: %d, b: %d)', cLab.l, cLab.a, cLab.b);
console.log('Opacity = %d', cLab.opacity);
@@ -89,6 +92,7 @@ cHcl = cHcl.darker(0.2);
cRGB = cHcl.rgb();
displayable = cHcl.displayable();
cString = cHcl.toString();
cString = cHcl.hex();
console.log('Channels = (h : %d, c: %d, l: %d)', cHcl.h, cHcl.c, cHcl.l);
console.log('Opacity = %d', cHcl.opacity);
@@ -108,6 +112,7 @@ cCubehelix = cCubehelix.darker(0.2);
cRGB = cCubehelix.rgb();
displayable = cCubehelix.displayable();
cString = cCubehelix.toString();
cString = cCubehelix.hex();
console.log('Channels = (h : %d, s: %d, l: %d)', cCubehelix.h, cCubehelix.s, cCubehelix.l);
console.log('Opacity = %d', cCubehelix.opacity);

View File

@@ -1,4 +1,4 @@
// Type definitions for D3JS d3-color module 1.0
// Type definitions for D3JS d3-color module 1.2
// Project: https://github.com/d3/d3-color/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
// Alex Ford <https://github.com/gustavderdrache>
@@ -6,7 +6,7 @@
// denisname <https://github.com/denisname>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.0.3
// Last module patch version validated against: 1.2.0
// ---------------------------------------------------------------------------
// Shared Type Definitions and Interfaces
@@ -27,6 +27,11 @@ export interface ColorCommonInstance {
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
/**
* 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.
*/
hex(): string;
}
export interface Color {
@@ -47,7 +52,15 @@ export interface RGBColor extends Color {
opacity: number;
brighter(k?: number): this;
darker(k?: number): this;
/**
* Returns the RGB equivalent of this color.
*/
rgb(): this;
/**
* 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.
*/
hex(): string;
}
export interface RGBColorFactory extends Function {
@@ -65,6 +78,11 @@ export interface HSLColor extends Color {
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
/**
* 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.
*/
hex(): string;
}
export interface HSLColorFactory extends Function {
@@ -82,6 +100,11 @@ export interface LabColor extends Color {
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
/**
* 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.
*/
hex(): string;
}
export interface LabColorFactory extends Function {
@@ -99,6 +122,11 @@ export interface HCLColor extends Color {
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
/**
* 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.
*/
hex(): string;
}
export interface HCLColorFactory extends Function {
@@ -116,6 +144,11 @@ export interface CubehelixColor extends Color {
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
/**
* 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.
*/
hex(): string;
}
export interface CubehelixColorFactory extends Function {