Created
March 12, 2017 23:52
-
-
Save mackenco/fd88136f91dcb98d71a7e97cc482763b to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=fd88136f91dcb98d71a7e97cc482763b
This file contains 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> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<canvas id="myCanvas"></canvas> | |
</body> | |
</html> |
This file contains 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
/* lines 2 - 14 set up functions to draw shapes | |
* you don't need to adjust them | |
*/ | |
var c=document.getElementById("myCanvas"); | |
var ctx=c.getContext("2d"); | |
function rectangle(length) { | |
ctx.rect(20,20,length*2,length); | |
ctx.stroke(); | |
} | |
function circle(radius) { | |
ctx.beginPath(); | |
ctx.arc(100, 75, radius, 0, 2*Math.PI); | |
ctx.stroke(); | |
} | |
// DO NOW STARTS HERE | |
function draw() { | |
if (shape === 'rectanle') { | |
rectangle(); | |
} else { | |
} | |
} | |
// these two should work | |
draw("rectangle", 10); | |
draw("circle", 25); | |
// these two should tell the user they did something wrong | |
draw("banana", 5); | |
draw("circle"); |
This file contains 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 { | |
height: 400px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment