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

Method draw_point

imagepy/core/draw/paint.py:32–42  ·  view source on GitHub ↗
(self, img, x, y, r=1, color=None)

Source from the content-addressed store, hash-verified

30 img[ys[msk], xs[msk]] = color
31
32 def draw_point(self, img, x, y, r=1, color=None):
33 shape = img.shape
34 x, y = np.round((x,y)).astype(np.int)
35 if x<0 or y<0 or x>=shape[1] or y>=shape[0]: return
36 if color == None:color = ColorManager.get_front()
37 color = match_color(img, color)
38 if r==1: img[y,x] = color
39 n = int(r)
40 xs,ys = np.mgrid[-n:n+1,-n:n+1]
41 msk = np.sqrt(xs**2+ys**2)<r
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)]

Callers 2

sketchMethod · 0.95
draw_lineMethod · 0.95

Calls 3

draw_pixsMethod · 0.95
match_colorFunction · 0.85
get_frontMethod · 0.80

Tested by

no test coverage detected