... | ... |
@@ -363,6 +363,9 @@ class Element(CompoundShape): |
363 | 363 |
def __init__(self, shapes): |
364 | 364 |
CompoundShape.__init__(self, shapes) |
365 | 365 |
|
366 |
+ def is_inside(self, x, y): |
|
367 |
+ return False |
|
368 |
+ |
|
366 | 369 |
def get_url(self, x, y): |
367 | 370 |
return None |
368 | 371 |
|
... | ... |
@@ -421,10 +424,23 @@ class Edge(Element): |
421 | 424 |
|
422 | 425 |
RADIUS = 10 |
423 | 426 |
|
427 |
+ def is_inside_begin(self, x, y): |
|
428 |
+ return square_distance(x, y, *self.points[0]) <= self.RADIUS*self.RADIUS |
|
429 |
+ |
|
430 |
+ def is_inside_end(self, x, y): |
|
431 |
+ return square_distance(x, y, *self.points[-1]) <= self.RADIUS*self.RADIUS |
|
432 |
+ |
|
433 |
+ def is_inside(self, x, y): |
|
434 |
+ if self.is_inside_begin(x, y): |
|
435 |
+ return True |
|
436 |
+ if self.is_inside_end(x, y): |
|
437 |
+ return True |
|
438 |
+ return False |
|
439 |
+ |
|
424 | 440 |
def get_jump(self, x, y): |
425 |
- if square_distance(x, y, *self.points[0]) <= self.RADIUS*self.RADIUS: |
|
441 |
+ if self.is_inside_begin(x, y): |
|
426 | 442 |
return Jump(self, self.dst.x, self.dst.y, highlight=set([self, self.dst])) |
427 |
- if square_distance(x, y, *self.points[-1]) <= self.RADIUS*self.RADIUS: |
|
443 |
+ if self.is_inside_end(x, y): |
|
428 | 444 |
return Jump(self, self.src.x, self.src.y, highlight=set([self, self.src])) |
429 | 445 |
return None |
430 | 446 |
|