canvas擦除圆形

function clearArcFun(x,y,r,cxt){    //(x,y)为要清除的圆的圆心,r为半径,cxt为context
	 var stepClear=1;//别忘记这一步  
     clearArc(x,y,r);
	 function clearArc(x,y,radius){
	     var calcWidth=radius-stepClear;  
	     var calcHeight=Math.sqrt(radius*radius-calcWidth*calcWidth);  
	    	
	     var posX=x-calcWidth;  
	     var posY=y-calcHeight;  
		                      
	     var widthX=2*calcWidth;  
	     var heightY=2*calcHeight;  
		                      
	     if(stepClear<=radius){  
	         cxt.clearRect(posX,posY,widthX,heightY);  
	         stepClear+=1;  
	         clearArc(x,y,radius);  
	     }  
	 }  
}

 

你可能感兴趣的:(javascript,canvas)