Skip to content

Instantly share code, notes, and snippets.

@startselect
Created September 17, 2015 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save startselect/7a026db3c7a6eb04f28e to your computer and use it in GitHub Desktop.
Save startselect/7a026db3c7a6eb04f28e to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>JS_PacMan</title>
</head>
<style type="text/css">
#pacman {
background-color: #fff;
}
</style>
<body>
<canvas id="pacman" width="300" height="250">
canvasがサポートされていません。
</canvas>
<script type="text/javascript">
var cv= document.getElementById("pacman");
var ctx = cv.getContext("2d");
ctx.strokeStyle = "#FF0000";
ctx.fillStyle = "#FF0000";
ctx.beginPath();
ctx.arc(100,100,50,0, 2 * Math.PI);
ctx.fill();
ctx.strokeStyle = "#FFFFFF";
ctx.fillStyle = "#FFFFFF";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc (100, 100, 50, -30 * Math.PI/180, 30 * Math.PI/180);
ctx.moveTo (100, 100);
ctx.lineTo (100 + 50 * Math.cos (-30 * Math.PI/180), 100 + 50 * Math.sin (-30 * Math.PI/180));
ctx.lineTo (100 + 50 * Math.cos (30 * Math.PI/180), 100 + 50 * Math.sin (30 * Math.PI/180));
ctx.stroke();
ctx.fill();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment