最近在用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>
翰术