What's a good algorithm for drawing anti-aliased circles? (Filled and not filled.)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Bresenham (of the line algorithm fame) also had a circle algorithm.
Xiaolin Wu adapted the line algorithm for anti-aliasing, and likewise did the same to the circle algorithm.
http://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
You can find the circle algorithm with this search:
http://www.google.com/search?q=Xiaolin%20Wu%20circle
-Adam
回答2:
If you want an easy one, make a soft blur from pixel matrix A to pixel matrix B.
This is one i've used (here in pseudo-code)
anti_alised_matrix[x][y] = point[x][y] / 2 + point[x+1][y]/8 + point[x-1][y]/8 + point[x][y-1]/8 + point[x][y+1]/8;
Ofcourse this is applied to grayscale, but you can do easily the same in RGB.
This is really a very simple one, you can also add the diagonals i.e. [x+1][y+1] and split it by 16 or 32.
回答3:
Create a Graphics object g. Do
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Draw your anti aliased circle with g.FillEllipse or g.DrawEllipse