The rotation, translation, and scaling canvas in Kivy is relatively easy with the use of matrices. In this recipe, we will create a traditional button and rotate its canvas.
Again the mathematics are important in graphics, so we should at least do a Wikipedia check about the matrix concept to get a real sense about what is happening with the canvas.
For this recipe, follow these steps:
In
canvas.before
, push the matrix onto the context's matrix stack.Rotate the matrix 45 degrees.
Use the translate instruction to translate the matrix.
In
canvas.after,
pop the matrix from the context's matrix stack onto the model view:<MyW>: Button: text: 'hello world' size_hint: None, None pos_hint: {'center_x': .5, 'center_y': .5} canvas.before: PushMatrix Rotate: ...