All files / Rindu/utils colorCoded.ts

20% Statements 2/10
100% Branches 0/0
0% Functions 0/2
20% Lines 2/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 182x                     2x            
export function colorCodedToRGB(color: number): {
  r: number;
  g: number;
  b: number;
} {
  const r = (color >> 16) & 0xff;
  const g = (color >> 8) & 0xff;
  const b = color & 0xff;
  return { r, g, b };
}
 
export function colorCodedToHex(color: number): string {
  const r = (color >> 16) & 0xff;
  const g = (color >> 8) & 0xff;
  const b = color & 0xff;
  return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
}