Skip to content

Instantly share code, notes, and snippets.

@nimzco
Created November 18, 2011 09:55
Show Gist options
  • Save nimzco/1376045 to your computer and use it in GitHub Desktop.
Save nimzco/1376045 to your computer and use it in GitHub Desktop.
draw: function() {
// Set new Height and Width of the browser's window
var windowHeight = window.innerHeight;
var windowWidth = window.innerWidth;
// Compute size of the Canvas again
var canvasHeight = windowHeight * .99; // 99% to prevent scrollbars
var canvasWidth = windowWidth * .99;
// Compute all sizes again
var menuSpacing = canvasHeight * this.options.menuSpacing;
var menuHeight = (canvasHeight - (this.nbMenu + 1) * menuSpacing) / this.nbMenu;
var menuWidth = canvasWidth * this.options.menuWidth;
var menuX = (canvasWidth - menuWidth) / 2;
this.fontSize = menuHeight * this.options.fontSize;
this.paper.setSize(canvasWidth, canvasHeight);
for (var i = 0; i < this.nbMenu; i += 1) {
this.menuRects[i].attr('x', menuX);
this.menuRects[i].attr('y', menuSpacing + (i * (menuHeight + menuSpacing)));
this.menuRects[i].attr('width', menuWidth);
this.menuRects[i].attr('height', menuHeight);
this.menuTexts[i].attr('x', canvasWidth / 2);
this.menuTexts[i].attr('y', menuSpacing + (menuHeight / 2) + i * (menuHeight + menuSpacing));
this.menuTexts[i].attr('font-size', this.fontSize);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment