Algorithm for drawing an anti-aliased circle?

2020-06-09 07:01发布

What's a good algorithm for drawing anti-aliased circles? (Filled and not filled.)

3条回答
做个烂人
2楼-- · 2020-06-09 07:55

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楼-- · 2020-06-09 07:59

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

查看更多
一纸荒年 Trace。
4楼-- · 2020-06-09 07:59

Create a Graphics object g. Do

g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

Draw your anti aliased circle with g.FillEllipse or g.DrawEllipse

查看更多
登录 后发表回答