globalCompositeOperation详解

 1 ctx.save(); 
 2 ctx.translate(w / 2, h / 2); 
 3 ctx.fillStyle = 'red'; 
 4 ctx.beginPath(); 
 5 ctx.arc(-40, 20, 80, 0, Math.PI * 2, true); 
 6 ctx.closePath(); 
 7 ctx.fill(); 
 8 ctx.globalCompositeOperation = 'source-in'; 
 9 ctx.fillStyle = 'orange'; 
10 ctx.beginPath(); 
11 ctx.arc(40, 20, 80, 0, Math.PI * 2, true); 
12 ctx.closePath(); 
13 ctx.fill(); 
14 ctx.restore();

 详情查看