insarviz.bresenham module
Bresenham algorithm for line drawing.
- insarviz.bresenham.line(x0, y0, x1, y1)[source]
returns list of indices of pixels for the line from (x0, y0) to (x1, y1)
both ends are included.
- x0int
row of first point
- y0int
col of first point
- x1int
row of second point
- y1int
col of second point
>>> 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