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"]) for (localx, localy) in mypts: self.__bb_point(localx, localy) 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)
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"]) for (localx, localy) in mypts: self.__bb_point(localx, localy) 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)
def testRoundingOpposite(self): pts = ((-1., 1.), (1., 1.)) rotated = geom.rotate_points(pts, 180.000001) self.assertFigureAlmostEqual(rotated, [[1., 1.], [-1., 1.]])
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)))
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)))
def testOpposite(self): pts = ((-1., 1.), (1., 1.)) rotated = geom.rotate_points(pts, angle=180.) self.assertFigureAlmostEqual(rotated, [[1., 1.], [-1., 1.]])
def testIdentic(self): pts = ((-1., 1.), (1., 1.)) rotated = geom.rotate_points(pts) self.assertFigureAlmostEqual(rotated, ((-1.0, 1.0), (1.0, 1.0)))
def testRoundingOpposite(self): pts=((-1., 1.), (1., 1.)) rotated =geom.rotate_points(pts, 180.000001) self.assertFigureAlmostEqual(rotated,[[1., 1.], [-1., 1.]])
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)))
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)))
def testOpposite(self): pts=((-1., 1.), (1., 1.)) rotated =geom.rotate_points(pts, angle=180.) self.assertFigureAlmostEqual(rotated,[[1., 1.], [-1., 1.]])
def testIdentic(self): pts=((-1., 1.), (1., 1.)) rotated =geom.rotate_points(pts) self.assertFigureAlmostEqual(rotated,((-1.0, 1.0), (1.0, 1.0)))