123456789101112131415161718192021222324252627282930313233 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- #can{
- background-color: #000;
- }
- </style>
- </head>
- <body>
- <canvas id="can" width="400" height="300"></canvas>
- <script>
- var oCan = document.getElementById("can");
- var can = oCan.getContext("2d");
- can.strokeStyle = "white";
- can.lineWidth = 3;
- oCan.onmousedown = function(e){
- can.moveTo(e.clientX,e.clientY);
- oCan.onmousemove = function(e){
- can.lineTo(e.clientX,e.clientY);
- can.stroke();
- }
- oCan.onmouseup = function(){
- oCan.onmousemove = null;
- }
- }
- </script>
- </body>
- </html>
|