Skip to content

Instantly share code, notes, and snippets.

@tosbourn
Created April 17, 2012 13:52
Show Gist options
  • Save tosbourn/2406097 to your computer and use it in GitHub Desktop.
Save tosbourn/2406097 to your computer and use it in GitHub Desktop.
Quick Calc Function
/**
* Quick calc functionality.
*
* Make sure you pass values of the same metric (all inches, or all centimetres or whatever)
* @input fw int floor width.
* @input fl int floor length.
* @input tw int tile width.
* @input tl int tile length.
*
* @return int Number of tiles.
*/
function floorCalc(fw, fl, tw, tl) {
var tiles_needed_length = ceil(parseInt(fl, 10) / parseInt(tl, 10)),
tiles_needed_width = ceil(parseInt(fw, 10) / parseInt(tw, 10));
return tiles_needed_length * tiles_needed_width;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment