Skip to content

Instantly share code, notes, and snippets.

@alexpelan
Created December 4, 2017 02:37
Show Gist options
  • Save alexpelan/9e878827b8a841291abb36d146535f30 to your computer and use it in GitHub Desktop.
Save alexpelan/9e878827b8a841291abb36d146535f30 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=9e878827b8a841291abb36d146535f30
  1. In your HTML, give your page a title <title> Function Declaration </title>
  2. Call the square function 4 times to draw 4 squares
  3. Call the rectangle function 2 times to draw 2 rectangles.
<!DOCTYPE html>
<html>
<head>
<title>Tiny Turtle</title>
<script src="https://toolness.github.io/tiny-turtle/tiny-turtle.js"></script>
</head>
<body>
<h1>Tiny Turtle</h1>
<canvas></canvas>
</body>
</html>
// Tiny Turtle Setup. Avoid modifying these lines of code!
var adjCanvasSize = document.getElementsByTagName('canvas')[0];
adjCanvasSize.width = 400;
adjCanvasSize.height = 400;
TinyTurtle.apply(window);
function square() {
forward(30);
right(90);
forward(30);
right(90);
forward(30);
right(90);
forward(30);
}
function rectangle() {
forward(30);
right(90);
forward(90);
right(90);
forward(30);
right(90);
forward(90);
}
canvas {
border: 1px solid black;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment