Why changing canvas size resets its parameters?
Because when you change the canvas width or height parameters, every properties of the attached context are reset to their default. From specs When the canvas element is created, and subsequently whenever the width and height attributes are set (whether to a new value or to the previous value), the bitmap and any associated contexts … Read more