mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add definitions for color-diff (#32516)
This commit is contained in:
committed by
Pranav Senthilnathan
parent
2a76edab65
commit
55dbfec2eb
17
types/color-diff/color-diff-tests.ts
Normal file
17
types/color-diff/color-diff-tests.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import diff from "color-diff";
|
||||
|
||||
const color = { R: 255, G: 1, B: 30 };
|
||||
// red, green, blue
|
||||
const palette = [
|
||||
{ R: 255, G: 0, B: 0 },
|
||||
{ R: 0, G: 255, B: 0 },
|
||||
{ R: 0, G: 0, B: 255 }
|
||||
];
|
||||
|
||||
diff.closest(color, palette); // {R: 255, G: 0, B: 0 }, red
|
||||
|
||||
const color1 = { R: 255, G: 255, B: 255 };
|
||||
// black, white
|
||||
const palette1 = [{ R: 0, G: 0, B: 0 }, { R: 255, G: 255, B: 255 }];
|
||||
|
||||
diff.furthest(color1, palette1); // {R: 0, G: 0, B: 0 }, black
|
||||
67
types/color-diff/index.d.ts
vendored
Normal file
67
types/color-diff/index.d.ts
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
// Type definitions for color-diff 1.1
|
||||
// Project: https://github.com/markusn/color-diff#readme
|
||||
// Definitions by: katsanva <https://github.com/katsanva>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
export interface RGBColor {
|
||||
R: number;
|
||||
G: number;
|
||||
B: number;
|
||||
A?: number;
|
||||
}
|
||||
|
||||
export interface LabColor {
|
||||
L: number;
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
|
||||
export function diff(c1: LabColor, c2: LabColor): number;
|
||||
|
||||
export function rgb_to_lab(c: RGBColor): LabColor;
|
||||
export function rgba_to_lab(c: RGBColor, bc?: RGBColor): LabColor;
|
||||
|
||||
export function closest(
|
||||
color: RGBColor,
|
||||
palette: ReadonlyArray<RGBColor>,
|
||||
backgroundColor?: RGBColor
|
||||
): RGBColor;
|
||||
|
||||
export function furthest(
|
||||
color: RGBColor,
|
||||
palette: ReadonlyArray<RGBColor>,
|
||||
backgroundColor?: RGBColor
|
||||
): RGBColor;
|
||||
|
||||
export function map_palette(
|
||||
a: ReadonlyArray<RGBColor>,
|
||||
b: ReadonlyArray<RGBColor>,
|
||||
type?: "closest" | "furthest",
|
||||
backgroundColor?: RGBColor
|
||||
): { [key: string]: RGBColor };
|
||||
|
||||
export function palette_map_key(c: RGBColor): string;
|
||||
|
||||
export function closest_lab(
|
||||
color: LabColor,
|
||||
palette: ReadonlyArray<LabColor>
|
||||
): LabColor;
|
||||
|
||||
export function furthest_lab(
|
||||
color: LabColor,
|
||||
palette: ReadonlyArray<LabColor>
|
||||
): LabColor;
|
||||
|
||||
export function map_palette_lab(
|
||||
p1: ReadonlyArray<LabColor>,
|
||||
p2: ReadonlyArray<LabColor>
|
||||
): { [key: string]: LabColor };
|
||||
|
||||
export function lab_palette_map_key(c: LabColor): string;
|
||||
|
||||
export function match_palette_lab(
|
||||
target_color: LabColor,
|
||||
palette: ReadonlyArray<LabColor>,
|
||||
find_furthest: boolean
|
||||
): LabColor;
|
||||
17
types/color-diff/tsconfig.json
Normal file
17
types/color-diff/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": ["index.d.ts", "color-diff-tests.ts"]
|
||||
}
|
||||
1
types/color-diff/tslint.json
Normal file
1
types/color-diff/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user