fix: add bresenham for arbitrary lines (#923)

## Summary

* GfxRender did handle horizontal and vertical lines but had a TODO for
arbitrary lines.
* Added integer based Bresenham line drawing 
  
## Additional Context

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
This commit is contained in:
jpirnay
2026-02-19 11:52:13 +01:00
committed by cottongin
parent c8ddb6b61d
commit e5d574a07a

View File

@@ -138,8 +138,28 @@ void GfxRenderer::drawLine(int x1, int y1, int x2, int y2, const bool state) con
drawPixel(x, y1, state); drawPixel(x, y1, state);
} }
} else { } else {
// TODO: Implement // Bresenham's line algorithm — integer arithmetic only
LOG_ERR("GFX", "Line drawing not supported"); int dx = x2 - x1;
int dy = y2 - y1;
int sx = (dx > 0) ? 1 : -1;
int sy = (dy > 0) ? 1 : -1;
dx = sx * dx; // abs
dy = sy * dy; // abs
int err = dx - dy;
while (true) {
drawPixel(x1, y1, state);
if (x1 == x2 && y1 == y2) break;
int e2 = 2 * err;
if (e2 > -dy) {
err -= dy;
x1 += sx;
}
if (e2 < dx) {
err += dx;
y1 += sy;
}
}
} }
} }