首页 > 代码库 > HTML——canvas1

HTML——canvas1

 1 <html> 2     <head> 3         <script src="easeljs-0.7.1.min.js"></script> 4     </head> 5     <body> 6         <canvas id="canvas" width="500px" height="500px"></canvas> 7       <script> 8                var canvas; 9 var stage;10 var txt;11 var count=0;12 //window.onload 页面数据初始化之类的工作13 window.onload=function(){14       canvas=document.getElementById("canvas");15     //创建一个新舞台16     stage=new createjs.Stage(canvas);17     //创建一个新文本(文本,大小,字体,颜色)18     txt =new createjs.Text("number->","20px Arial","#ff7700"); 19     //把这个文本添加到舞台中20     stage.addChild(txt);21     //FPS 每秒中页面刷新的次数(frames per second)22     createjs.Ticker.setFPS(5);23     //添加侦听事件并处理函数24     createjs.Ticker.addEventListener("tick",tick);25     26 }27 28 function tick(e){29       count++;30       txt.text="number->"+count+"!";31       //更新舞台的数据32       stage.update();33     }34           </script>35     </body>36 </html>

 

HTML——canvas1