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.
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.
Share Improve this question edited Nov 8, 2021 at 18:38 conor909 asked Nov 4, 2021 at 15:06 conor909conor909 1,6231 gold badge17 silver badges31 bronze badges 3- 1 Divide the 0...255 value by 255 (or 256 maybe) – Pointy Commented Nov 4, 2021 at 15:10
- 1 standard RGB is not from 0 to 255 (or 256). Max value of 100 or 1 is mon (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) – Giao Catenazzi Commented Nov 5, 2021 at 6:12
- 1 @GiaoCatenazzi It's standard in web apis, and this is a javascript library – conor909 Commented Nov 8, 2021 at 17:38
1 Answer
Reset to default 9Documentation gives an example like this color: rgb(0.95, 0.1, 0.1)
. Dividing by 255 is likely the solution.