-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathDemo.html
More file actions
38 lines (33 loc) · 937 Bytes
/
Copy pathDemo.html
File metadata and controls
38 lines (33 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<canvas style="border: 1px solid black" id="mycanvas" height ="800" width = "1200">
</body>
<script src="turtle.js"></script>
<script defer>
//Get the canvas from the body
const canvas = document.getElementById("mycanvas");
const p = new Turtle(canvas);
//place the pen on the canvas. First argument is the x position, second argument is the y position.
p.moveto(400, 350);
p.penDown = true;
//This function draws a square. The function isn't called so this code does nothing.
//Argument is the size of the square.
function Square(size){
for(let i = 0; i < 4; i++){
p.forward(size);
p.right(90);
}
}
//This code is getting executed.
for(let i = 0; i < 6; i++){
p.forward(50);
p.left(45);
}
</script>
</html>