예제 #1
0
 def test_from_path(self, path_n_bytes_image):
     path, bytes_image = path_n_bytes_image
     img = images.Img(bytes_image)
     assert isinstance(img.surface, cairocffi.ImageSurface)
     img2 = img.from_path(path)
     assert img == img2
     img2.theta = 90.0
     assert img != img2
     img2.theta = 0.0
     assert img == img2
예제 #2
0
 def test_pattern_rotate(self, path_n_bytes_image):
     path, bytes_image = path_n_bytes_image
     img = images.Img(bytes_image)
     img.theta = 90.0
     assert img.theta == 90.0
     t_matrix = img.pattern.get_matrix().as_tuple()
     assert_approx_equal(t_matrix, (0.0, 1.0, -1.0, 0.0))
     img.theta = 45.0
     t_matrix = img.pattern.get_matrix().as_tuple()
     from math import sqrt
     s2o2 = sqrt(2) / 2.0
     assert_approx_equal(t_matrix, (s2o2, s2o2, -s2o2, s2o2))
     del img.theta
     assert img.theta == pytest.approx(0.0)
예제 #3
0
 def test_init(self, path_n_bytes_image):
     path, bytes_image = path_n_bytes_image
     img = images.Img(bytes_image)
     assert isinstance(img.surface, cairocffi.ImageSurface)
     del img.surface
     assert isinstance(img.surface, cairocffi.ImageSurface)
예제 #4
0
 def test_pattern(self, path_n_bytes_image):
     path, bytes_image = path_n_bytes_image
     img = images.Img(bytes_image)
     assert isinstance(img.pattern, cairocffi.SurfacePattern)