Skip to content

Instantly share code, notes, and snippets.

@stmtk1
Created May 4, 2016 12:12
Show Gist options
  • Save stmtk1/ef12a281315ea727033006ce64a609cc to your computer and use it in GitHub Desktop.
Save stmtk1/ef12a281315ea727033006ce64a609cc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<body>
<canvas id="draw"></canvas>
<script>
var canvas = document.getElementById("draw");
var ctx = canvas.getContext("2d");
canvas.width = 300;
canvas.height = 300;
canvas.style.backgroundColor = '#000';
ctx.fillStyle = "#f00";
ctx.beginPath();
ctx.arc(250, 50, 50, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = "#bb2";
ctx.fillRect(0 , 0, 100, 100);
ctx.fillStyle = '#000';
ctx.beginPath();
ctx.arc(150, 150, 50 * Math.sqrt(10), Math.PI + Math.atan2(1, 3), Math.PI + Math.atan2(3, 1));
ctx.fill();
ctx.beginPath();
ctx.moveTo(100, 0);
ctx.lineTo(0, 100);
ctx.lineTo(100, 100);
ctx.fill();
ctx.fillStyle = "#888";
ctx.fillRect(200 , 200, 100, 100);
ctx.fillStyle = '#000';
ctx.beginPath();
ctx.arc(150, 150, 50 * Math.sqrt(10), Math.atan2(1, 3), Math.atan2(3, 1));
ctx.fill();
ctx.beginPath();
ctx.moveTo(200, 300);
ctx.lineTo(300, 200);
ctx.lineTo(200, 200);
ctx.fill();
ctx.fillStyle = "#fff";
ctx.fillRect(100, 0, 100, 300);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment