3

What color format is pdf-lib using? Writing rgb(156, 132, 678) or cmyk(157, 145, 124, 135) throws an error where all number values must be between 0 and 1.

How do I convert standard rgb, ie. 0-255 to whatever format this is?

The docs give me the TypeScript definitions of the function but no explanations.

conor909
  • 1,475
  • 14
  • 29
  • 1
    Divide the 0...255 value by 255 (or 256 maybe) – Pointy Nov 04 '21 at 15:10
  • standard RGB is not from 0 to 255 (or 256). Max value of 100 or 1 is common (especially in literature), and we should go back to such normalizations because we may have more bits per channel. In fact some new function start using again RGB which is white (see CSS) – Giacomo Catenazzi Nov 05 '21 at 06:12
  • @GiacomoCatenazzi It's standard in web apis, and this is a javascript library – conor909 Nov 08 '21 at 17:38

1 Answers1

7

Documentation gives an example like this color: rgb(0.95, 0.1, 0.1). Dividing by 255 is likely the solution.