最近在用w3school看html5,在用例子练习的时候,改了下坐标,然后对显示出来的结果有一些疑问,烦请大家帮忙解答<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="200" height="250" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var grd=ctx.createLinearGradient(0,0,170,0);
grd.addColorStop(0,"red");
grd.addColorStop(1,"black");
ctx.fillStyle=grd;
ctx.fillRect(0,0,170,100);
ctx.fillRect(20,120,170,100);
</script>
</body>
</html>
- 1 回答
- 0 关注
- 1499 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消