Beispiel #1
0
    def svg_addBezier(self, node, bounds, shapeopts, **opts):
        points = shapeopts["UnitPoints"]
        points =[self.extractBoundCOordinates(pt) for pt in points]
        c = [bounds[i] + (bounds[i+2]/2.) for i in [0, 1]] #centre
        rx = bounds[2]/2.
        ry = bounds[3]/2.

        # These points are relative to the bounds
        points = [ [c[0] + pt[0] * rx, c[1] + pt[1] * ry] for pt in points]

        if opts.get("HFlip", False):
            points = geom.h_flip_points(points)
        if opts.get("VFlip", False):
            points = geom.v_flip_points(points)
        if opts.get("Rotation") is not None:
            points = geom.rotate_points(points, opts["Rotation"])

        ptStrings = [",".join([str(b) for b in a]) for a in points]
        line_string = "M %s"%ptStrings[0] + " ".join(" L %s"%a for a in ptStrings[1:])
        
        path_tag = self.svg_dom.createElement("path")
        path_tag.setAttribute("id", opts.get("id",""))
        path_tag.setAttribute("style", str(self.style.scopeStyle()))
        path_tag.setAttribute("d", line_string)
        node.appendChild(path_tag)
Beispiel #2
0
    def svg_addBezier(self, node, bounds, shapeopts, **opts):
        points = shapeopts["UnitPoints"]
        points = [self.extractBoundCOordinates(pt) for pt in points]
        c = [bounds[i] + (bounds[i + 2] / 2.) for i in [0, 1]]  #centre
        rx = bounds[2] / 2.
        ry = bounds[3] / 2.

        # These points are relative to the bounds
        points = [[c[0] + pt[0] * rx, c[1] + pt[1] * ry] for pt in points]

        if opts.get("HFlip", False):
            points = geom.h_flip_points(points)
        if opts.get("VFlip", False):
            points = geom.v_flip_points(points)
        if opts.get("Rotation") is not None:
            points = geom.rotate_points(points, opts["Rotation"])

        ptStrings = [",".join([str(b) for b in a]) for a in points]
        line_string = "M %s" % ptStrings[0] + " ".join(" L %s" % a
                                                       for a in ptStrings[1:])

        path_tag = self.svg_dom.createElement("path")
        path_tag.setAttribute("id", opts.get("id", ""))
        path_tag.setAttribute("style", str(self.style.scopeStyle()))
        path_tag.setAttribute("d", line_string)
        node.appendChild(path_tag)
Beispiel #3
0
 def addPath(self, pts, **opts):
     # do geometry mapping here
     mypts = pts
     if opts.get("HFlip",False):
         mypts = geom.h_flip_points(mypts)
     if opts.get("VFlip",False):            
         mypts = geom.v_flip_points(mypts)
     if opts.get("Rotation") is not None:
         mypts = geom.rotate_points(mypts,opts["Rotation"])
         
     ptStrings = [",".join([str(b) for b in a]) for a in mypts]
     line_string = "M %s"%ptStrings[0] + " ".join(" L %s"%a for a in ptStrings[1:] )
     if opts.get("closepath",False):
         line_string = line_string + " z"
     path_tag = self.svg_dom.createElement("path")
     path_tag.setAttribute("id", opts.get("id",""))
     path_tag.setAttribute("style", str(self.style.scopeStyle()))
     path_tag.setAttribute("d", line_string)
     self.svg_current_layer.appendChild(path_tag)
Beispiel #4
0
    def svg_addPath(self, node, pts, **opts):
        # do geometry mapping here
        mypts = pts
        if opts.get("HFlip", False):
            mypts = geom.h_flip_points(mypts)
        if opts.get("VFlip", False):
            mypts = geom.v_flip_points(mypts)
        if opts.get("Rotation") is not None:
            mypts = geom.rotate_points(mypts, opts["Rotation"])

        ptStrings = [",".join([str(b) for b in a]) for a in mypts]
        line_string = "M %s" % ptStrings[0] + " ".join(" L %s" % a
                                                       for a in ptStrings[1:])
        if opts.get("closepath", False) == True:
            line_string = line_string + " z"
        path_tag = self.svg_dom.createElement("path")
        path_tag.setAttribute("id", opts.get("id", ""))
        path_tag.setAttribute("style", str(self.style.scopeStyle()))
        path_tag.setAttribute("d", line_string)
        node.appendChild(path_tag)