开发者

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

开发者 https://www.devze.com 2023-02-15 01:33 出处:网络
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)

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开发者_Python百科 color of line to any color using cairo in pygtk. Please help me. thank you in advanced...


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

0

精彩评论

暂无评论...
验证码 换一张
取 消