Example #1
0
def svg_center(svg):
    """ Find and return the center of a svg path or group. Only path elements are considered. """
    if svg.t == 'path':
        bounding_box = path_bounding_box(svgfig_mc.pathtoPath(svg))
    else:
        bounding_box = None
        for i, p in svg:
            if isinstance(p, svgfig_mc.SVG) and p.t == 'path':
                bounding_box = path_bounding_box(svgfig_mc.pathtoPath(p), start_from=bounding_box)
    return (bounding_box[0] + bounding_box[2])/2, (bounding_box[1] + bounding_box[3])/2
Example #2
0
def svg_center(svg):
    """ Find and return the center of a svg path or group. Only path elements are considered. """
    if svg.t == 'path':
        bounding_box = path_bounding_box(svgfig_mc.pathtoPath(svg))
    else:
        bounding_box = None
        for i, p in svg:
            if isinstance(p, svgfig_mc.SVG) and p.t == 'path':
                bounding_box = path_bounding_box(svgfig_mc.pathtoPath(p),
                                                 start_from=bounding_box)
    return (bounding_box[0] + bounding_box[2]) / 2, (bounding_box[1] +
                                                     bounding_box[3]) / 2
Example #3
0
 def bounding_box_svg(self, s):
     """ Measure an svg path and set the rectangle to the bounding box """
     p = svgfig_mc.pathtoPath(s)
     self.x0, self.y0, self.x1, self.y1 = path_bounding_box(p)
     return self