This site requires JavaScript, please enable it in your browser!
Greenfoot back
vtn2@calvin.edu
vtn2@calvin.edu wrote ...

2014/6/18

rotating image is broken?

vtn2@calvin.edu vtn2@calvin.edu

2014/6/18

#
Here is my very simple code:
    
    public Allig()
    {
        getImage().rotate(45);
    }
   
    public void act() 
    {
    }    
All this does is rotate the default image by 45 degrees... The default image is the alligator.png. (I've tried with other images too.) When the code runs, the image gets all screwed up. (I can't figure out how to After the rotate it looks like this: Is there something I am doing wrong? Or is this a bug? Thanks. Vic
vtn2@calvin.edu vtn2@calvin.edu

2014/6/18

#
Huh... those image links didn't seem to work. Here they are again: http://imgur.com/aJlKvIC After rotate(45) http://imgur.com/72h1Mea
danpost danpost

2014/6/18

#
That is not a bug. It is doing what it is supposed to do. The problem is that your image is wider than it is high and the size of the image does not change when you rotate the image. Draw the image onto a larger sized image and then rotate:
GreenfootImage image = new GreenfootImage(getImage().getWidth(), getImage().getWidth());
image.drawImage(getImage(), 0, (image.getHeight()-getImage().getHeight())/2);
image.rotate(45);
setImage(image);
davmac davmac

2014/6/20

#
Huh... those image links didn't seem to work
The problem is that you linked to the imgur page for the image, and not to the image itself. The correct URLs are: http://i.imgur.com/aJlKvIC.png http://i.imgur.com/72h1Mea.png Which look like this: and
You need to login to post a reply.