Rotating, translating, and scaling
The Rotate
, Translate
, and
Scale
classes are the context instructions that are applied to the coordinate space, and indirectly to the vertex instructions. This may bring unexpected results if we forget that the coordinate space is of the size of the screen (actually bigger than that because there is no restriction in the coordinates and we can draw outside of the window), and this might affect all the subsequent components that are drawn. In this section, you will learn more about these problems; then, in the next section, we can analyze them more deeply and you will learn techniques that will facilitate working with the instructions.
Let's start with the new
drawing.kv
code as follows:
114. # File name: drawing.kv (Rotate, Translate, and Scale) 115. <DrawingSpace>: 116. pos_hint: {'x':.5, 'y':.5} 117. canvas: 118. Rectangle: 119. source: 'kivy.png' 120. Rotate: 121. angle: 90 122. axis: 0,0,1 123. Color: 124. ...