mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #25586 from Ledragon/d3-color-120
#25583 : D3 color 1.2.0
This commit is contained in:
@@ -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,9 +72,14 @@ 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);
|
||||
|
||||
// Signature tests for Gray
|
||||
cLab = d3Color.gray(120);
|
||||
cLab = d3Color.gray(120, 0.5);
|
||||
|
||||
// Signature tests for HCL
|
||||
|
||||
let cHcl: d3Color.HCLColor;
|
||||
@@ -89,9 +96,16 @@ 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);
|
||||
|
||||
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;
|
||||
@@ -108,6 +122,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);
|
||||
|
||||
|
||||
Vendored
+35
-6
@@ -1,12 +1,13 @@
|
||||
// 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>
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// denisname <https://github.com/denisname>
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>,
|
||||
// Alex Ford <https://github.com/gustavderdrache>,
|
||||
// Boris Yankov <https://github.com/borisyankov>,
|
||||
// denisname <https://github.com/denisname>,
|
||||
// Hugues Stefanski <https://github.com/ledragon>
|
||||
// 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,11 +28,21 @@ 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 {
|
||||
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 {
|
||||
@@ -47,6 +58,9 @@ export interface RGBColor extends Color {
|
||||
opacity: number;
|
||||
brighter(k?: number): this;
|
||||
darker(k?: number): this;
|
||||
/**
|
||||
* Returns the RGB equivalent of this color.
|
||||
*/
|
||||
rgb(): this;
|
||||
}
|
||||
|
||||
@@ -91,6 +105,11 @@ export interface LabColorFactory extends Function {
|
||||
readonly prototype: LabColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new Lab color with the specified l value and a = b = 0.
|
||||
*/
|
||||
export type GrayColorFactory = (l: number, opacity?: number) => LabColor;
|
||||
|
||||
export interface HCLColor extends Color {
|
||||
h: number;
|
||||
c: number;
|
||||
@@ -108,6 +127,12 @@ export interface HCLColorFactory extends Function {
|
||||
readonly prototype: HCLColor;
|
||||
}
|
||||
|
||||
export interface LCHColorFactory {
|
||||
(l: number, c: number, h: number, opacity?: number): HCLColor;
|
||||
(cssColorSpecifier: string): HCLColor;
|
||||
(color: ColorSpaceObject | ColorCommonInstance): HCLColor;
|
||||
}
|
||||
|
||||
export interface CubehelixColor extends Color {
|
||||
h: number;
|
||||
s: number;
|
||||
@@ -137,6 +162,10 @@ export const hsl: HSLColorFactory;
|
||||
|
||||
export const lab: LabColorFactory;
|
||||
|
||||
export const gray: GrayColorFactory;
|
||||
|
||||
export const hcl: HCLColorFactory;
|
||||
|
||||
export const lch: LCHColorFactory;
|
||||
|
||||
export const cubehelix: CubehelixColorFactory;
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for D3JS d3-geo module 1.10
|
||||
// Project: https://github.com/d3/d3-geo/
|
||||
// Definitions by: Hugues Stefanski <https://github.com/Ledragon>, Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions by: Hugues Stefanski <https://github.com/ledragon>, Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
Vendored
+6
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user