Dynamic resizing of canvas