Controlling Color in a Canvas

26 views
Skip to first unread message

GreyGnome

unread,
Jun 27, 2016, 2:33:40 PM6/27/16
to Kivy users support
I'm quite confused as to how to control the color of my images when they are included in a canvas.

Here are links to the gists of my confusion. It's a very simple app which displays a Label and an Image. It's the label that's of concern. Its canvas loads an image to display:


The label shows a yellow tinge to it right now, because of the line <code>Color(1.0, 1.0, 0)</code> (see the .py file gist, below). If I get rid of that line altogether, the Label seems to inherit the settings on the canvas of the MyFloatLayout. That is, it's completely black and unseaable. If I change it to, say, 0.5,0.5,0.5, then the image will have a grey wash over it.

Why does the label use the values of the Color of the enclosing FloatLayout? Checking the documentation, it discusses Color values being applied as multipliers to Vertex instructions, but not to other objects such as Canvases. Actually the docs https://kivy.org/docs/api-kivy.graphics.html only seem to discuss vertices, not Canvases.

Thanks.

Alexander Taylor

unread,
Jun 27, 2016, 6:10:16 PM6/27/16
to Kivy users support
The canvas is ultimately a big list of state manipulations, executed in order. This includes Color; the color variable changes when a Color instruction is encountered, but otherwise is left unchanged. For this reason, if you want to be sure the color state is something in particular, you should always add your own Color instruction and set it to what you want.
Reply all
Reply to author
Forward
0 new messages