编辑:此版本在版本38中修复。Chrome arc路径填充错误的解决方法?
最近的Chrome版本在我维护的应用程序中引入了一个问题。我不确定这是否是那些奇怪的“看起来错误但实际上是正确的”问题之一,或者它是一个诚实的上帝错误,但它只在最近版本的Chrome中出现(它开始发生在大约一个月前,我不确定究竟是哪个版本引入的)
在使用上下文arc()方法绘制的某些路径上使用上下文fill()方法时,会出现该错误。填充的是一个奇怪形状的多边形,而不是绘制一个实心圆弧。
这里是我的意思示范 - 右上角应该是一个充满圆弧形状:
var ctx = document.getElementById('cvs').getContext('2d');
// draw stroked arc
ctx.beginPath();
ctx.arc(75, 75, 50, 0, Math.PI/2);
ctx.lineTo(125, 125);
ctx.closePath();
ctx.stroke();
// draw filled arc
ctx.beginPath();
ctx.arc(225, 75, 50, 0, Math.PI/2);
ctx.lineTo(275, 125);
ctx.closePath();
ctx.fill();
\t \t \t
// draw stroked triangle
ctx.beginPath();
ctx.moveTo(125, 225);
ctx.lineTo(75, 275);
ctx.lineTo(125, 275);
ctx.closePath();
ctx.stroke();
// draw filled triangle
ctx.beginPath();
ctx.moveTo(275, 225);
ctx.lineTo(225, 275);
ctx.lineTo(275, 275);
ctx.closePath();
ctx.fill();
<div><canvas id="cvs" width="300" height="300" style="border: solid black 1px"></canvas></div>
我的问题是:是否有针对此问题的解决方法吗?最好不要我写我自己的填充弧渲染器。
什么版本的Chrome浏览器您使用的是?在这里没有看到任何问题 - 这是我得到http://oi61.tinypic.com/23wvt2.jpg – Cheery 2014-09-29 00:14:43
同样在这里FF31 Cheery(没有边界虽然)。 – mechalynx 2014-09-29 00:30:32
我已经看到在Windows的Chrome 37.0.2062.124以及适用于Android的Chrome 37.0.2062.117中出现该错误。 – slaufer 2014-09-29 00:56:14