Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 804
paarth batra Avatar asked Apr 08 '14 08:04

paarth batra


People also ask

What color system does KIVY use?

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).

What is RGBA color codes?

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).


1 Answers

I think you can just divide it by 255:

float_color = color / 255.0
like image 193
gog Avatar answered Sep 18 '22 01:09

gog