Created
July 8, 2017 00:30
-
-
Save sguzman/d5a05f5538651a440ecfb6d665c63fc9 to your computer and use it in GitHub Desktop.
2d HTML context example - draws a simple square with an arc on top
This file contains hidden or 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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Canvas 2d Example</title> | |
<style> | |
body { | |
margin: 0; | |
} | |
canvas { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id="canvas"> | |
</canvas> | |
<script> | |
const canvas = document.getElementById('canvas'); | |
const context = canvas.getContext('2d'); | |
context.fillStyle = 'blue'; | |
context.fillRect(10, 20, 200, 100); | |
context.lineWidth = 5; | |
context.lineCap = 'round'; | |
context.arc(50, 50, 20, 0, Math.PI, false); | |
context.stroke(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment