MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / Line

Method Line

src/Display/Lcd/Lcd.cpp:365–392  ·  view source on GitHub ↗

Draw a line using the Bresenham Algorithm (thanks Wikipedia)

Source from the content-addressed store, hash-verified

363
364// Draw a line using the Bresenham Algorithm (thanks Wikipedia)
365void 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)
395void Lcd::Circle(PixelNumber x0, PixelNumber y0, PixelNumber radius, bool mode) noexcept

Callers 2

DisplayMessageBoxMethod · 0.80
ReloadMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected