首页 > 代码库 > html5之canvas绘图 1.写字板功能

html5之canvas绘图 1.写字板功能

       写字板事例:

    

      写字板分析:1.点击鼠标开始写字(onmosedown)2.按下鼠标写字(onmousemove)3.松开鼠标,停下写字(撤销onmousemove事件):

      代码:

<strong><!doctype html>  
</strong><html>  
    <head>  
        <meta charset="utf-8">  
        <title>Canvas</title>  
        <style type="text/css">  
            body {  
                margin: 0px;  
                padding: 0px;  
            }  
            #canvas {  
                margin: 0px;  
                padding: 0px;  
                border: 1px solid #000000;    
            }  
        </style>  
    </head>  
    <body>  
        <canvas id="canvas" width="400" height="400">当前浏览器不支持canvas</canvas>  
        <script type="text/javascript" src=http://www.mamicode.com/"utils.js"></script>  >


html5之canvas绘图 1.写字板功能