标签:html eee get height fun class lan sem div
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>canvas实现简单的画图工具中画笔效果</title> </head> <body> <canvas width="500" height="500" style="background:#eee;"></canvas> <script> var canvas = document.getElementsByTagName(‘canvas‘)[0]; var con = canvas.getContext(‘2d‘); canvas.onmousedown = function(e){ var mx = e.layerX, my = e.layerY; con.moveTo(mx,my); canvas.onmousemove = function(e){ var ex = e.layerX, ey = e.layerY; con.lineTo(ex,ey); con.stroke(); } canvas.onmouseup = function(){ canvas.onmousemove = null; canvas.onmouseup = null; } } </script> </body> </html>
标签:html eee get height fun class lan sem div
原文地址:http://www.cnblogs.com/webBlog-gqs/p/7956004.html