In WxWidget colors are represented by a RGB integer triplet. To interact with other libraries using a [0.0-1.0] float triplet representation, a conversion is needed.
Is there such a conversion function already existing in WxPython, Numpy or Python ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can just divide each element by 255 (or 256 depending on whether you want the upper range to include or exclude 1):
As you can see from
rgbvar3, you can use a similar method to convert them back.To check that this works, the following may help:
The fact that it shows no errors for the expected possible input values (integers
0through255) means that the reverse operation should work okay.