Skip to content

Instantly share code, notes, and snippets.

@miguel12345
Created November 29, 2013 08:05
Show Gist options
  • Select an option

  • Save miguel12345/7702782 to your computer and use it in GitHub Desktop.

Select an option

Save miguel12345/7702782 to your computer and use it in GitHub Desktop.
Canvas basic example
<body> This is a red square: <canvas id="square" width=10 height=10></canvas>. This is a blue circle: <canvas id="circle" width=10 height=10></canvas>. <script> var canvas = document.getElementById("square"); var context = canvas.getContext("2d"); context.fillStyle = "#f00"; context.fillRect(0,0,10,10); canvas = document.getElementById("circle"); context = canvas.getContext("2d"); context.beginPath(); context.arc(5, 5, 5, 0, 2*Math.PI, true); context.fillStyle = "#00f"; context.fill(); </script> </body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment