Skip to content

Instantly share code, notes, and snippets.

@GoToLoop
Created June 28, 2019 17:44
Show Gist options
  • Save GoToLoop/54b4c49e9c2541da2d91692bf0c01192 to your computer and use it in GitHub Desktop.
Save GoToLoop/54b4c49e9c2541da2d91692bf0c01192 to your computer and use it in GitHub Desktop.
windowResized()
function windowResized() {
const css = getComputedStyle(canvas.parentElement),
mw = float(css.marginLeft) + float(css.marginRight),
mh = float(css.marginTop) + float(css.marginBottom),
ww = float(css.width) || windowWidth,
wh = float(css.height) || windowHeight,
w = round(ww - mw), h = round(wh - mh);
resizeCanvas(w, h, true);
}
p.windowResized = function () {
const css = getComputedStyle(this.canvas.parentElement),
mw = this.float(css.marginLeft) + this.float(css.marginRight),
mh = this.float(css.marginTop) + this.float(css.marginBottom),
ww = this.float(css.width) || this.windowWidth,
wh = this.float(css.height) || this.windowHeight,
w = this.round(ww - mw), h = this.round(wh - mh);
this.resizeCanvas(w, h, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment