HTML5 知识库
html5 canvas例子
阅读:799次
评论:0条
更新时间:2011-08-04
<!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"/> <title>HTML5</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> </head> <body> <canvas id="canvas" width="640" height="480"></canvas> <script type="text/javascript"> $(document).ready(function(){ var canvas = $("#canvas").get(0); var ctx = canvas.getContext("2d"); var width = canvas.width; var height = canvas.height; ctx.beginPath(); ctx.moveTo(0,0); ctx.lineTo(width,0); ctx.lineTo(width, height); ctx.lineTo(0, height); ctx.lineTo(0, 0); ctx.lineWidth=12; ctx.lineCap="round"; ctx.stroke(); $("#canvas").click(function(event) { ctx.moveTo(event.pageX,event.pageY); ctx.lineTo(0,0); ctx.stroke(); }); }); </script> </body> </html>
评论 共 0 条 请登录后发表评论