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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# coding=utf-8
"""
Test CubicSuperPath
"""
from inkex.tester import TestCase
from inkex.paths import CubicSuperPath
class CubicPathTest(TestCase):
def test_LHV(self):
p = [
["M", [1.2, 2.3]],
["L", [3.4, 4.5]],
["H", [5.6]],
["V", [6.7]],
]
csp = CubicSuperPath(p)
self.assertDeepAlmostEqual(
csp,
[
[
[[1.2, 2.3], [1.2, 2.3], [1.2, 2.3]],
[[3.4, 4.5], [3.4, 4.5], [3.4, 4.5]],
[[5.6, 4.5], [5.6, 4.5], [5.6, 4.5]],
[[5.6, 6.7], [5.6, 6.7], [5.6, 6.7]],
]
],
)
def test_CS(self):
p = [
["M", [1.2, 2.3]],
["C", [4.5, 3.4, 5.6, 6.7, 8.9, 7.8]],
["S", [9.1, 1.2, 2.3, 3.4]],
]
csp = CubicSuperPath(p)
self.assertDeepAlmostEqual(
csp,
[
[
[[1.2, 2.3], [1.2, 2.3], [4.5, 3.4]],
[[5.6, 6.7], [8.9, 7.8], [12.2, 8.9]],
[[9.1, 1.2], [2.3, 3.4], [2.3, 3.4]],
]
],
)
def test_QT(self):
p = [
["M", [0.0, 0.0]],
["Q", [3.0, 0.0, 3.0, 3.0]],
["T", [0.0, 6.0]],
]
csp = CubicSuperPath(p)
self.assertDeepAlmostEqual(
csp,
[
[
[[0.0, 0.0], [0.0, 0.0], [2.0, 0.0]],
[[3.0, 1.0], [3.0, 3.0], [3.0, 5.0]],
[[2.0, 6.0], [0.0, 6.0], [0.0, 6.0]],
]
],
)
def test_AZ(self):
p = [
["M", [0.0, 4.0]],
["A", [3.0, 6.0, 0.0, 1, 1, 5.0, 4.0]],
["Z", []],
]
csp = CubicSuperPath(p)
self.assertTrue(len(csp[0]) > 3)
|