Skip to content

Commit

Permalink
fix(🖍): Add functions to extract color components
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Sep 2, 2021
1 parent 1f9e72f commit c036513
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,23 @@ export const hsv2rgb = (h: number, s: number, v: number) => {

return { r, g, b };
};

export const opacity = (c: number): number => {
'worklet';
return ((c >> 24) & 255) / 255;
};

export const red = (c: number): number => {
'worklet';
return (c >> 16) & 255;
};

export const green = (c: number): number => {
'worklet';
return (c >> 8) & 255;
};

export const blue = (c: number): number => {
'worklet';
return c & 255;
};

0 comments on commit c036513

Please sign in to comment.