Before using canvas to paint, are directly in the canvas label directly written on the width of the high, no problem, but also did not explore why the width of the canvas directly in the label, because the various data examples are so written. Today, Mr Wang raises a question: If you write the width and height in <style>, see what's different. I tried the following, and sure enough there was a problem.
Check the code First:
<! DOCTYPE html>
1. Width: 400, High: 300, direct write in <canvas> effect:
2, delete the <canvas> width, Width: 400; High: 300; effect written in <style>:
Why are the two effects different?
Canvas, like any other label, can also define styles through CSS. However, it is important to note that the default width of canvas is 300px * 150px, the canvas is defined in CSS for a wide height, in fact, the width of 300px * 150px is stretched, if in this case canvas drawing, The graphic you get may be the effect of deformation. Therefore, when you draw a canvas, you should define the width height directly in the canvas label.
Canvas canvas height should be written in the <canvas> tab