Update
This commit is contained in:
parent
5414a07fa2
commit
c25381cf0e
9 changed files with 38 additions and 21 deletions
10
line.md
10
line.md
|
@ -85,7 +85,7 @@ There are many [algorithms](algorithm.md) for line [rasterization](rasterization
|
|||
XX XX a.
|
||||
|
||||
pixel subpixel subpixel accuracy
|
||||
accuracy accuracy + anti-aliasing
|
||||
accuracy accuracy + antialiasing
|
||||
```
|
||||
|
||||
One of the most basic line rasterization algorithms is the [DDA](dda.md) (Digital differential analyzer), however it is usually better to use at least the [Bresenham's line algorithm](bresenham.md) which is still simple and considerably improves on DDA by not requiring multiplication or division (slow operations) and by only using integers (no [floating point](float.md)).
|
||||
|
@ -128,8 +128,8 @@ void drawLine(int ax, int ay, int bx, int by)
|
|||
{
|
||||
drawPixel(ax,ay);
|
||||
|
||||
steps--;
|
||||
*x += stepX;
|
||||
|
||||
bx += dy;
|
||||
|
||||
if (bx >= dx)
|
||||
|
@ -137,8 +137,8 @@ void drawLine(int ax, int ay, int bx, int by)
|
|||
bx -= dx;
|
||||
*y += stepY;
|
||||
}
|
||||
|
||||
steps--;
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
To add [antialiasing](antialiasing.md) here you wouldn't just draw one pixel at each step but two, right next to each other, between which you'd distribute the intensity in the ratio given by current error.
|
Loading…
Add table
Add a link
Reference in a new issue