def fit(self): bbox = defaults.BBox(None, None, None, None) for child in self.children: bbox += child.bbox() if self.xmin is not None: bbox.xmin = self.xmin if self.xmax is not None: bbox.xmax = self.xmax if self.ymin is not None: bbox.ymin = self.ymin if self.ymax is not None: bbox.ymax = self.ymax self.trans = trans.window(bbox.xmin, bbox.xmax, bbox.ymin, bbox.ymax, x=self.x, y=self.y, width=self.width, height=self.height, xlogbase=self.xlogbase, ylogbase=self.ylogbase, minusInfinityX=(self.x - 10. * self.width), minusInfinityY=(self.y - 10. * self.height), flipx=self.flipx, flipy=self.flipy)
def bbox(self): if self.tag is not None: tonumber_tag = getattr(defaults, "tonumber_%s" % self.tag, None) if tonumber_tag is not None: tonumber_tag(self) bbox_tag = getattr(defaults, "bbox_%s" % self.tag, None) if bbox_tag is not None: output = bbox_tag(self) else: output = defaults.BBox(None, None, None, None) for child in self.children: if isinstance(child, SVG): output += child.bbox() return output
def bbox(self): return defaults.BBox(self.x, self.x + self.width, self.y, self.y + self.height)
def bbox(pathdata): x, y = None, None output = defaults.BBox(None, None, None, None) for datum in pathdata: if not isinstance(datum, (tuple, list)): raise TypeError, "Pathdata elements must be lists/tuples" command = datum[0] args = datum[1:] ###################### if command in ("Z", "z"): pass ###################### elif command in ("H", "h", "V", "v"): num1 = args[0] if command == "H" or (command == "h" and x is None): x = num1 elif command == "h": x += num1 elif command == "V" or (command == "v" and y is None): y = num1 elif command == "v": y += num1 output.insert(x, y) ###################### elif command in ("M", "m", "L", "l", "T", "t"): num1, num2 = args if command.isupper() or x is None or y is None: x, y = num1, num2 else: x += num1 y += num2 output.insert(x, y) ###################### elif command in ("S", "s", "Q", "q"): num1, num2, num3, num4 = args if command.isupper() or x is None or y is None: cx, cy = num1, num2 else: cx = x + num1 cy = y + num2 if command.isupper() or x is None or y is None: x, y = num3, num4 else: x += num3 y += num4 output.insert(x, y) ###################### elif command in ("C", "c"): num1, num2, num3, num4, num5, num6 = args if command.isupper() or x is None or y is None: c1x, c1y = num1, num2 else: c1x = x + num1 c1y = y + num2 if command.isupper() or x is None or y is None: c2x, c2y = num3, num4 else: c2x = x + num3 c2y = y + num4 if command.isupper() or x is None or y is None: x, y = num5, num6 else: x += num5 y += num6 output.insert(x, y) ###################### elif command in ("A", "a"): num1, num2, angle, large_arc_flag, sweep_flag, num3, num4 = args oldx, oldy = x, y if command.isupper() or x is None or y is None: x, y = num3, num4 else: x += num3 y += num4 if x is not None and y is not None: centerx, centery = (x + oldx) / 2., (y + oldy) / 2. output.insert(x, y) return output