Ejemplo n.º 1
0
    def test_apply_transform(self):
        translatable = Translatable((10, 20))
        angle = 145
        rotatable = Rotatable(angle)
        self.__backend.create_canvas()

        self.__backend.push_surface()
        self.__backend.apply_transform(translatable)
        matrix = self.__backend.ctx().get_matrix()
        assert matrix[4] == 10
        assert matrix[5] == 20
        self.__backend.pop_surface()

        self.__backend.push_surface()
        self.__backend.apply_transform(rotatable)
        matrix = self.__backend.ctx().get_matrix()
        c = math.cos(math.radians(angle))
        s = math.sin(math.radians(angle))
        assert sum(map(operator.sub, matrix, (c, s, -1 * s, c, 0, 0))) == 0
        self.__backend.pop_surface()
Ejemplo n.º 2
0
 def test_init(self):
     rotatable = Rotatable()
     assert rotatable != None
     assert rotatable.angle() == 0
Ejemplo n.º 3
0
 def test_angle(self):
     rotatable = Rotatable()
     rotatable.set_angle(46)
     assert rotatable.angle() == 46
     rotatable.set_angle(-170)
     assert rotatable.angle() == -170
Ejemplo n.º 4
0
 def test_init(self):
     rotatable = Rotatable()
     assert rotatable != None
     assert rotatable.angle() == 0
Ejemplo n.º 5
0
 def test_angle(self):
     rotatable = Rotatable()
     rotatable.set_angle(46)
     assert rotatable.angle() == 46
     rotatable.set_angle(-170)
     assert rotatable.angle() == -170