Skip to content

Instantly share code, notes, and snippets.

@domenicrosati
Last active September 23, 2018 23:20
Show Gist options
  • Save domenicrosati/0ac7b3ec565b371dcb2f2a0f66192ca4 to your computer and use it in GitHub Desktop.
Save domenicrosati/0ac7b3ec565b371dcb2f2a0f66192ca4 to your computer and use it in GitHub Desktop.
getting started with animation
// jsfiddle.net
// functions
function drawBlueRectangle() {
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 50, 50);
}
// another function
function drawBlueCircle() {
ctx.strokeStyle = "blue";
ctx.beginPath();
ctx.arc(95, 50, 40, 0, 2*Math.PI);
ctx.stroke();
}
// functions with parameters
// functions
function drawRedRectangle(x, y) {
ctx.fillStyle = "red";
ctx.fillRect(x, y, 50, 50);
}
// problems
// make the shape go down
// make the shape go the left
// how do we prevent the shape from going past the boundary?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment