Hi. I was reading Drawing graphics and came up with two questions. Can someone help?
-
Taken from
0_canvas_start/style.css
:body { margin: 0; overflow: hidden; }
The problem is, if I comment out
overflow: hidden;
, the scroll bar appears. I am confused because without the margin, the size of the canvas should be exactly the same with the window. So why is there still a scroll bar?P.S. I came up with this question when I was reading the translated version. It said that
margin: 0;
was used to remove the margin that causes the overflow. However, it didn’t explain aboutoverflow: hidden;
. Then I checked the English version of the guide, and realized that the explanation ofstyle.css
was removed about 2 years ago. The translated version hasn’t been updated for years, so that part was still preserved. -
Taken from
7_canvas_walking_animation/script.js
:ctx.fillRect(-(width/2),-(height/2),width,height);
I thought it should be
ctx.fillRect(-(width/2),-(height/2),width/2,height/2);
because earlier we “made the coordinate origin sit in the middle of the canvas”. However, after trying it out, I found that only the top left quarter was cleared. I don’t understand.