Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Help with rotating images
-
Is there anyway to rotate images in scene module without layers. I just want to use the built in image equals sign and turn it side ways to be a pause button
-
Maybe you should start using layers. The problem is that in:<pre>i = scene.image('Alien_Monster', 0, 0) # i is set to None</pre>the i variable is set to None. Scene.image() does not provide an image variable so i.center(), i.skew(), i.rotate(), etc. are not possible. However, if you draw your images into layers then lots of things become possible.
An alternative to adopting layers would be to use the Python Imaging Library (PIL) to rotate the image BEFORE you make the call to scene.image().
-
You can rotate images like this:<pre>from scene import *
class MyScene (Scene):
def setup(self):
passdef draw(self): background(0, 0, 0) push_matrix() translate(200, 200) rotate(45) image('Alien_Monster', 0, 0, 100, 100) pop_matrix()
run(MyScene())</pre>
-
Thanks Sebastian once again. ccc I am using multiple scene code omz made without layers but thanks anyway
-
I'm glad I could help :)
-
Thanks also Sebastian -- If you can't turn the image <b>after</b> you draw it then you must turn the canvas <b>before</b> you draw it. You learn something new every day.
Keeping track of properly balancing repeated calls to <b>push_matrix()</b> and <b>pop_matrix()</b> was bugging me so see https://gist.github.com/cclauss/6313658 for the syntax:
<pre>with privateMatrix(): # Save and then restore the scene.matrix
translate(200, 200)
rotate(45)
image('Alien_Monster', 0, 0, 100, 100)</pre>
This should eliminate the complexity of calling push_matrix() and pop_matrix() repeatedly in programs that heavily use Scene scale(), transform(), rotation(), etc.