zoukankan      html  css  js  c++  java
  • html5 canvas 小例子 简易画板

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Canvas</title>
        <script src="jQuery.js"></script>
    </head>
    <style type="text/css">
        body{
            padding: 0;
            margin: 0;
            background: black;
        }
        #canvas{
            background: white;
            margin: 100px 0 0 300px;
        }
        #canvas > span{
            color: white;
            font-size: 14px;
        }
    </style>
    <body>
        <canvas id="canvas" width="600" height="500">
            <span>您的浏览器不支持</span>
        </canvas>
    </body>
    </html>
    <script type="text/javascript">
        /*获取绘制环境*/    
        var oc = $('#canvas')[0];
        canvas = oc.getContext('2d');    
        $('#canvas').on('mousedown', function(){
            /*开始绘制*/        
            canvas.beginPath();
            /*设置动画绘制起点坐标*/
            canvas.moveTo(event.pageX - 300 , event.pageY - 100);
            $('#canvas').on('mousemove', function(){
                /*设置下一个点坐标*/
                canvas.lineTo(event.pageX - 300 , event.pageY - 100);
                /*画线*/
                canvas.stroke();
            });
        }).on('mouseup', function(){
            $('#canvas').off('mousemove');
        });    
    </script>
  • 相关阅读:
    数据结构实验2-迷宫
    离散实验4
    关系代数中的除法运算
    数据库中什么叫象集
    (转)汇编-补码
    2014022201
    20140222
    2014022101
    代码20140221
    代码20140215
  • 原文地址:https://www.cnblogs.com/lovling/p/6440677.html
Copyright © 2011-2022 走看看