首頁  >  文章  >  web前端  >  HTML5畫電路圖

HTML5畫電路圖

阿神
阿神原創
2016-11-08 14:30:053235瀏覽

画图API的应用,线,圆等

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
<meta name="description" content="canvas画简单电路图 by hovertree.com" />
</head>
<body>
    <canvas id="canHewenqi" width="500" height="300" style="margin: 20px auto"></canvas>
     
    <script>
        var canvas = document.getElementById("canHewenqi");
        var cxt = canvas.getContext("2d");
         
        cxt.moveTo(10,10);
        cxt.lineTo(100,10);
        cxt.stroke();
        cxt.beginPath();
        cxt.moveTo(100,10);
        cxt.lineTo(100,0);
        cxt.lineTo(150,0);
        cxt.lineTo(150,20);
        cxt.lineTo(100,20);
        cxt.closePath();
        cxt.moveTo(150,10);
        cxt.lineTo(250,10);
        cxt.lineTo(250,100);
        cxt.stroke();
        cxt.moveTo(225,100);
        cxt.lineTo(275,100);
        cxt.stroke();
        cxt.moveTo(225,115);
        cxt.lineTo(275,115);
        cxt.stroke();
        cxt.moveTo(250,115);
        cxt.lineTo(250,160);
        cxt.stroke();
        cxt.moveTo(250,160);
        cxt.lineTo(150,160);
        cxt.stroke();
        cxt.arc(130,160,20,0,360,false);
        cxt.stroke();
        cxt.moveTo(150,160);
        cxt.lineTo(10,160);
        cxt.lineTo(10,10);
        cxt.stroke();   
    </script>
</body>
</html>


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn