The graphical environment in Kivy uses a coordinate space to locate the content. In this recipe, we will take a look at how to work with the coordinate space. This recipe will define a vector and make some basic operations with it.
Now we are going to use the mathematical concept of vectors. You will get a better understanding of this recipe if you have the concept clear. Read the Wikipedia about it, a good start point. The implementation is made on top of a Python list, so it is important to have a good understanding of that concept too.
In this recipe, we will work directly with Python to show the possibilities of the vectors in Kivy, for which we will use the common vector operations.
First, let's define a vector:
v = Vector(82, 34)
Now if we want to retrieve the coordinate from a widget, we use:
w = widget.pos
The sum of the last two defined vectors is given by:
x = v + w
The product of those vectors is given...