Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windowResized() erase drawings #1876

Closed
gilfuser opened this issue Apr 3, 2017 · 2 comments
Closed

windowResized() erase drawings #1876

gilfuser opened this issue Apr 3, 2017 · 2 comments

Comments

@gilfuser
Copy link

gilfuser commented Apr 3, 2017

Well, I'm not sure if this is a bug but It is surely an issue and I couldn't find anything specific about that.
If I resize the window, anything that was drawn disappears.

A small example here:


function setup() {
  canv = createCanvas(windowWidth, windowHeight);
  canv.position(0, 0);
  stroke(255, 0, 0);
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

function draw() {
  if (mouseIsPressed){
    ellipse(0, 0, 100, 100);
  }
}
@lmccart
Copy link
Member

lmccart commented Apr 3, 2017

Yeah, unfortunately this is a limitation of the underlying HTML5 Canvas. Whenever it is resized, all content is erased. The workaround I suppose would be to save an array of all mouse coordinates as the mouse is pressed, and redraw them when the window is resized.

@gilfuser
Copy link
Author

gilfuser commented Apr 3, 2017

Thank you.
I was trying a workaround using createGraphics() but I got luck with that approach to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants