简体   繁体   English

如何使HTML5画布的弧形像素化程度降低,或更抗锯齿?

[英]How can I make my HTML5 canvas arc less pixellated, or more anti-aliased?

The following arc is drawn in HTML5 canvas. 在HTML5画布中绘制了以下弧线。 How can I make the outside of the arc smoother and less pixelated, or more anti-aliased? 如何使圆弧的外部更平滑,像素更少或更抗锯齿?

在html5画布中绘制的弧线

This is the code used to create the arc above 这是用于在上方创建圆弧的代码

  var canvas = document.getElementById('myCanvas');
  var context = canvas.getContext('2d');
  var img = new Image();var x = canvas.width / 2;
  var y = canvas.height / 2;
  var radius = 100;
  var startAngle =   Math.PI;
  var endAngle =2* Math.PI;
  var counterClockwise = false;
  var outX= x
  var outY= y  
  var vari1 =.1;
  var endAngle = startAngle+ vari1* Math.PI;
  context.beginPath();
  context.arc(outX , outY, radius, startAngle, endAngle, counterClockwise);
  context.lineWidth = 25; 
  context.strokeStyle = '#FA603D';  
  context.stroke();
  context.closePath();

I don't think you can short of using a retina display (not trying to be sarcastic). 我认为您不能不使用视网膜显示器(不要试图讽刺)。

You can give the illusion of more smoothness by having less contrast between the arc and the background. 通过在圆弧和背景之间具有较小的对比度,可以提供更平滑的效果。

If you were drawing lines rather than arcs, you could turn off anti-aliasing in Chrome to make the lines sharper. 如果要绘制线条而不是圆弧,则可以在Chrome中关闭抗锯齿功能以使线条更清晰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM