Algorithm for drawing an anti-aliased circle?

こ雲淡風輕ζ 提交于 2019-12-09 08:25:32

问题


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



来源:https://stackoverflow.com/questions/485800/algorithm-for-drawing-an-anti-aliased-circle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!