/ src / utils / colors.ts
colors.ts
 1  import {
 2    type RGB,
 3    rgb as rgbToPdf
 4  } from "@cantoo/pdf-lib";
 5  
 6  /**
 7   *
 8   * @example
 9   * hex(0xFFFFFF); // [1, 1, 1];
10   */
11  export const hexToPdf = (hex: number): RGB => {
12    const r = (hex >> 16) & 0xff;
13    const g = (hex >> 8) & 0xff;
14    const b = hex & 0xff;
15  
16    return rgbToPdf(r / 255, g / 255, b / 255);
17  };
18  
19  export type { RGB };