def test_orient_rad(self): marker = Marker(id='test', orient='3.1415rad', debug=True, profile='full') self.assertEqual(marker.tostring(), '<marker id="test" orient="3.1415rad" />')
def test_add_subelement_with_autoid(self): marker = Marker(debug=True, profile='full') marker.add(Group()) self.assertTrue( re.match(r'^<marker id="id\d+"><g /></marker>$', marker.tostring()), "getting an autoid for class Marker failed.")
def test_orient_number(self): marker = Marker(id='test', orient=30, debug=True, profile='full') self.assertEqual(marker.tostring(), '<marker id="test" orient="30" />')
def test_size(self): marker = Marker(id='test', size=(1, 2), debug=True, profile='full') self.assertEqual( marker.tostring(), '<marker id="test" markerHeight="2" markerWidth="1" />')
def test_insert(self): marker = Marker(id='test', insert=(1, 2), debug=True, profile='full') self.assertEqual(marker.tostring(), '<marker id="test" refX="1" refY="2" />')
def test_add_subelement(self): marker = Marker(id='test', debug=True, profile='full') marker.add(Group()) self.assertEqual(marker.tostring(), '<marker id="test"><g /></marker>')
def test_constructor(self): marker = Marker(id='test', orient='auto', debug=True, profile='full') self.assertEqual(marker.tostring(), '<marker id="test" orient="auto" />')
def test_size(self): marker = Marker(id='test', size=(1, 2), debug=True, profile='full') self.assertEqual(marker.tostring(), '<marker id="test" markerHeight="2" markerWidth="1" />')
def test_add_subelement_with_autoid(self): marker = Marker(debug=True, profile='full') marker.add(Group()) self.assertTrue( re.match('^<marker id="id\d+"><g /></marker>$', marker.tostring()), "getting an autoid for class Marker failed.")
def include_markers(dwg, endpoints): from svgwrite.container import Marker from svgwrite.shapes import Circle, Line, Polyline arrowhead = Marker( insert=(4, 4), size=(4, 8), orient='auto', markerUnits='strokeWidth', id='arrowhead' ) arrowhead.add(Polyline([(0, 8), (4, 4), (0, 0)])) dwg.defs.add(arrowhead) #TICKMARK tickmark = Marker( insert=(0.5, 5), size=(1, 10), orient='auto', markerUnits='strokeWidth', id='tickmark' ) tickmark.add(Line((0, 0), (0, 10))) dwg.defs.add(tickmark) if not endpoints: return #DISCONTINUITY discontinuity = Marker( insert=(3.5, 3.5), size=(7, 7), markerUnits='strokeWidth', id='discontinuity' ) discontinuity.add(Circle((3.5, 3.5), 2)) dwg.defs.add(discontinuity) #CONTINUITY continuity = Marker( insert=(3.5, 3.5), size=(7, 7), markerUnits='strokeWidth', id='continuity' ) continuity.add(Circle((3.5, 3.5), 2)) dwg.defs.add(continuity)