From 72ade1444e92dfca78d412c4465d171e214e449b Mon Sep 17 00:00:00 2001 From: Hugues Stefanski Date: Sun, 13 May 2018 12:14:28 +0200 Subject: [PATCH] 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 {