zoukankan      html  css  js  c++  java
  • 兼容IE浏览器的canvas画线和圆圈

    1.新建test.html文件,代码如下:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>人脉地图</title>
        <script type="text/javascript" src="js/jquery.js"></script>
        <!--[if lte IE 9]>
            <script src="js/excanvas.js"></script>
            <!--[if gt IE 9]><!-->
        <![endif]-->
        <script>
            (function($){
                $(window).on('load', function(){
                    getline();
                    drawarc();
                });
            })(jQuery);
            function getline(){
                var myCanvas = document.getElementById("box1");
                var context = myCanvas.getContext("2d");
                context.strokeStyle = "blue";
                context.lineWidth = 1;
                context.beginPath();
                context.strokeRect(0,0,300,200);
                context.strokeStyle = "red";
                context.moveTo(50,50);
                context.lineTo(100,100);
                context.stroke();
            }
            function drawarc(){
                var c = document.getElementById("box1");
                var ctx = c.getContext("2d");
                ctx.beginPath();
                ctx.lineWidth = 1;
                //画圈
                ctx.arc(100, 100, 20, 0, Math.PI * 2, true);
                ctx.stroke();
            }
        </script>

    </head>
    <body>
    <canvas id = "box1">Canvas画线技巧</canvas>
    </body>
    </html>

    2.下载jquery.js ,excanvas.js放入到js文件夹下

  • 相关阅读:
    webrtc vp8与h264 sdp文件解读
    如何着手学习WebRTC开发(转)
    python第二次周末大作业
    python 面向对象(六)MRO C3算法 super
    python 面向对象(五)约束 异常处理 MD5 日志处理
    python 面向对象(经典作业讲解)
    python 面向对象(四)反射
    python 面向对象(三)类与类之间的关系 初始化方法一些类
    python 面向对象(二)成员
    python 面向对象(一)初识面向对象
  • 原文地址:https://www.cnblogs.com/myphper/p/3972637.html
Copyright © 2011-2022 走看看