Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Cage committed Jul 7, 2021
1 parent 798fb12 commit 070ad8c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/utils/rgbToHSL.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
/**
* Transform RGB to HEX
* Transform RGB to HSL
*/
export default function rgbToHSL(r: number, g: number, b: number): string {
export default function rgbToHSL(r: number, g: number, b: number): number[] {
const _r = r / 255;
const _g = g / 255;
const _b = b / 255;
const max = Math.max(_r, _g, _b);
const min = Math.min(_r, _g, _b);
let h = 0;
let s = 0;
let v = max;
const v = max;
if (max != min) {
let delta = max - min;
const delta = max - min;
s = delta / max;
switch (max) {
case _r: h = (_g - _b) / delta + (g < b ? 6 : 0);
case _r:
h = (_g - _b) / delta + (g < b ? 6 : 0);
break;
case _g: h = (_b - _r) / delta + 2;
case _g:
h = (_b - _r) / delta + 2;
break;
case _b: h = (_r - _g) / delta + 4;
case _b:
h = (_r - _g) / delta + 4;
break;
}
}
Expand Down

0 comments on commit 070ad8c

Please sign in to comment.