예제 #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)
예제 #2
0
파일: main.py 프로젝트: rektide/graffle2svg
    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)
예제 #3
0
파일: main.py 프로젝트: jnavila/graffle2svg
 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)
예제 #4
0
파일: main.py 프로젝트: rektide/graffle2svg
    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)
예제 #5
0
 def testRoundingOpposite(self):
     pts = ((-1., 1.), (1., 1.))
     rotated = geom.rotate_points(pts, 180.000001)
     self.assertFigureAlmostEqual(rotated, [[1., 1.], [-1., 1.]])
예제 #6
0
 def testRounding360(self):
     pts = ((-1., 1.), (1., 1.))
     rotated = geom.rotate_points(pts, 359.999999)
     self.assertFigureAlmostEqual(rotated, ((-1.0, 1.0), (1.0, 1.0)))
예제 #7
0
 def test90(self):
     pts = ((-1., 1.), (3., 1.), (-1, -2))
     rotated = geom.rotate_points(pts, 90)
     self.assertFigureAlmostEqual(rotated,
                                  ((-0.5, -2.5), (-0.5, 1.5), (2.5, -2.5)))
예제 #8
0
 def testOpposite(self):
     pts = ((-1., 1.), (1., 1.))
     rotated = geom.rotate_points(pts, angle=180.)
     self.assertFigureAlmostEqual(rotated, [[1., 1.], [-1., 1.]])
예제 #9
0
 def testIdentic(self):
     pts = ((-1., 1.), (1., 1.))
     rotated = geom.rotate_points(pts)
     self.assertFigureAlmostEqual(rotated, ((-1.0, 1.0), (1.0, 1.0)))
예제 #10
0
 def testRoundingOpposite(self):
     pts=((-1., 1.), (1., 1.))
     rotated =geom.rotate_points(pts, 180.000001)
     self.assertFigureAlmostEqual(rotated,[[1., 1.], [-1., 1.]])
예제 #11
0
 def testRounding360(self):
     pts=((-1., 1.), (1., 1.))
     rotated =geom.rotate_points(pts, 359.999999)
     self.assertFigureAlmostEqual(rotated,((-1.0, 1.0), (1.0, 1.0)))
예제 #12
0
 def test90(self):
     pts=((-1., 1.), (3., 1.),(-1,-2))
     rotated =geom.rotate_points(pts,90)
     self.assertFigureAlmostEqual(rotated,((-0.5,-2.5),(-0.5,1.5),(2.5,-2.5)))
예제 #13
0
 def testOpposite(self):
     pts=((-1., 1.), (1., 1.))
     rotated =geom.rotate_points(pts, angle=180.)
     self.assertFigureAlmostEqual(rotated,[[1., 1.], [-1., 1.]])
예제 #14
0
 def testIdentic(self):
     pts=((-1., 1.), (1., 1.))
     rotated =geom.rotate_points(pts)
     self.assertFigureAlmostEqual(rotated,((-1.0, 1.0), (1.0, 1.0)))