sunny1334
2016-05-02 20:09
3.9节中为什么ctx.fillStyle='blue'; ctx.fillRect(110,110,100,100);与 ctx.fillStyle='blue'; ctx.fillRect(10,10,100,100);画出来的蓝色图形不一样啊?
因为画布 Canvas 高度不够,容纳不了两个正方形,所以下方正方形被部分隐藏。
HTML
<canvas id="cvs"></canvas>
Javascript
alert("width:" + cvs.width + " height:" + cvs.height)
此时弹出 width: 300 height: 150
当设置画布 Canvas 高度为 900 时,则可显示两个正方形内容。
<canvas id="cvs" height=900 ></canvas>
画布 Canvas 绘制内容无法完全显示时,可以尝试调整画布大小
不懂哎
H5+JS+CSS3 实现圣诞情缘
122097 学习 · 231 问题
相似问题