Iryna Bolbat преди 2 години
родител
ревизия
dd31b1f506
променени са 2 файла, в които са добавени 38 реда и са изтрити 0 реда
  1. 13 0
      work in class/Canvas/index.html
  2. 25 0
      work in class/Canvas/main.js

+ 13 - 0
work in class/Canvas/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <canvas id="canvas"></canvas>
+    <script src="main.js"></script>
+</body>
+</html>

+ 25 - 0
work in class/Canvas/main.js

@@ -0,0 +1,25 @@
+let ctx = canvas.getContext("2d");
+ctx.beginPath();
+ctx.arc(50, 50, 50, Math.PI/6, -Math.PI/6, false);
+ctx.lineTo(50, 50);
+ctx.closePath();
+ctx.strokeStyle = 'black';
+ctx.fillStyle = "green";
+ctx.fill();
+ctx.stroke();
+
+ctx.beginPath();
+ctx.arc(57, 25, 5, 0, 2 * Math.PI);
+ctx.fillStyle = "black";
+ctx.fill();
+ctx.stroke();
+
+function drawCircle(e){
+    ctx.beginPath();
+    ctx.arc(e.layerX, e.layerY, 5, 0, 2 * Math.PI, false);
+    ctx.fillStyle ="yellow";
+    ctx.fill()  
+    ctx.stroke();
+}
+
+canvas.addEventListener("click", drawCircle);