Beispiel #1
0
 def bounds(self):
     """Default bounds method. This is guaranteed to work, and should be fast
     enough with small number of shapes. Subclasses with large numbers of
     shapes may see performance benefits from overriding this method.
     """
     if self._bounds is None:
         left_edge   = Min(shape.bounds.left_edge   for shape in self.shapes)
         right_edge  = Max(shape.bounds.right_edge  for shape in self.shapes)
         top_edge    = Min(shape.bounds.top_edge    for shape in self.shapes)
         bottom_edge = Max(shape.bounds.bottom_edge for shape in self.shapes)
         self._bounds = Bounds(left_edge, right_edge, top_edge, bottom_edge)
     return self._bounds
Beispiel #2
0
    def bounds(self):
        # FIXME: this class does not know how to compute its bounds!
        # Maybe some clever font nerd can figure those out, but not me.

        # Currently it just says the edges all intersect the anchor point, which
        # is not very helpful (but is necessary for using this shape in Groups).

        # Note that even without meaningful bounds you can still left-, center-,
        # or right-align text. You just have to do it via styling. See
        # examples/go_board.py for a sample of what this might look like.

        x = self.anchor_point.x
        y = self.anchor_point.y
        return Bounds(x, x, y, y)
Beispiel #3
0
 def bounds(self):
     ul_bounds = self.shapes[0].bounds
     br_bounds = self.shapes[-1].bounds
     return Bounds(ul_bounds.left_edge, br_bounds.right_edge,
                   ul_bounds.top_edge, br_bounds.bottom_edge)
Beispiel #4
0
 def bounds(self):
     left_edge, right_edge = self.x - self.radius, self.x + self.radius
     top_edge, bottom_edge = self.y - self.radius, self.y + self.radius
     return Bounds(left_edge, right_edge, top_edge, bottom_edge)
Beispiel #5
0
 def bounds(self):
     left_edge, right_edge = self.x, self.x + self.width
     top_edge, bottom_edge = self.y, self.y + self.height
     return Bounds(left_edge, right_edge, top_edge, bottom_edge)
Beispiel #6
0
 def bounds(self):
     x, y = self.x, self.y
     return Bounds(x, x, y, y)  # just a point!
Beispiel #7
0
 def bounds(self):
     xs = (self.pt1.x, self.pt2.x)
     ys = (self.pt1.y, self.pt2.y)
     left_edge, right_edge = Min(*xs), Max(*xs)
     top_edge, bottom_edge = Min(*ys), Max(*ys)
     return Bounds(left_edge, right_edge, top_edge, bottom_edge)