Beispiel #1
0
 def makeRotTransform(cls, theta, origin):
     if isinstance(origin, QtCore.QPointF) or isinstance(
             origin, QtCore.QPoint):
         origin = (origin.x(), origin.y())
     rotMat = (math.cos(theta), -math.sin(theta), math.sin(theta),
               math.cos(theta))
     shift = xasy2asy.asyTransform((0, 0, 1 - rotMat[0], -rotMat[1],
                                    -rotMat[2], 1 - rotMat[3])) * origin
     return xasy2asy.asyTransform(
         (shift[0], shift[1], rotMat[0], rotMat[1], rotMat[2], rotMat[3]))
Beispiel #2
0
def extractTransform(line):
    """Returns key and the new transform."""
    # see https://regex101.com/r/6DqkRJ/4 for info
    mapString = x2a.xasyItem.mapString
    testMatch = re.match(
        r'^{0:s}\s*\(\s*\"([^\"]+)\"\s*,\s*\(([-\d, .]+)\)\s*\)'.format(
            mapString), line.strip())
    if testMatch is None:
        mapOnlyMatch = re.match(
            r'^{0:s}\s*\(\s *\"([^\"]+)\"\s*\)'.format(mapString),
            line.strip())
        if mapOnlyMatch is None:
            return None
        else:
            key = mapOnlyMatch.group(1)
            return key, x2a.identity()
    else:
        key = testMatch.group(1)
        rawStr = testMatch.group(2)
        rawStrArray = rawStr.split(',')

        if len(rawStrArray) != 6:
            return None
        transf = [float(val.strip()) for val in rawStrArray]
        return key, x2a.asyTransform(transf)
Beispiel #3
0
 def applyChanges(self):
   self.modified = True
   self.shape.transform[0] = xasy2asy.asyTransform((0,0,1,0,0,1))
   for i in range(len(self.nodeList)):
     self.path.nodeSet[i] = self.nodeList[i].node
     if self.nodeList[i].postcontrol != None:
       self.path.controlSet[i][0] = self.nodeList[i].postcontrol
     if self.nodeList[i].precontrol != None:
       self.path.controlSet[i-1][1] = self.nodeList[i].precontrol
Beispiel #4
0
 def makeScaleTransform(cls, sx, sy, origin):
     if isinstance(origin, Qc.QPointF) or isinstance(origin, Qc.QPoint):
         origin = (origin.x(), origin.y())
     shiftMat = x2a.asyTransform((0, 0, 1 - sx, 0, 0, 1 - sy)) * origin
     return x2a.asyTransform((shiftMat[0], shiftMat[1], sx, 0, 0, sy))