4
from PIL import ImagePath
10
p = ImagePath.Path(list(range(10)))
13
assert_equal(len(p), 5)
14
assert_equal(p[0], (0.0, 1.0))
15
assert_equal(p[-1], (8.0, 9.0))
16
assert_equal(list(p[:1]), [(0.0, 1.0)])
17
assert_equal(list(p), [(0.0, 1.0), (2.0, 3.0), (4.0, 5.0), (6.0, 7.0), (8.0, 9.0)])
20
assert_equal(p.tolist(), [(0.0, 1.0), (2.0, 3.0), (4.0, 5.0), (6.0, 7.0), (8.0, 9.0)])
21
assert_equal(p.tolist(1), [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0])
23
assert_equal(p.getbbox(), (0.0, 1.0, 8.0, 9.0))
25
assert_equal(p.compact(5), 2)
26
assert_equal(list(p), [(0.0, 1.0), (4.0, 5.0), (8.0, 9.0)])
28
p.transform((1,0,1,0,1,1))
29
assert_equal(list(p), [(1.0, 2.0), (5.0, 6.0), (9.0, 10.0)])
31
# alternative constructors
32
p = ImagePath.Path([0, 1])
33
assert_equal(list(p), [(0.0, 1.0)])
34
p = ImagePath.Path([0.0, 1.0])
35
assert_equal(list(p), [(0.0, 1.0)])
36
p = ImagePath.Path([0, 1])
37
assert_equal(list(p), [(0.0, 1.0)])
38
p = ImagePath.Path([(0, 1)])
39
assert_equal(list(p), [(0.0, 1.0)])
41
assert_equal(list(p), [(0.0, 1.0)])
42
p = ImagePath.Path(p.tolist(0))
43
assert_equal(list(p), [(0.0, 1.0)])
44
p = ImagePath.Path(p.tolist(1))
45
assert_equal(list(p), [(0.0, 1.0)])
46
p = ImagePath.Path(array.array("f", [0, 1]))
47
assert_equal(list(p), [(0.0, 1.0)])
48
p = ImagePath.Path(array.array("f", [0, 1]).tostring())
49
assert_equal(list(p), [(0.0, 1.0)])