Circle filling algorithm?

Started by
9 comments, last by FxMazter 21 years, 3 months ago
While we''re all posting circle-render code, I just have to chime in with my own algorithm

for(int h = radius; h >= -radius; --h){   int w = 2 * sqrt( radius*radius - h*h );   int local_x = X - (w / 2);   int local_y = Y - h;   Rectangle(local_x, local_y, w, 1, color_r, color_g, color_b, color_a);} 

Rectangle is such a trivial function to code, I''m sure you can handle that If you want an unfilled circle, then simply draw a pixel at the start and end points.

This topic is closed to new replies.

Advertisement