Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

color codes in reportlabs-python

I'm using reportlabs library of python to generate PDF reports. I need to understand which format of color code is needed to be passed.

When I pass RGB code for light green (178,255,102), to the_canvas.setFillColorRGB(178,255,102) it gives me white. And if I provide universal RGB color code for any color, it still gives me the same white color.

If I provide (25,51,0) , it gives me yellow, which is not RGB code for yellow.

How should I provide color codes to the reportlab in order to get the color I wanted. Which format is it using?

like image 883
PythonEnthusiast Avatar asked Dec 10 '13 03:12

PythonEnthusiast


1 Answers

From what I can tell, using the 256 color space won't work. The manual states that using 1 is 'all lights on full'. So, to create 256,256,256 is actually done by using (1,1,1). Thus, to get something in between, you'll have to use decimals. For me, I wanted the RGB: (75,116,156) so I had to write: setFillColorRGB(0.29296875,0.453125,0.609375). That's the equivelant to: 75/256, 116/256, 156/256. A bit ridiculous IMO, but it came out perfect

like image 118
PythonEnthusiast Avatar answered Oct 02 '22 04:10

PythonEnthusiast