| 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: black;
- }
- </style>
- </head>
- <body>
- <canvas id="can" width="500" height="400"></canvas>
- <script>
- var oCan = document.getElementById("can");
- var aCan = oCan.getContext("2d");
- aCan.strokeStyle = "white";
- aCan.lineWidth = 3;
- oCan.onmousedown = function(event){
- aCan.moveTo(event.clientX,event.clientY);
- oCan.onmousemove = function(event){
- aCan.lineTo(event.clientX,event.clientY);
- aCan.stroke();
- }
- }
- oCan.onmouseup = function(){
- oCan.onmousemove = null;
- }
- </script>
- </body>
- </html>
|