soulwire / sketch.js

Cross-Platform JavaScript Creative Coding Framework
MIT License
4.09k stars 431 forks source link

Setting/updating canvas width to 100% #86

Open pimmey opened 8 years ago

pimmey commented 8 years ago

Right, setting it is quite straightforward, just doing

fullscreen: false,
width: window.innerWidth

Now, to update it, I did something like this:

gl.resize = function () {
    this.width = window.innerWidth; // Updating the width
    this.viewport(0, 0, this.width, this.height);
    return this.updateUniforms();
};

However it is quite choppy and doesn't update the width precisely. Only if I resize the window really slowly, it is more or less fine, but when doing it even a bit faster, it just doesn't fill the whole width.

Is there maybe another way to accomplish this?

Sporradik commented 4 years ago

I am experiencing the same issue

EDIT: @pimmey perhaps 3 years later is too late, but setting this.canvas.width and this.canvas.height ended up working for me.