|
DDA line drawing algorithm
.raw
void DrawLine_DDA(int x0, int y0, int x1, int y1, u32 color)
{
int dx = x1 - x0;
int dy = y1 - y0;
int length = max(abs(dx), abs(dy));
if (length > 0) {
f32 sx = dx / length;
f32 sy = dy / length;
f32 px = x0 + 0.5;
f32 py = y0 + 0.5;
for (int i = 0; i < length; ++i) {
DrawPoint(floor(px), floor(py), color);
px += sx;
py += sy;
}
}
}
|