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
Forum Archive
Help with rotating images
Maybe you should start using layers. The problem is that in:
i = scene.image('Alien_Monster', 0, 0) # i is set to Nonethe 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:
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())
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 after you draw it then you must turn the canvas before you draw it. You learn something new every day.
Keeping track of properly balancing repeated calls to push_matrix() and pop_matrix() was bugging me so see https://gist.github.com/cclauss/6313658 for the syntax:
with privateMatrix(): # Save and then restore the scene.matrix
translate(200, 200)
rotate(45)
image('Alien_Monster', 0, 0, 100, 100)
This should eliminate the complexity of calling push_matrix() and pop_matrix() repeatedly in programs that heavily use Scene scale(), transform(), rotation(), etc.