Big sketch size and displaying an image make my program choppy, is there a solution to that?
in
Programming Questions
•
11 months ago
First I'm going to introduce you to my project so you can understand my problem better.
The main idea of my project is to draw a windmill and rotate it. There are many other specifications regarding it's movement like the deceleration on the second click, randomizing it's speed etc. (I solved all this problems), but you don't need to know this stuff, they're not the issue. First, I was given a PNG picture of a windmill and I just loaded it, put it in the sketch and rotated it in every frame. It worked fine, but it's just too choppy. The sketch dimensions have to be 1920x1080 because that are the dimensions of the monitor it will finally be ran on.
Here is the very simplified version of my code, this is just a PNG rotating in the middle of the screen, notice how choppy it is:
1. If I set the sketch size to, let's say, 800x800, it runs much more smoother (even if I let the image's size be 700x700).
2. If I resize the image to half it's size (with the sketch size 1920x1080) it also runs much smoother.
The only thing I know now is that both sketch size and image size effect the choppiness of the program, but I just can't touch those parameters, the size of the sketch has to be 1920x1080, and the image size has to be about 700x700.
Do you have any solutions to that problem?
If not, how hard is to construct a simple windmill in Processing using curves/bezier/... (I've never used them in Processing)?
Thanks in advance,
Cheers
The main idea of my project is to draw a windmill and rotate it. There are many other specifications regarding it's movement like the deceleration on the second click, randomizing it's speed etc. (I solved all this problems), but you don't need to know this stuff, they're not the issue. First, I was given a PNG picture of a windmill and I just loaded it, put it in the sketch and rotated it in every frame. It worked fine, but it's just too choppy. The sketch dimensions have to be 1920x1080 because that are the dimensions of the monitor it will finally be ran on.
Here is the very simplified version of my code, this is just a PNG rotating in the middle of the screen, notice how choppy it is:
- PImage v;
- float t = 0;
- float inc = 4;
- void setup() {
- v = loadImage("http://i.imgur.com/IMdHL.png"); // I googled this picture
- size(1920, 1080);
- imageMode(CENTER);
- }
- void draw() {
- background(255);
- pushMatrix();
- translate(width/2, height/2);
- rotate(radians(t));
- image(v, 0, 0);
- popMatrix();
- t += inc;
- }
1. If I set the sketch size to, let's say, 800x800, it runs much more smoother (even if I let the image's size be 700x700).
2. If I resize the image to half it's size (with the sketch size 1920x1080) it also runs much smoother.
The only thing I know now is that both sketch size and image size effect the choppiness of the program, but I just can't touch those parameters, the size of the sketch has to be 1920x1080, and the image size has to be about 700x700.
Do you have any solutions to that problem?
If not, how hard is to construct a simple windmill in Processing using curves/bezier/... (I've never used them in Processing)?
Thanks in advance,
Cheers
1