Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<!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