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

Method snap

imagepy/tools/Transform/scale_tol.py:12–25  ·  view source on GitHub ↗
(self, x, y, lim)

Source from the content-addressed store, hash-verified

10 self.moving = False
11
12 def snap(self, x, y, lim):
13 plg = self.plg
14 if abs(x-plg.lt)<lim and abs(y-(plg.tp+plg.bm)/2)<lim:return 'l'
15 if abs(x-plg.rt)<lim and abs(y-(plg.tp+plg.bm)/2)<lim:return 'r'
16 if abs(x-(plg.lt+plg.rt)/2)<lim and abs(y-plg.tp)<lim:return 't'
17 if abs(x-(plg.lt+plg.rt)/2)<lim and abs(y-plg.bm)<lim:return 'b'
18 if abs(x-plg.lt)<lim and abs(y-plg.tp)<lim:return 'lt'
19 if abs(x-plg.rt)<lim and abs(y-plg.bm)<lim:return 'rb'
20 if abs(x-plg.rt)<lim and abs(y-plg.tp)<lim:return 'rt'
21 if abs(x-plg.lt)<lim and abs(y-plg.bm)<lim:return 'lb'
22 if (x-plg.lt)*(x-plg.rt)<0 and (y-plg.tp)*(y-plg.bm)<0:
23 self.ox, self.oy = x, y
24 return True
25 return False
26
27 def mouse_down(self, ips, x, y, btn, **key):
28 lim = 5.0/key['canvas'].get_scale()

Callers 2

mouse_downMethod · 0.95
mouse_moveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected