There is such a function

void circle(HDC hdc, int x, int y) { //int x=0; //int y=R; int d=1-R; int delta1=3; int delta2=-2*R+5; while(y>=0) { if(d<0) { d+=delta1; delta1+=2; delta2+=2; x++; } else { d+=delta2; delta2+=4; delta1+=2; x++; y--; } SetPixel(hdc, x, y, 0); } } 

She has to draw 1/8 of a circle, but in addition to this, an extra line is drawn. So how to get rid of it?

  • Indeed, it turns out there is a Brezenham algorithm for the circle :). By the way, they are talking about three options (right / diagonal / down), you have only two. Is R large enough? More than 5? - Michael M
  • @ Mikhail M R more than 5 and I want to deal with this option at the beginning. - inham130
  • @ inham130, how are you doing? You traced, what coordinates of points are obtained at the output / experimented with the parameters? In theory, it should be clear what the algorithm turned out to be - it either draws a circle or a line - Mikhail M
  • @ Michael M everything turned out! The problem was in my carelessness - inham130

1 answer 1

Wipe off? :-) Or read on Wikipedia for example. For some reason it seems to me that SetPixel should be called at the beginning and not at the end.