From 22c541a2ba3a113a8bee23cd650325e754fa8775 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 7 May 2018 21:22:21 +0200 Subject: [PATCH 01/10] #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 { From 415972a8af1e742b23894e706042f59f6276dcb6 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 7 May 2018 21:38:32 +0200 Subject: [PATCH 02/10] #25583 : added gray method --- types/d3-color/d3-color-tests.ts | 6 ++++ types/d3-color/index.d.ts | 60 +++++++++++++++++++------------- types/d3-geo/index.d.ts | 2 +- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/types/d3-color/d3-color-tests.ts b/types/d3-color/d3-color-tests.ts index 135456a005..d8ea79b637 100644 --- a/types/d3-color/d3-color-tests.ts +++ b/types/d3-color/d3-color-tests.ts @@ -76,6 +76,10 @@ cString = cLab.hex(); console.log('Channels = (l : %d, a: %d, b: %d)', cLab.l, cLab.a, cLab.b); console.log('Opacity = %d', cLab.opacity); +// Signature tests for Gray +cLab = d3Color.gray(120); +cLab = d3Color.gray(120, 0.5); + // Signature tests for HCL let cHcl: d3Color.HCLColor; @@ -126,6 +130,8 @@ if (color instanceof d3Color.rgb) { cHSL = color; } else if (color instanceof d3Color.lab) { cLab = color; +} else if (color instanceof d3Color.gray) { + cLab = color; } else if (color instanceof d3Color.hcl) { cHcl = color; } else if (color instanceof d3Color.cubehelix) { diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 1682fe653f..465618b5e8 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -1,9 +1,10 @@ // Type definitions for D3JS d3-color module 1.2 // Project: https://github.com/d3/d3-color/ -// Definitions by: Tom Wanzek -// Alex Ford -// Boris Yankov -// denisname +// Definitions by: Tom Wanzek , +// Alex Ford , +// Boris Yankov , +// denisname , +// Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Last module patch version validated against: 1.2.0 @@ -27,10 +28,10 @@ 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. - */ + /** + * 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; } @@ -78,10 +79,10 @@ 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. - */ + /** + * 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; } @@ -100,10 +101,10 @@ 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. - */ + /** + * 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; } @@ -114,6 +115,15 @@ export interface LabColorFactory extends Function { readonly prototype: LabColor; } +/** + * Constructs a new Lab color with the specified l value and a = b = 0. + */ +export interface GrayColorFactory extends Function { + (l: number, opacity?: number): LabColor; + readonly prototype: LabColor; + +} + export interface HCLColor extends Color { h: number; c: number; @@ -122,10 +132,10 @@ 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. - */ + /** + * 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; } @@ -144,10 +154,10 @@ 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. - */ + /** + * 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; } @@ -170,6 +180,8 @@ export const hsl: HSLColorFactory; export const lab: LabColorFactory; +export const gray: GrayColorFactory; + export const hcl: HCLColorFactory; export const cubehelix: CubehelixColorFactory; diff --git a/types/d3-geo/index.d.ts b/types/d3-geo/index.d.ts index a41f67618a..5dd835026d 100644 --- a/types/d3-geo/index.d.ts +++ b/types/d3-geo/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for D3JS d3-geo module 1.10 // Project: https://github.com/d3/d3-geo/ -// Definitions by: Hugues Stefanski , Tom Wanzek , Alex Ford , Boris Yankov +// Definitions by: Hugues Stefanski , Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 3d87842d8b21a84ac0d71c0aa1c5701c1b107a46 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 7 May 2018 21:41:37 +0200 Subject: [PATCH 03/10] #25583 : added lch method --- types/d3-color/d3-color-tests.ts | 8 ++++++++ types/d3-color/index.d.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/types/d3-color/d3-color-tests.ts b/types/d3-color/d3-color-tests.ts index d8ea79b637..9be5a3d067 100644 --- a/types/d3-color/d3-color-tests.ts +++ b/types/d3-color/d3-color-tests.ts @@ -100,6 +100,12 @@ cString = cHcl.hex(); console.log('Channels = (h : %d, c: %d, l: %d)', cHcl.h, cHcl.c, cHcl.l); console.log('Opacity = %d', cHcl.opacity); +cHcl = d3Color.lch(40, 50, 120); +cHcl = d3Color.lch(40, 50, 120, 0.5); +cHcl = d3Color.lch('steelblue'); +cHcl = d3Color.lch('rgba(20, 100, 200, 0.5)'); +cHcl = d3Color.lch(c); + // Signature tests for Cubehelix let cCubehelix: d3Color.CubehelixColor; @@ -134,6 +140,8 @@ if (color instanceof d3Color.rgb) { cLab = color; } else if (color instanceof d3Color.hcl) { cHcl = color; +} else if (color instanceof d3Color.lch) { + cHcl = color; } else if (color instanceof d3Color.cubehelix) { cCubehelix = color; } else if (color === null) { diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 465618b5e8..70ff67477e 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -146,6 +146,13 @@ export interface HCLColorFactory extends Function { readonly prototype: HCLColor; } +export interface LCHColorFactory extends Function { + (l: number, c: number, h: number, opacity?: number): HCLColor; + (cssColorSpecifier: string): HCLColor; + (color: ColorSpaceObject | ColorCommonInstance): HCLColor; + readonly prototype: HCLColor; +} + export interface CubehelixColor extends Color { h: number; s: number; @@ -184,4 +191,6 @@ export const gray: GrayColorFactory; export const hcl: HCLColorFactory; +export const lch: LCHColorFactory; + export const cubehelix: CubehelixColorFactory; From 4b4c00c4bb1832e668a9818521f57202dc71d64a Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Mon, 7 May 2018 22:04:42 +0200 Subject: [PATCH 04/10] Fix comments --- types/d3-color/index.d.ts | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 70ff67477e..3c11d8f88d 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -28,11 +28,6 @@ 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 { @@ -57,10 +52,10 @@ export interface RGBColor extends Color { * 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. - */ + /** + * 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; } @@ -79,7 +74,7 @@ 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. */ @@ -101,7 +96,7 @@ 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. */ @@ -121,7 +116,6 @@ export interface LabColorFactory extends Function { export interface GrayColorFactory extends Function { (l: number, opacity?: number): LabColor; readonly prototype: LabColor; - } export interface HCLColor extends Color { @@ -132,10 +126,10 @@ 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. - */ + /** + * 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; } @@ -161,7 +155,7 @@ 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. */ From 120a90e9670c7197fc0a2e5c83a62898c5c6114c Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Fri, 11 May 2018 20:27:08 +0200 Subject: [PATCH 05/10] d3-color : fix comment indent remove prototypes --- types/d3-color/index.d.ts | 45 +++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 3c11d8f88d..68a92ed321 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -28,6 +28,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 { @@ -53,9 +58,9 @@ export interface RGBColor extends 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. - */ + * 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; } @@ -74,10 +79,10 @@ 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. - */ + /** + * 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; } @@ -96,10 +101,10 @@ 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. - */ + /** + * 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; } @@ -115,7 +120,6 @@ export interface LabColorFactory extends Function { */ export interface GrayColorFactory extends Function { (l: number, opacity?: number): LabColor; - readonly prototype: LabColor; } export interface HCLColor extends Color { @@ -126,10 +130,10 @@ 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. - */ + /** + * 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; } @@ -144,7 +148,6 @@ export interface LCHColorFactory extends Function { (l: number, c: number, h: number, opacity?: number): HCLColor; (cssColorSpecifier: string): HCLColor; (color: ColorSpaceObject | ColorCommonInstance): HCLColor; - readonly prototype: HCLColor; } export interface CubehelixColor extends Color { @@ -155,10 +158,10 @@ 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. - */ + /** + * 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; } From 1180203388f48d6751800415c883d71da24fb677 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Fri, 11 May 2018 20:28:31 +0200 Subject: [PATCH 06/10] d3-color : Fix prototype test --- types/d3-color/d3-color-tests.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/types/d3-color/d3-color-tests.ts b/types/d3-color/d3-color-tests.ts index 9be5a3d067..2d324e7886 100644 --- a/types/d3-color/d3-color-tests.ts +++ b/types/d3-color/d3-color-tests.ts @@ -136,12 +136,8 @@ if (color instanceof d3Color.rgb) { cHSL = color; } else if (color instanceof d3Color.lab) { cLab = color; -} else if (color instanceof d3Color.gray) { - cLab = color; } else if (color instanceof d3Color.hcl) { cHcl = color; -} else if (color instanceof d3Color.lch) { - cHcl = color; } else if (color instanceof d3Color.cubehelix) { cCubehelix = color; } else if (color === null) { From 8ae3c459e6d150b1212f475b744c120f293324c5 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Fri, 11 May 2018 20:42:49 +0200 Subject: [PATCH 07/10] d3-color : fix border effects --- types/d3-color/index.d.ts | 10 ++++++---- types/d3-hsv/index.d.ts | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 68a92ed321..68dcf9e358 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -57,7 +57,7 @@ export interface RGBColor extends Color { * 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. */ @@ -118,9 +118,11 @@ export interface LabColorFactory extends Function { /** * Constructs a new Lab color with the specified l value and a = b = 0. */ -export interface GrayColorFactory extends Function { - (l: number, opacity?: number): LabColor; -} +// export interface GrayColorFactory extends Function { +// (l: number, opacity?: number): LabColor; +// } + +export type GrayColorFactory = (l: number, opacity?: number) => LabColor; export interface HCLColor extends Color { h: number; diff --git a/types/d3-hsv/index.d.ts b/types/d3-hsv/index.d.ts index 1728af0874..7452dbcc2b 100644 --- a/types/d3-hsv/index.d.ts +++ b/types/d3-hsv/index.d.ts @@ -68,6 +68,12 @@ export interface HSVColor extends Color { * Returns the RGB equivalent of this color. */ 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 const hsv: HSVColorFactory; From 72ade1444e92dfca78d412c4465d171e214e449b Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sun, 13 May 2018 12:14:28 +0200 Subject: [PATCH 08/10] d3-color : moved hex at Color interface level --- types/d3-color/index.d.ts | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 68dcf9e358..a616543bfe 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -38,6 +38,11 @@ export interface ColorCommonInstance { export interface Color { displayable(): boolean; // Note: While this method is used in prototyping for colors of specific colorspaces, it should not be called directly, as 'this.rgb' would not be implemented on Color toString(): string; // Note: While this method is used in prototyping for colors of specific colorspaces, it should not be called directly, as 'this.rgb' would not be implemented on Color + /** + * 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 ColorFactory extends Function { @@ -57,11 +62,6 @@ export interface RGBColor extends Color { * 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 { @@ -79,11 +79,6 @@ 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 { @@ -101,11 +96,6 @@ 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 { @@ -118,12 +108,13 @@ export interface LabColorFactory extends Function { /** * Constructs a new Lab color with the specified l value and a = b = 0. */ +export type GrayColorFactory = (l: number, opacity?: number) => LabColor; + +// Using the interface creates an error // export interface GrayColorFactory extends Function { // (l: number, opacity?: number): LabColor; // } -export type GrayColorFactory = (l: number, opacity?: number) => LabColor; - export interface HCLColor extends Color { h: number; c: number; @@ -132,11 +123,6 @@ 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 { @@ -160,11 +146,6 @@ 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 { From be78af0d6cac15f583ca21e89a79f4708cd91911 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Fri, 18 May 2018 21:30:03 +0200 Subject: [PATCH 09/10] d3-color : adress last comments --- types/d3-color/index.d.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index a616543bfe..931ac29b96 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -108,12 +108,9 @@ export interface LabColorFactory extends Function { /** * Constructs a new Lab color with the specified l value and a = b = 0. */ -export type GrayColorFactory = (l: number, opacity?: number) => LabColor; - -// Using the interface creates an error -// export interface GrayColorFactory extends Function { -// (l: number, opacity?: number): LabColor; -// } +export interface GrayColorFactory { + (l: number, opacity?: number): LabColor; +} export interface HCLColor extends Color { h: number; @@ -132,7 +129,7 @@ export interface HCLColorFactory extends Function { readonly prototype: HCLColor; } -export interface LCHColorFactory extends Function { +export interface LCHColorFactory { (l: number, c: number, h: number, opacity?: number): HCLColor; (cssColorSpecifier: string): HCLColor; (color: ColorSpaceObject | ColorCommonInstance): HCLColor; From 1606c6c190ffb54ab983021ae260165dbbb83714 Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Fri, 18 May 2018 21:46:44 +0200 Subject: [PATCH 10/10] d3-color : use type instead of interface --- types/d3-color/index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/types/d3-color/index.d.ts b/types/d3-color/index.d.ts index 931ac29b96..56812a6bdb 100644 --- a/types/d3-color/index.d.ts +++ b/types/d3-color/index.d.ts @@ -32,7 +32,7 @@ export interface ColorCommonInstance { * 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; + hex(): string; } export interface Color { @@ -108,9 +108,7 @@ export interface LabColorFactory extends Function { /** * Constructs a new Lab color with the specified l value and a = b = 0. */ -export interface GrayColorFactory { - (l: number, opacity?: number): LabColor; -} +export type GrayColorFactory = (l: number, opacity?: number) => LabColor; export interface HCLColor extends Color { h: number;