> Hi! Can someone please give me some advice on the following program? I'm
> trying to draw some antialiased lines, and if you'll run the program,
> you'll see that they all work, EXCEPT for the one that runs from the upper
> left to the lower right. Can anyone shed any light on what I'm doing
> wrong?
I don't think your algorithm (draw two pixels vertically or
horizontally `around' the `real' one) can cope with the general case;
it just happens to work with certain types of lines and not others.
I'm not sure this is particularly trivial to fix. :-( However, I do
have a more severely wrong case if that helps...
wu_line(0,0,110,100,255,255,255);
That one looks very nasty, and I think shows up the problem nicely.
But to be honest, I think the advice you're after is "look in a
computer graphics book". :-) From a brief look in one I have handy
("Computer Graphics" by F. S. Hill Jr., not the best, but it's not too
bad), the Pitteway-Watkinson algorithm looks promising [1], so try
looking that one up.
-Rus.
[1] One key quote being "In the spirit of Bresenham's algorithm, the
computations are both incremental and based on integer arithmetic,
which makes them very efficient."