canvas问题 为什么矩形可以画出来 圆却不可以

$(document).ready(function (){

    width = window.innerWidth;
    height = window.innerHeight;

    canvas = document.getElementById('myCanv');        
    canvas.width = width;
    canvas.height = height;

    var c=document.getElementById("myCanv");
    var canv=c.getContext("2d");
    canv.fillStyle="#FF0000";

    canv.beginPath();
    var h = 20;


    var y = 0;
    
    function draw() {
        if (y < canvas.height/2) {
            canv.fillRect(170,y,15,1);
            canv.clearRect(170,y-15,15,1);
            y++;
        };

        if (y >= canvas.height/2) {
            canv.clearRect(170,y+21,15,1);
            y++;
        };

        if ( h < canvas.height/2) {
            canv.arc(70,h,15,0,Math.PI*2,true);
            h++;
        };
    };

    canv.closePath();
    canv.fill();

    setInterval(draw,15);
阅读 2.5k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏