+-+-+-+-+-+-+-+-+-+ | | | | | | |*|*|*| +-+-+-+-+-+-+-+-+-+ | | | |*|*|*| | | | +-+-+-+-+-+-+-+-+-+ |*|*|*| | | | | | | +-+-+-+-+-+-+-+-+-+
Now, if all your pixels are either black or white, this isn't too bad. But the human eye is very good in seeing the non-smoothness, the "staircase" sticks out like a sore thumb.
But if you have a grayscale (or full colour) device available, there are much better techniques. One technique revolves around the observation a line needs thickness to be seen. So, if you want to draw a line from say (0, 0) to (8, 2), assume you have a rectangle of width 1 and length 2 * sqrt (17), running from (0, 0) to (8, 2). This will cover some of the pixels partially. If a pixel is covered for say, 61%, the pixel should get a gray value that's 61% of pure black.
Now, this still isn't perfect, but it's a step better. There are lots of line drawing algorithms, each of them finding a different balance between simplicity, speed, good results and avoidance of artifacts.
Abigail
In reply to Re: Plotting A Line
by Abigail-II
in thread Plotting A Line
by mdog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |