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