convert rgba color codes 255,255,255,255 to kivy color codes in 1,1,1,1

paarth batra picture paarth batra · Apr 8, 2014 · Viewed 17.9k times · Source

In order to specify any color value in kivy we need to specify values from 0 to 1 i.e. color defaults to [1,1,1,1] and can contain values between 0 and 1 , however rgba codes which are readily available for other languages are always specified from 0 to 255 and i usually refer them from any web link as in http://www.rapidtables.com/web/color/RGB_Color.htm

This helps even in various python toolkits example pyQt library however in kivy its different .

Does anyone know why its specified from 0 to 1 and if there s any way to code values used by various other languages to kivy color codes . for example what if i want to change rgb(192,192,192) to kivy color code ?

Answer

georg picture georg · Apr 8, 2014

I think you can just divide it by 255:

float_color = color / 255.0