【发布时间】:2011-09-04 17:25:22
【问题描述】:
如何覆盖 HTML5 画布弧?我认为这段代码可以工作,但它在它周围留下了一个边框,尽管它的值完全相同,只是颜色不同.. 有没有我缺少的边框属性??
<!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>
【问题讨论】:
-
只是出于好奇,这比使用 ctx.clear() 快吗?
-
不是真的,我最终重组了使用标准更新/绘制周期渲染的格式。作为抽奖的一部分,我使用了 ctx.clear() 并且工作得更快。
标签: javascript html canvas html5-animation