MCPcopy Create free account
hub / github.com/Image-Py/imagepy / draw_line

Method draw_line

imagepy/core/draw/paint.py:44–52  ·  view source on GitHub ↗
(self, img, x1, y1, x2, y2, w=None, color=None)

Source from the content-addressed store, hash-verified

42 self.draw_pixs(img, xs[msk]+x, ys[msk]+y, color)
43
44 def draw_line(self, img, x1, y1, x2, y2, w=None, color=None):
45 x1, y1, x2, y2 = [int(round(i)) for i in (x1, y1, x2, y2)]
46 if w==None:w=self.width
47 dx, dy = x2-x1, y2-y1
48 n = max(abs(dx), abs(dy)) + 1
49 xs = np.linspace(x1, x2, n).round().astype(np.int16)
50 ys = np.linspace(y1, y2, n).round().astype(np.int16)
51 for x,y in zip(xs, ys):
52 self.draw_point(img, x, y, w, color)
53
54 def lineto(self, img, x, y, w=None, color=None):
55 self.draw_line(img, self.curpt[0], self.curpt[1], x, y, w, color)

Callers 1

linetoMethod · 0.95

Calls 1

draw_pointMethod · 0.95

Tested by

no test coverage detected