Calculate widths and heights