Resize canvas when required.