SpinalHDL
1 / 1
Description
Line Rasterization
Implement Bresenham line rasterization for the segment from p0 to p1.
Output the visited pixel centers in order from p0 to p1, including both endpoints. At each step, move one pixel toward p1 along the major axis, and move along the minor axis only when the exact line has strictly crossed the midpoint between the two candidate pixel centers.
Example: (0, 0) to (5, 2) outputs (0, 0), (1, 0), (2, 1), (3, 1), (4, 2), (5, 2).
Source: Original problem (inspired by Bresenham's line algorithm)
Input
p0
8-bit Signed Integer PairLine start point (x0, y0).
p1
8-bit Signed Integer PairLine end point (x1, y1).
Output
Stream of 8-bit Signed Integer Pair
Pixel coordinates forming the line.