From 22c541a2ba3a113a8bee23cd650325e754fa8775 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 7 May 2018 21:22:21 +0200 Subject: [PATCH] #25583 : update d3-color to 1.2.0 Added hex method --- types/d3-color/d3-color-tests.ts | 5 +++++ types/d3-color/index.d.ts | 37 ++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/types/d3-color/d3-color-tests.ts b/types/d3-color/d3-color-tests.ts index 47f191073b..135456a005 100644 --- a/types/d3-color/d3-color-tests.ts +++ b/types/d3-color/d3-color-tests.ts @@ -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); diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 825b82d9c4..1682fe653f 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -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 // Alex Ford @@ -6,7 +6,7 @@ // 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 {