Created
May 21, 2017 23:16
-
-
Save venkat/2e95b19b31a56e188704fd921f9b895c to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=2e95b19b31a56e188704fd921f9b895c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://toolness.github.io/tiny-turtle/tiny-turtle.js"></script> | |
<script src="script.js"></script> | |
<title>Tiny Turtle Unit 10</title> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
</head> | |
<body> | |
<h1>Tiny Turtle</h1> | |
<canvas></canvas> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TinyTurtle.apply(window); | |
function arc() { | |
penStyle = 'purple'; | |
for (var i = 0; i < 20; i = i + 1) { | |
forward(7); | |
right(8); | |
} | |
} | |
// On line 19 call the squareFractal function. What happens? | |
function squareFractal(){ | |
for(var i = 0; i<5; i = i +1){ | |
penStyle = '00FF00'; | |
forward(30); | |
right(90); | |
forward(30); | |
right(90); | |
forward(30); | |
right(90); | |
forward(30); | |
right(90); | |
//turn starting direction 30 degrees | |
//penUp(); | |
forward(40); | |
right(40); | |
//penDown(); | |
} | |
} | |
//squareFractal(); | |
function prettyArcs() { | |
for(var i=0; i <10; i = i + 1) { | |
arc(); | |
penUp(); | |
left(50); | |
forward(-70); | |
penDown(); | |
} | |
} | |
prettyArcs(); | |
//Let's refactor this code an break it up into smaller parts. Write the function square code the that makes a square on the canvas. | |
function square(){ | |
for(var i = 0; i<4; i = i +1){ | |
} | |
} | |
// In the loop write the code that rotates the arrow and draws a new square 20 times. | |
for(var i = 0; i<20; i = i +1){ | |
} | |
//Make your own fractal art using a different shape. | |
//do not remove the stamp function. This should remain at the end of the program. | |
//stamp(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas{ | |
width: 500px; | |
height: 300px; | |
border: 1px solid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment