Browse Source

canvas cw

Mitrofanova Natali 2 years ago
parent
commit
0f2810cabc

+ 5 - 0
ClassWorks/canvas/.idea/.gitignore

@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 12 - 0
ClassWorks/canvas/.idea/Calc.iml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/temp" />
+      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+      <excludeFolder url="file://$MODULE_DIR$/tmp" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
ClassWorks/canvas/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/Calc.iml" filepath="$PROJECT_DIR$/.idea/Calc.iml" />
+    </modules>
+  </component>
+</project>

+ 15 - 0
ClassWorks/canvas/index.html

@@ -0,0 +1,15 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>canvas</title>
+    <link rel="stylesheet" href="style.css">
+    
+</head>
+<body>
+<canvas id="canvas" width="500px"; height="500px"></canvas>
+
+<script src="script.js"></script>
+</body>
+</html>
+

+ 40 - 0
ClassWorks/canvas/script.js

@@ -0,0 +1,40 @@
+var canvas = document.getElementById("canvas");
+var ctx = canvas.getContext("2d");
+
+ctx.beginPath();
+ctx.arc(70, 70, 50, Math.PI/8, -Math.PI/8, false);
+ctx.lineTo(65,70);
+ctx.closePath();
+ctx.strokeStyle = "black";
+ctx.fillStyle = "yellow";
+ctx.fill();
+ctx.stroke();
+
+ctx.beginPath();
+ctx.arc(75, 45, 4, 0, 2 * Math.PI);
+ctx.fillStyle = "black";
+ctx.fill();
+ctx.stroke();
+
+function creatDots(amountOfDots){
+    let directionX = 50;
+    for(let i=0;i<amountOfDots;i++){
+        ctx.beginPath();
+        ctx.arc(directionX=directionX+50, 70, 5, 0, 2 * Math.PI, false);
+        ctx.fillStyle ="yellow";
+        ctx.fill()  
+        ctx.stroke();
+    }
+}
+creatDots(8)
+
+
+canvas.addEventListener("click", paint);
+
+function paint(e){
+    ctx.beginPath();
+    ctx.arc(e.layerX, e.layerY, 5, 0, 2 * Math.PI, false);
+    ctx.fillStyle ="red";
+    ctx.fill()  
+    ctx.stroke();
+}

+ 5 - 0
ClassWorks/canvas/style.css

@@ -0,0 +1,5 @@
+#canvas{
+ 
+    border: 1px solid grey;
+    margin: 50px 100px;
+}