Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!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>
- canvas {
- border: 2px solid black;
- }
- </style>
- </head>
- <body>
- <canvas id="myCanvas" width="600" height="600"></canvas>
- <script>
- var c = document.getElementById("myCanvas");
- var ctx = c.getContext("2d");
- ctx.beginPath();
- ctx.lineWidth = 10;
- ctx.strokeStyle = "#FF0000";
- ctx.rect(20, 20, 150, 100);
- ctx.stroke();
- ctx.lineWidth = 5;
- ctx.beginPath();
- ctx.arc(70, 70, 30, 0, Math.PI * 2);
- ctx.fillStyle = "red";
- ctx.stroke();
- ctx.lineWidth = 15;
- ctx.beginPath();
- ctx.moveTo(0, 0);
- ctx.lineTo(300, 150);
- ctx.stroke();
- ctx.font = "30px Arial";
- ctx.fillText("Hello World", 350, 150);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment