Draw a line using the Bresenham Algorithm (thanks Wikipedia)
| 363 | |
| 364 | // Draw a line using the Bresenham Algorithm (thanks Wikipedia) |
| 365 | void Lcd::Line(PixelNumber y0, PixelNumber x0, PixelNumber y1, PixelNumber x1, bool mode) noexcept |
| 366 | { |
| 367 | int dx = (x1 >= x0) ? x1 - x0 : x0 - x1; |
| 368 | int dy = (y1 >= y0) ? y1 - y0 : y0 - y1; |
| 369 | int sx = (x0 < x1) ? 1 : -1; |
| 370 | int sy = (y0 < y1) ? 1 : -1; |
| 371 | int err = dx - dy; |
| 372 | |
| 373 | for (;;) |
| 374 | { |
| 375 | SetPixel(y0, x0, mode); |
| 376 | if (x0 == x1 && y0 == y1) |
| 377 | { |
| 378 | break; |
| 379 | } |
| 380 | int e2 = err + err; |
| 381 | if (e2 > -dy) |
| 382 | { |
| 383 | err -= dy; |
| 384 | x0 += sx; |
| 385 | } |
| 386 | if (e2 < dx) |
| 387 | { |
| 388 | err += dx; |
| 389 | y0 += sy; |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | // Draw a circle using the Bresenham Algorithm (thanks Wikipedia) |
| 395 | void Lcd::Circle(PixelNumber x0, PixelNumber y0, PixelNumber radius, bool mode) noexcept |
no outgoing calls
no test coverage detected