Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definitions #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* The LAB color configuration object.
*/
export interface Lab {
/** The lightness value, on scale of 0 to 100. */
L: number;
/** The chroma value, on scale of -128 to 128 */
A: number;
/** The hue value, on scale of -128 to 128 */
B: number;
}

declare class DeltaE {
/**
* The CIE76 color difference algorithm: a simple euclidean distance calculation.
* http://en.wikipedia.org/wiki/Color_difference#CIE76
*/
getDeltaE76(x1: Lab, x2: Lab): number;

/**
* The CIE94 algorithm: an iteration of the CIE76 algorithm.
* http://en.wikipedia.org/wiki/Color_difference#CIE94
*/
getDeltaE94(x1: Lab, x2: Lab): number;

/**
* The CIE2000 color difference algorithm.
* http://en.wikipedia.org/wiki/Color_difference#CIEDE2000
*/

getDeltaE00(x1: Lab, x2: Lab): number;
}

declare const deltaE: DeltaE;

export default deltaE;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "CIE color difference algorithms in JavaScript.",
"private": false,
"main": "./src/index.js",
"types": "./index.d.ts",
"keywords": [
"cie",
"cie94",
Expand Down