Skip to content

Instantly share code, notes, and snippets.

@kawaynejohnson
Created November 30, 2015 21:28
Show Gist options
  • Save kawaynejohnson/5c8490bcebf5d7985c25 to your computer and use it in GitHub Desktop.
Save kawaynejohnson/5c8490bcebf5d7985c25 to your computer and use it in GitHub Desktop.
Tiny Turtle
<canvas width=300 height=300></canvas>
// Required
TinyTurtle.apply(window);
// Write a function called box that draws a box
// It should take one parameter, sideLength
function box(sideLength) {
forward(sideLength);
left(90);
forward(sideLength);
left(90);
forward(sideLength);
left(90);
forward(sideLength);
}
function triangle(sideLength) {
forward(sideLength);
right(120);
forward(sideLength);
right(120);
forward(sideLength)
}
// ...when your function is complete. This should work!
box(100);
triangle(50);
<script src="//toolness.github.io/tiny-turtle/tiny-turtle.js"></script>
body {
background: gray;
text-align: center;
}
canvas {
background: white;
margin: 5vh 0 0;
width: 90vh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment