How to resize canvas by percentage

This example code is for resizing canvas by percentage.