Skip to content

Instantly share code, notes, and snippets.

@venkat
Created May 21, 2017 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save venkat/fcf2055129b1fb229973e2929f5f006f to your computer and use it in GitHub Desktop.
Save venkat/fcf2055129b1fb229973e2929f5f006f to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=fcf2055129b1fb229973e2929f5f006f
<!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>
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();
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