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 ?
Kivy's colours are RGB(A) - don't confuse the colour space with the in-memory representation of the colour. Ultimately RGB measures each of the red, green and blue colour components on the scale from lightness zero (black) to maximum lightness (pure red/blue/green, if you like).
RGBA Colors RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color. An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).
I think you can just divide it by 255:
float_color = color / 255.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With