我正在使用 HTML 画布编写绘图应用程序。为了平滑绘制的线条,我在每个mousemove
事件之后填充了一系列二次曲线:
ctx.beginPath()
ctx.moveTo(mx1-halfLastWidth*sin(angle), my1-halfLastWidth*cos(angle))
ctx.quadraticCurveTo(mx1-lastWidth*cos(angle), my1+lastWidth*sin(angle),
mx1+halfLastWidth*sin(angle), my1+halfLastWidth*cos(angle))
ctx.quadraticCurveTo(xl+halfMidWidth*sin(angle), yl+halfMidWidth*cos(angle),
mx2+halfCurrentWidth*sin(angle), my2+halfCurrentWidth*cos(angle))
ctx.quadraticCurveTo(mx2+currentWidth*cos(angle), my2-currentWidth*sin(angle),
mx2-halfCurrentWidth*sin(angle), my2-halfCurrentWidth*cos(angle))
ctx.quadraticCurveTo(xl-halfMidWidth*sin(angle), yl-halfMidWidth*cos(angle),
mx1-halfLastWidth*sin(angle), my1-halfLastWidth*cos(angle))
ctx.fill()
完整演示: http: //jsfiddle.net/PfzM2/2/(有很多不相关的代码,因为这是从一个更大的项目中提取的)
这些线条在 Firefox 中渲染得非常流畅,但在 Chrome 中看起来有些“锯齿状”:
向浏览器发出的一系列命令和参数是相同的。
如何让 Chrome 像 Firefox 一样渲染线条?