在 HTML Canvas 上,某些重叠颜色会产生不需要的阴影
我正在画布上使用各种颜色,只是注意到某些重叠的颜色(例如蓝色上的红色)会产生阴影,如下图所示:
如果您注意到,上面有大约 0.5px 宽的阴影的右侧红色圆圈。
我有以下代码:
<canvas width="1000" height="1000"></canvas>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
// BG
ctx.fillStyle = '#1c4c72'; ctx.fillRect(0, 0, 1000, 1000);
// Circle red
ctx.beginPath(); ctx.arc(500, 500, 250, 0, 2 * Math.PI); ctx.fillStyle = '#9a1500'; ctx.fill();
// Circle white
ctx.beginPath(); ctx.arc(500, 500, 150, 0, 2 * Math.PI); ctx.fillStyle = '#ffffff'; ctx.fill();
是否有补救措施,或者这是需要学习忍受的东西?感谢您的任何想法。
在 Windows 上的 Firefox 和 Chrome 最新版本上进行了测试。
I am playing with various colors on canvas and just noticed that certain overlapping colors (e.g. red on blue) create shadows, as shown in the image below:
If you notice, there's about 0.5px wide shadow on the right side of the red circle.
I have the following code:
<canvas width="1000" height="1000"></canvas>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
// BG
ctx.fillStyle = '#1c4c72'; ctx.fillRect(0, 0, 1000, 1000);
// Circle red
ctx.beginPath(); ctx.arc(500, 500, 250, 0, 2 * Math.PI); ctx.fillStyle = '#9a1500'; ctx.fill();
// Circle white
ctx.beginPath(); ctx.arc(500, 500, 150, 0, 2 * Math.PI); ctx.fillStyle = '#ffffff'; ctx.fill();
Is there a remedy for this or is this something to learn to live with? Thanks for any ideas.
Tested on Firefox and Chrome on Windows, latest versions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论