Exemplo n.º 1
0
 def testMatrixMapping(self):
     m = QMatrix(1.0, 2.0, 1.0, 3.0, 100.0, 200.0)
     res = m.map(5, 5)
     self.assertAlmostEqual(res[0], 5 * 1.0 + 5 * 1.0 + 100.0)
     self.assertAlmostEqual(res[1], 5 * 2.0 + 5 * 3.0 + 200.0)
     res = m.map(5.0, 5.0)
     self.assertAlmostEqual(res[0], 5.0 * 1.0 + 5.0 * 1.0 + 100.0)
     self.assertAlmostEqual(res[1], 5.0 * 2.0 + 5.0 * 3.0 + 200.0)
Exemplo n.º 2
0
 def testMatrixMapping(self):
     m = QMatrix(1.0, 2.0, 1.0, 3.0, 100.0, 200.0)
     res = m.map(5, 5)
     self.assertAlmostEqual(res[0], 5 * 1.0 + 5 * 1.0 + 100.0)
     self.assertAlmostEqual(res[1], 5 * 2.0 + 5 * 3.0 + 200.0)
     res = m.map(5.0, 5.0)
     self.assertAlmostEqual(res[0], 5.0 * 1.0 + 5.0 * 1.0 + 100.0)
     self.assertAlmostEqual(res[1], 5.0 * 2.0 + 5.0 * 3.0 + 200.0)
Exemplo n.º 3
0
 def _distortvertex(self, scene, offset, displacement, vertexindex, rotation):
     item = scene.itemAt(*self._addoffsets(offset, displacement))
     polygon = item.polygon()
     matrix = QMatrix()
     matrix.rotate(rotation)
     rotated = matrix.map(pentproto.value(0)).toTuple()
     polygon.replace(vertexindex, QPointF(*self._addoffsets(rotated, offset)))
     item.setPolygon(polygon)
Exemplo n.º 4
0
    def loadShipImage(self, width, height):
        """ Load the ship image """
        self.unscaled_ship = QImage("hero_ship.png")
        matrix = QMatrix()
        matrix = matrix.rotate(180)
        self.unscaled_ship = self.unscaled_ship.transformed(matrix)

        xScaledSize = width*self.ship_model.rectangle.width/100
        yScaledSize = height*self.ship_model.rectangle.height/100
        
        self.scaled_ship = self.unscaled_ship.scaled(xScaledSize, yScaledSize)
Exemplo n.º 5
0
 def takeSnapshot(self, path):
     '''
     screen capture in png format
     :param path: saved file path
     :return: None
     '''
     p1 = self.cmd.popen(['screencap', '-p'], stdout=PIPE)
     p = Popen(['perl', '-pe', 's/\x0D\x0D\x0A/\x0A/g'],
               stdin=p1.stdout,
               stdout=PIPE)
     out, error = p.communicate()
     ba = QByteArray.fromRawData(out)
     img = QImage.fromData(ba, 'PNG')
     orient = self.getCurrDisplay()['orientation']
     if orient == 1:
         img = img.transformed(QMatrix().rotate(-90))
     elif orient == 2:
         img = img.transformed(QMatrix().rotate(-180))
     elif orient == 3:
         img = img.transformed(QMatrix().rotate(-270))
     img.save(path, 'PNG')
Exemplo n.º 6
0
 def setUp(self):
     self.original = QMatrix(1, 2, 3, 4, 5, 6)
Exemplo n.º 7
0
 def testMatrixWithWrongType(self):
     matrix = QMatrix(11, 12, 21, 22, 100, 200)
     point = QPoint(3, 3)
     self.assertRaises(TypeError, matrix.__mul__, point)
Exemplo n.º 8
0
 def testMatrix(self):
     matrix = QMatrix(11, 12, 21, 22, 100, 200)
     point = QPoint(3, 3)
     self.assertEqual(point * matrix, qpointTimesQMatrix(point, matrix))