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:
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