58 (other.x - self.x) ** 2 + |
58 (other.x - self.x) ** 2 + |
59 (other.y - self.y) ** 2 |
59 (other.y - self.y) ** 2 |
60 ) |
60 ) |
61 |
61 |
62 |
62 |
63 class Rect(object): |
63 class Rect: |
64 """Simple rectangle object.""" |
64 """Simple rectangle object.""" |
65 def __init__(self, width, height, data={}): |
65 def __init__(self, width, height, data={}): |
66 self.width = width |
66 self.width = width |
67 self.height = height |
67 self.height = height |
68 self.data = data |
68 self.data = data |
108 def area(self): |
108 def area(self): |
109 """Area: length * width.""" |
109 """Area: length * width.""" |
110 return self.width * self.height |
110 return self.width * self.height |
111 |
111 |
112 |
112 |
113 class PointList(object): |
113 class PointList: |
114 """Methods for transforming a list of points.""" |
114 """Methods for transforming a list of points.""" |
115 def __init__(self, points=[]): |
115 def __init__(self, points=[]): |
116 self.points = points |
116 self.points = points |
117 self._polygon = None |
117 self._polygon = None |
118 |
118 |
175 """Helper method too automatically return distance.""" |
175 """Helper method too automatically return distance.""" |
176 closest_point = self.closest_point_to_point(point) |
176 closest_point = self.closest_point_to_point(point) |
177 return closest_point.distance(point) |
177 return closest_point.distance(point) |
178 |
178 |
179 |
179 |
180 class Packer(object): |
180 class Packer: |
181 def __init__(self): |
181 def __init__(self): |
182 self._rects = [] |
182 self._rects = [] |
183 |
183 |
184 def add_rect(self, width, height, data={}): |
184 def add_rect(self, width, height, data={}): |
185 self._rects.append(Rect(width, height, data)) |
185 self._rects.append(Rect(width, height, data)) |