-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
Description
Nature of issue?
- [x ] Found a bug
- Existing feature enhancement
- New feature request
Most appropriate sub-area of p5.js?
- Color
- Core/Environment/Rendering
- Data
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Other (specify if possible)
Which platform were you using when you encountered this?
- Mobile/Tablet (touch devices)
- Desktop/Laptop
- Others (specify if possible)
Details about the bug:
- p5.js version: 0.5.8
- Web browser and version: Chrome and Firefox , latest version
- Operating System: Mac OSX Mojave
- Steps to reproduce this:
try to create a 1000x1000 virtual screen :
- create a 1000x1000 canvas
- resize to widowHeight or windowWidth, wichever is smaller
- deduce zoom with width/1000
-> It works perfectly
after windowResized event, reproduce the same steps, it's a fail. It's as if the origin was moved away, or as if the rectangle is scaled, but not moved ....
the centered rectangle is no more centered .
Here is the code to reproduce the bug :
var myCanvas, myZoom;
/*
virtual 1000x1000 screen
create screen
get needed zoom
scale
change scale on resize
*/
function setup() {
myCanvas = createCanvas(1000, 1000);
makeSize();
}
function draw() {
scale(myZoom);
background(0);
fill(255);
rect(250, 250, 500, 500); // centered in a 1000x1000 virtual screen
}
function windowResized() {
makeSize();
}
function makeSize() {
if (windowWidth > windowHeight) {
myCanvas.resize(windowHeight, windowHeight);
} else {
myCanvas.resized(windowWidth, windowWidth);
}
myZoom = width / 1000;
}