A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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**_

authored by

jpirnay and committed by
GitHub
e70066e7 00e25b1a

+22 -2
+22 -2
lib/GfxRenderer/GfxRenderer.cpp
··· 147 147 drawPixel(x, y1, state); 148 148 } 149 149 } else { 150 - // TODO: Implement 151 - LOG_ERR("GFX", "Line drawing not supported"); 150 + // Bresenham's line algorithm — integer arithmetic only 151 + int dx = x2 - x1; 152 + int dy = y2 - y1; 153 + int sx = (dx > 0) ? 1 : -1; 154 + int sy = (dy > 0) ? 1 : -1; 155 + dx = sx * dx; // abs 156 + dy = sy * dy; // abs 157 + 158 + int err = dx - dy; 159 + while (true) { 160 + drawPixel(x1, y1, state); 161 + if (x1 == x2 && y1 == y2) break; 162 + int e2 = 2 * err; 163 + if (e2 > -dy) { 164 + err -= dy; 165 + x1 += sx; 166 + } 167 + if (e2 < dx) { 168 + err += dx; 169 + y1 += sy; 170 + } 171 + } 152 172 } 153 173 } 154 174