帆布弧清理 [英] Canvas arc clearing
本文介绍了帆布弧清理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何覆写HTML5画布圆弧?我推测这个代码可以工作,但它留下一个边框,尽管事实上,它完全相同的值,只是一个不同的颜色..有一个边界属性我错过了
How do I overwrite an HTML5 canvas arc? I presumed this code would work but it leaves a border around it despite the fact that its exactly the same values and just a different colour.. Is there a border property I'm missing??
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<canvas id="surface" width="300" height="300"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('surface');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'black';
ctx.beginPath();
ctx.arc(100, 100, 20, 0, Math.PI * 2, true);
ctx.fill();
ctx.fillStyle = 'white';
ctx.beginPath();
ctx.arc(100, 100, 20, 0, Math.PI * 2, true);
ctx.fill();
</script>
</body>
</html>
推荐答案
这个黑边是反锯齿。
最简单的解决方法是稍微增加圆弧的半径。
The easiest solution is to increase the radius of the arc slightly.
这篇关于帆布弧清理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文