Firefox和Chrome上的HTML画布填充区别

编程入门 行业动态 更新时间:2024-10-27 10:30:02
本文介绍了Firefox和Chrome上的HTML画布填充区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请考虑下面的代码片段 - 可用于jsFiddle: jsfiddle/Xqu5U/2/

Consider the snippet below - available on jsFiddle: jsfiddle/Xqu5U/2/

ctx = document.getElementById('canvas').getContext('2d'); ctx.beginPath(); ctx.fillStyle = '#FF0000'; for (var i = 0; i < 20; i++) { ctx.arc(i * 10, 50 + Math.sin(i * 0.5) * 15, 2, 0, Math.PI * 2); } ctx.fill();

Google Chrome浏览器能够正常工作,但是Firefox会从最后一个弧段填充到第一个弧段。 如何更新上面的代码片段让Firefox像Chrome一样绘制弧线?

It works as expected on Google Chrome, but Firefox renders a fill from the last arc to the first one. How can the snippet above be updated to get Firefox drawing the arcs exactly like Chrome?

推荐答案

我知道这是('''');但是对于将来的参考:

I know this is old question but for the future reference:

ctx = document.getElementById('canvas').getContext('2d'); ctx.beginPath() ctx.fillStyle = '#FF0000' for (var i = 0; i < 20; i++) { ctx.arc(i * 10, 50 + Math.sin(i * 0.5) * 15, 2, 0, Math.PI * 2) ctx.closePath() } ctx.fill()

更多推荐

Firefox和Chrome上的HTML画布填充区别

本文发布于:2023-10-08 02:23:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471239.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:画布   区别   Firefox   Chrome   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!