HTML5 Canvas笔划没有消除锯齿

nip*_*ese 5 antialiasing stroke html5-canvas

我只想在画布上用一个厚的抗锯齿笔画制作一个圆圈.

圆圈按预期绘制,但笔划的边缘非常锯齿.我一直在阅读Chrome强制抗锯齿,所以不知道该怎么做......

小提琴:http://jsfiddle.net/nipponese/hWsxw/

HTML

<div id="main">
    <canvas id="myCanvas" width="400" height="400" style="border: 1px solid #000"></canvas>
        <div id="counter" style="height: 100px; width: 100px; border: 1px solid #000">
     </div>
</div>
Run Code Online (Sandbox Code Playgroud)

JS + jQuery

<script>
    function calc(myVal) {
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        var radius = 70;

        ctx.beginPath();
        ctx.arc(140, 140, 20, myVal * Math.PI, 0, true);
        ctx.lineWidth = 14;
        ctx.stroke();
    };
    $(document).ready(function() {
        var count = 0;
        var parsedCount;
        function go(){  
            if (count <= 200) {
                parsedCount = count*.01
                $('#counter').html('<p>' + parsedCount + '</p>');
                calc(parsedCount);
                count++;
            }
        }
        setInterval(go, 10)
    });
</script>
Run Code Online (Sandbox Code Playgroud)

nip*_*ese 16

我的同事刚刚指出我需要在每次抽奖后使用clearRect清除画布.笔画只是在彼此之上绘制.

function calc(myVal) {
    var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    var radius = 70;
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    ctx.beginPath();
    ctx.arc(140, 140, 20, myVal * Math.PI, 0, true);
    ctx.lineWidth = 14;
    ctx.stroke();
};
Run Code Online (Sandbox Code Playgroud)