麻烦问下为啥只出现方框不出现圆?
<!doctype html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
<title>Canvas</title>
<style type="text/css">
div {
text-align: center;
margin-top: 250px;
}
#clock {
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div>
<canvas id="clock" height="280px" width="280px"></canvas>
</div>
<script type="text/javascript">
var dom = document.getElementsById('clock');
var ctx = dom.getContext('2d');
var width = ctx.canvas.width;
var height = ctx.canvas.height;
var r = width / 2;
function drawBackground() {
ctx.translate(r, r);
ctx.beginPath();
ctx.lineWidth = 10;
ctx.arc(0, 0, r - 5, 0, 2 * Math.PI, false);
ctx.stroke();
}
drawBackground();
</script>
</body>
</html>