Пример #1
0
def _rect_center(self, point_or_x=None, y=0):
    x = point_or_x
    if x is None:
        return Point(self.x + self.w * 0.5, self.y + self.h * 0.5)
    if isinstance(point_or_x, Point):
        x = point_or_x.x
        y = point_or_x.y
    self.x = x - self.w * 0.5
    self.y = y - self.h * 0.5
Пример #2
0
def _rect_contains(self, item):
    try:
        if len(item) == 2:
            x, y = item
            item = Point(x, y)
        elif len(item) == 4:
            x, y, w, h = item
            item = Rect(x, y, w, h)
    except:
        pass

    if not isinstance(item, Rect) and not isinstance(item, Point):
        return False
    if isinstance(item, Rect):
        return (item.left() >= self.left() and item.right() <= self.right()
                and item.bottom() >= self.bottom()
                and item.top() <= self.top())
    return (item.x >= self.left() and item.x <= self.right()
            and item.y >= self.bottom() and item.y <= self.top())
Пример #3
0
def _rect_contains(self, item):
	try:
		if len(item) == 2:
			x, y = item
			item = Point(x, y)
		elif len(item) == 4:
			x, y, w, h = item
			item = Rect(x, y, w, h)
	except:
		pass
		
	if not isinstance(item, Rect) and not isinstance(item, Point):
		return False
	if isinstance(item, Rect):
		return (item.left() >= self.left() and
				item.right() <= self.right() and
				item.bottom() >= self.bottom() and
				item.top() <= self.top())
	return (item.x >= self.left() and item.x <= self.right() and
			item.y >= self.bottom() and item.y <= self.top())
Пример #4
0
def _rect_origin(self):
    return Point(self.x, self.y)
Пример #5
0
 def __init__(self, x, y, prev_x, prev_y, touch_id):
     self.touch_id = touch_id
     self.location = Point(x, y)
     self.prev_location = Point(prev_x, prev_y)
     self.layer = None