Home > Web Front-end > H5 Tutorial > Draw a simple and beautiful circuit diagram in HTML5

Draw a simple and beautiful circuit diagram in HTML5

零下一度
Release: 2017-05-17 17:47:20
Original
4636 people have browsed it

Applications of drawing API, lines, circles, etc.

I have been very busy recently. Thanks to everyone’s care, I made an HTML5 circuit diagram by myself

<!DOCTYPE html><html lang="en"><head>
 <meta charset="UTF-8">
    <title>何问起</title>
<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>
<div>canvas画简单电路图 by 何问起</div>
<!--http://hovertree.com/code/html5/fatorqgm.htm-->
</body>
</html>
Copy after login

[Related recommendations]

1. Special recommendation: "php Programmer Toolbox" V0.1 version download

2. Free h5 online video tutorial

3. php.cn original html5 video tutorial

The above is the detailed content of Draw a simple and beautiful circuit diagram in HTML5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template