Skip to content

Instantly share code, notes, and snippets.

@nrwinner
Created June 10, 2018 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrwinner/091965dfe385d8d1c593709842046bd7 to your computer and use it in GitHub Desktop.
Save nrwinner/091965dfe385d8d1c593709842046bd7 to your computer and use it in GitHub Desktop.
Calculate width, height, and bottom position of rotated "angle" elements
let w = window.outerWidth;
let width = Math.ceil(w / Math.cos(ANGLE * Math.PI / 180));
let height = Math.ceil(w * Math.tan(ANGLE * Math.PI / 180));
let bottom = Math.floor((-1) * ((Math.tan(ANGLE * Math.PI / 180) * w) / 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment