This site requires JavaScript, please enable it in your browser!
Greenfoot back
Arkin
Arkin wrote ...

2017/10/10

Rotate an image scaled keeping scale

Arkin Arkin

2017/10/10

#
hello! I made a lot of surch on my browser but i didn find what i want. the situation is the following: i have a circle image that i changed the scale and i want to turn this image without changing the scale, i mean rotate the image and having a constant scale on it. the scale isn't a square, it's something like 50 by 150. if you have some questions, i'm really active so i'll answer the best i can the faster i can. good coding! :)
danpost danpost

2017/10/10

#
To allow better understanding of your issue, you should show the scaling and turning codes you are using (best is to show the entire class and indicate where in the class the pertinent codes are located). Also, it seems you are wanting (or not wanting -- hard to tell) the circle to be an oval. Please confirm or clarify.
Arkin Arkin

2017/10/10

#
i think my code is unsuefull, i think restart my code is a better idea. So what i want is that the circle turn 2 degrees each frame and make the scale of this circle of 50 for x and 150 for y
danpost danpost

2017/10/10

#
You still need to supply some pertinent class code -- regardless. The only extra bit of info given on your second post is the rate of turning. Everything else is still unclear as to what you have and want.
Arkin Arkin

2017/10/10

#
So what i have is an image, what i want is that the image turn 2 degrees then is rescaled every time act is launched, for my code i have nothing interesting, really, what i have is the void act, that's all
danpost danpost

2017/10/11

#
Arkin wrote...
for my code i have nothing interesting, really, what i have is the void act, that's all
Regardless of how uninteresting it is, you still need to show the class.
Arkin Arkin

2017/10/11

#
1
2
3
4
5
6
7
8
9
10
11
12
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
 
public class portal_b extends Actor{
    public portal_b(){
        GreenfootImage image = getImage();
        image.scale(50,100);
        setImage(image);
    }
    public void act(){
         
    }
}
it it's really usefull for you....
Super_Hippo Super_Hippo

2017/10/11

#
You could add a "turn(2);" to your act method. Is that what you want?
Arkin Arkin

2017/10/11

#
no it doesn't work the object turn, but what i want is the image turn and the scale doesn't change. The idea is to make an animation without makeing 180 images (the idea is to optimise the game). do you understand what i want to say?
danpost danpost

2017/10/11

#
So, you want your image to always be 50 wide from left to right and 100 high regardless of what rotation it may have -- that is, the image is to stretch and shrink, contorting to that size as it rotates. Is that correct?
Arkin Arkin

2017/10/11

#
Exactely, perfect you understand what i want. I'm verry sorry about my english i make my maximum, but perfect you understand exactely what i want!
danpost danpost

2017/10/11

#
This is probably possible; but, it would take a bit of doing to code it properly. The first thing to understand is what happens when the size of an image is changed. When making an image larger (in one or both dimensions), pixilation occurs due to filling in the new area; and when making an image smaller (in one or both dimensions), degradation in quality (loss of detail) occurs due to the removal of some of the image. This being said, constantly scaling an image over time will dramatically distort the image (especially when rotating it also). Therefore, you should keep a base image at hand and copy it to work on each act. You mentioned that your image was a circle, which does make things, by far, less complicated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import greenfoot.*;
 
public class portal_b extends Actor
{
    GreenfootImage baseImage;
    int imageRotation;
 
    public portal_b()
    {
        baseImage = getImage();
        updateImage();
    }
     
    public void act()
    {
        imageRotation += 2;
        updateImage();
    }
     
    private void updateImage()
    {
        GreenfootImage image = new GreenfootImage(baseImage);
        image.rotate(imageRotation);
        image.scale(50, 150);
        setImage(image);
    }
}
This is not tested, but I hope it does what you want. Also, I will not be able to afford any extra advise for the next few hours. Program well.
You need to login to post a reply.