insarviz.misc.bresenham module

Bresenham algorithm for line drawing.

insarviz.misc.bresenham.line(x0: int, y0: int, x1: int, y1: int) list[tuple[int, int]][source]

returns list of indices of pixels for the line from (x0, y0) to (x1, y1)

both ends are included.

Parameters:
  • x0 (int) – row of first point

  • y0 (int) – col of first point

  • x1 (int) – row of second point

  • y1 (int) – col of second point

Examples

>>> from insarviz.bresenham import line
>>> import numpy as np
>>> X0, Y0, X1, Y1 = 0, 0, 4, 3
>>> res = line(X0, Y0, X1, Y1)
>>> print(res, type(res)==list, type(res[0])==tuple)
[(0, 0), (1, 1), (2, 2), (3, 2), (4, 3)] True True