基于html5绘制圆形多角图案

2020-04-24 18:55:26易采站长站整理

      x1 =100;   
      y1 =0;   
      ctx.beginPath();   
      for(var i = ci *2; i >0; i–){   
        ctx.rotate(pi);   
        ctx.moveTo(r,0);   
        y2 = r * Math.sin(pi);   
        x2 = r * Math.cos(pi);   
  
        x3 = (r – x2) /2+ x2 +10+ Math.random() *20;   
        y3 = y2 /2;   
  
        ctx.lineTo(x3,y3);   
        ctx.lineTo(x2,y2);   
      }   
      ctx.fill();   
      ctx.restore();   
      r <=100&& (r +=2);   
   },100);