Skip to content

Instantly share code, notes, and snippets.

@GZShi
Created August 7, 2013 09:36
Show Gist options
  • Save GZShi/6172619 to your computer and use it in GitHub Desktop.
Save GZShi/6172619 to your computer and use it in GitHub Desktop.
Chrome context.arc bug
<html>
<head>
<title>chrome arc bug</title>
</head>
<body>
<canvas id="c" width="3000" height="3000"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
function myarc(ctx, cx, cy, r) {
var delta = 0.5;
var alpha = 0;
ctx.moveTo(cx + r, cy);
for(; alpha < 360; alpha += delta) {
px = cx + r * Math.cos(alpha*Math.PI/180);
py = cy + r * Math.sin(alpha*Math.PI/180);
ctx.lineTo(px, py);
}
}
ctx.beginPath();
ctx.strokeStyle = 'black';
ctx.arc(1000, 1000, 1000, 0, 2*Math.PI, true);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = 'red';
myarc(ctx, 1000, 1000, 1000);
ctx.stroke();
</script>
</body>
</html>
@pyrocat101
Copy link

bug在哪?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment