Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do some programs draw smooth lines? [closed]

As you know, when we use usual line drawing methods, we use such code (I'm not speaking about a specific programming language. I'm just speaking about what do we do.):

line(point1,point2)

Or something like that.

I'm sure that you have seen that when we draw a diagonal line with these usual methods, the line won't be smooth. For example, if you go to windows paint and set line width to minimum, then try to draw a diagonal line, you'll see breaks in the line. But, in some programs like Photoshop, Corel DRAW, when you draw a diagonal line, it is very smooth and you can't see the breaks. If you take a closer look at pixels, you'll see what causes that:

https://skydrive.live.com/embed?cid=6D7B572F0E7DEFED&resid=6D7B572F0E7DEFED%21115&authkey=AMgqS95hWkp-e5w

I know that the light-color pixels cause the smoothness.

Okay, can you tell me what algorithm do I need to do that?

Simply, plz.

like image 983
Mostafa Farzán Avatar asked Mar 06 '26 06:03

Mostafa Farzán


1 Answers

I think Xiaolin Wu's line algorithm is exactly what you need.

like image 182
Kendall Frey Avatar answered Mar 09 '26 20:03

Kendall Frey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!