Created
August 7, 2013 09:36
-
-
Save GZShi/6172619 to your computer and use it in GitHub Desktop.
Chrome context.arc bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bug在哪?