日期:2014-05-16 浏览次数:20344 次
window.onload = function(){ if(document.getElementById("c_canvas1")){ var ctx1 = document.getElementById("c_canvas1").getContext('2d'); } if(document.getElementById("c_canvas2")){ var ctx2 = document.getElementById("c_canvas2").getContext('2d'); } var ctx = ctx1||ctx2; var img = new Image(); var speed = 120; img.onload = function(){ function drawStar(){ for(var i = 0; i < 4; i++ ){ draw(i); } function draw(x){ setTimeout(function(){ ctx.clearRect(0,0,270,270); ctx.drawImage(img,0,270*x,270,270,0,0,270,270); },speed*x); } } setInterval(drawStar,480); } if( ctx == ctx1){ ctx = ctx1; img.src = 'themes/images/imgc/an1.png'; } if( ctx == ctx2){ ctx = ctx2; img.src = 'themes/images/imgc/an2.png'; } }