forked from xyz2tex/svg2tikz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_graphicstate.py
46 lines (39 loc) · 1.5 KB
/
test_graphicstate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
import unittest
from svg2tikz.extensions.tikz_export import TikZPathExporter, GraphicsState
arrows_svg = r"""<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="4in" height="2in"
viewBox="0 0 4000 2000" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="Triangle"
viewBox="0 0 10 10" refX="0" refY="5"
markerUnits="strokeWidth"
markerWidth="4" markerHeight="3"
orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
</defs>
<path id="pathA" d="M 1000 750 L 2000 750 L 2500 1250"
fill="none" stroke="black" stroke-width="100"
marker-end="url(#Triangle)" />
<path id="pathB" d="M 1000 750 L 2000 750 L 2500 1250"
fill="none" stroke="black" stroke-width="100"
marker-end="url(#Triangle)" marker-start="url(#Triangle)" />
</svg>"""
class TestGraphicsState(unittest.TestCase):
def test_markers(self):
tt = TikZPathExporter()
tt.parse(arrows_svg)
n = tt.get_node_from_id('pathA')
gs = GraphicsState(n)
self.assertTrue("Triangle" in gs.marker_end)
self.assertTrue(gs.marker_start is None)
self.assertTrue(gs.marker_mid is None)
gs2 = GraphicsState(tt.get_node_from_id('pathB'))
self.assertTrue("Triangle" in gs2.marker_end)
self.assertTrue("Triangle" in gs2.marker_start)
if __name__ == "__main__":
unittest.main()