Start refactoring state management
This commit is contained in:
parent
ca0bf943f7
commit
a9ad628488
1 changed files with 410 additions and 360 deletions
16
src/app/utils/color.ts
Normal file
16
src/app/utils/color.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { IColor } from '../interfaces/persistance/color';
|
||||
|
||||
export const lighten = (by: number, { h, s, l }: IColor): IColor => {
|
||||
let newL = l + by;
|
||||
if (newL > 100) {
|
||||
newL = 100;
|
||||
} else if (newL < 0) {
|
||||
newL = 0;
|
||||
}
|
||||
|
||||
return { h, s, l: newL, type: 'Color' };
|
||||
};
|
||||
|
||||
export const toHslString = ({ h, s, l }: IColor): string => {
|
||||
return `hsl(${h}, ${s}%, ${l}%)`;
|
||||
};
|
||||
Loading…
Reference in a new issue