87,994
社区成员
发帖
与我相关
我的任务
分享
<canvas id="x" width="400" height="300" style="border:1px solid #eee;">hello,canvas!</canvas>
<script type="text/javascript" src="http://www.easyui.org.cn/easyui.js"></script>
<script type="text/javascript">
var dx = document.getElementById('x');
var client = navigator.userAgent+'\n'+navigator.appVersion+'\n\n';
var dimg = new Image();dimg.src = 'http://www.v-ec.com/ijc/jslab_logo.png';
var show = function(){
if(!dx.getContext){alert(client+'不支持Canvas');return;}
var dxC = dx.getContext('2d');
dxC.fillStyle = '#00f';
dxC.strokeStyle = '#f00';
dxC.lineWidth = 2;
easyUI.queue([
function(){dxC.fillRect(0,0,400,300);},
function(){dxC.clearRect(10,10,380,280);},
function(){dxC.fillStyle='rgba(0,0,0,0.2)';dxC.fillRect(15, 15, 370, 30);},
function(){dxC.strokeStyle='#AC904B';dxC.fillStyle='#EACA06';dxC.beginPath();dxC.moveTo(50,50);
dxC.lineTo(80,100);dxC.lineTo(20,100);dxC.lineTo(50,50);dxC.fill();dxC.stroke();dxC.closePath();
},
function(){if(!dxC.fillText){alert(client+'不支持fillText');return;}dxC.fillStyle='#000';dxC.font = 'bold 30px Arial';dxC.fillText('!',46,90);},
function(){dxC.strokeStyle='#2A66B2';dxC.fillStyle='#2D7FE2';dxC.beginPath();
dxC.arc(120,75,25,0,Math.PI*2,true);dxC.fill();dxC.stroke();dxC.closePath();
},
function(){dxC.drawImage(dimg,50,150);}
],1000);
};
window.onload = show;
</script>