html5的阴影 shadow

 1 var canvas = document.getElementById("myCanvas");
 2     if(canvas.getContext == null){
 3         return false;
 4     }
 5     var context = canvas.getContext("2d");
 6     context.shadowBlur = 20;
 7     context.shadowColor = "rgb(0,0,0)";
 8     context.fillRect(150,150,100,100);
 9 
10     context.shadowBlur = 0;
11     context.shadowOffsetX = 10;
12     context.shadowOffsetY = 10;
13     context.shadowColor = "rgba(100, 100, 100, 0.5)";
14     context.fillRect(200,50,100,100);
15 
16     context.shadowColor = "rgb(255,0,0)";
17     context.shadowBlur = 50;
18     context.shadowOffsetX = 0;
19     context.shadowOffsetY = 0;
20     context.beginPath();
21     context.arc(400,100,50,0,Math.PI*2,false);
22     context.closePath();
23     context.fill();

shadowBlur   shadowOffsetX    shadowOffsetY  shadowColor  四个选项 

posted @ 2013-10-29 13:58  楚玉  阅读(477)  评论(0编辑  收藏  举报