Re: How to get hexadecimal colour value from Python API?



Hi Bao,

On 08.07.2013 08:52, Bao Niu wrote:
Now if I want to extract colour value for an object from Python API, there
is only one form, namely decimal RBG value, and even worse, they are three
separate attributes (value.red, value.blue, value.green), is there a way to
extract a single hexadecimal colour value? Or at least extract a grouped
RBG value from one call instead of three different calls? Thanks.
Assuming that c is a DiaColor object, the following Python code should
give you a "hexadecimal color value".

 '#%02x%02x%02x' % (c.red*255, c.green*255, c.blue*255)

I don't think that this is too difficult. You can wrap that in a function that takes
a DiaColor object as the argument.
And Dia is open source, you can provide a patch that adds additional functionality.

Regards,

Steffen


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]