user636424
user636424

Reputation:

can not change color of line using rgb value using cairo in pygtk

I am drawing on drawing area using cairo in pygtk. I set color of line using this func:

cr.set_source_rgb(203,12,41)

but it showing white color instead of this color #CB0C33 it is like red rose color. So please can any one tell me how to change color of line to any color using cairo in pygtk. Please help me. thank you in advanced...

Upvotes: 1

Views: 1836

Answers (1)

serge_gubenko
serge_gubenko

Reputation: 20482

set_source_rgb expects you to pass floating point values from 0 to 1, where 1 should correspond to FF. Pls, check if the code below would work for you:

color = gtk.gdk.Color('#CB0C33')
cr.set_source_rgb(float(color.red) / 65535, 
                  float(color.green) / 65535, 
                  float(color.blue) / 65535)

hope this helps, regards

Upvotes: 3

Related Questions