-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
24 lines (22 loc) · 837 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Color from 'color';
import ensureHexFormat from "./ensureHexFormat";
/**
* Darkens a color.
* @param color - The base color in hex format.
* @param coefficient - The coefficient between 0 and 1 to determine how much to darken the color.
* @returns The darkened color in hex format.
*/
export function darken(color: string, coefficient: number): string {
const c = Color(color).darken(coefficient).hex();
return ensureHexFormat(c);
}
/**
* Lightens a color.
* @param color - The base color in hex format.
* @param coefficient - The coefficient between 0 and 1 to determine how much to lighten the color.
* @returns The lightened color in hex format.
*/
export function lighten(color: string, coefficient: number): string {
const c = Color(color).lighten(coefficient).hex();
return ensureHexFormat(c);
}