scale() problem
in
Programming Questions
•
2 years ago
int WIDTH=320;
int HEIGHT=224;
void setup() {
noStroke();
frame.setResizable(true);
background(0);
size(WIDTH,HEIGHT);
frameRate(1);
}
void draw() {
scale(width/WIDTH,height/HEIGHT);
fill(random(255),random(255),random(255));
rect(0,0,WIDTH,HEIGHT);
}
This is my source code.
The thing I want is make rectangle's size same as screen size as I change size of the screen.
There are some reason's I can't use rect(0,0,width,height); . I have to use scale();
I think that code should works well. But when I use that code, rectangle is not fit with the screen. There are something left as empty space in the right side and the bottom side.
Is there anybody who knows the reason why the size of the rectangle is not same as the size of the screen?
int HEIGHT=224;
void setup() {
noStroke();
frame.setResizable(true);
background(0);
size(WIDTH,HEIGHT);
frameRate(1);
}
void draw() {
scale(width/WIDTH,height/HEIGHT);
fill(random(255),random(255),random(255));
rect(0,0,WIDTH,HEIGHT);
}
This is my source code.
The thing I want is make rectangle's size same as screen size as I change size of the screen.
There are some reason's I can't use rect(0,0,width,height); . I have to use scale();
I think that code should works well. But when I use that code, rectangle is not fit with the screen. There are something left as empty space in the right side and the bottom side.
Is there anybody who knows the reason why the size of the rectangle is not same as the size of the screen?
1