Before studying the examples of this chapter, it is important to recapitulate the following particularities related to the graphics display:
The coordinate space refers to the place in which we draw, which is not restricted to the windows size
A Canvas object is a set of instructions to draw in the coordinate space, not the place we draw in
All Widget objects contain their own Canvas (canvases, which we will see later) but all of them share the same coordinate space, the one in the App object.
For example, if we add a rotation instruction to a specific Canvas instance (for example, the canvas of a button), then this will also affect all the subsequent graphics instructions that are going to display graphics in the coordinate space. It doesn't matter if the graphics belong to canvases of different widgets; they all share the same coordinate space.
Therefore, we need to learn techniques to leave the coordinate space context in its original state after modifying it with graphics instructions.
Tip
All the graphics instructions added to different Canvas objects, which at the same time belong to different Widget objects, affect the same coordinate space. It is our task to make sure that the coordinate space is in its original state after modifying it with the graphics instructions.
Another important concept that we need to extend is the one of the Widget. We already know that widgets are the blocks that allow us to build interfaces.
Note
A Widget is also a place marker (with its position and size), but not necessarily a placeholder. The instructions of the canvas of a widget are not restricted to the specific area of the widget but to the whole coordinate space.
This directly adds to the previous problem of sharing a coordinate space. Not only do we need to control the fact that we share a coordinate space, but also, we have no restrictions on where to draw. On one hand, this makes Kivy very efficient and gives us a lot of flexibility. On the other hand, this seems to be a lot to control. Fortunately, Kivy provides the necessary tools to easily work around the problem.
The next section will present the available graphics instructions that can be added to the canvas in order to draw basic shapes. After this, we will explore graphic instructions that change the coordinate space context and exemplify the problems of sharing the coordinate space. The final section concentrates on illustrating the acquired knowledge inside the Comic Creator, where we learn the most common techniques to master the use of the canvas considering its particularities. By the end of this chapter, we will be in complete control of the graphics that are displayed on the screen.