Exemple #1
0
def point_generator(path, mat, flatness):

        rirCount = 0

        if len(simplepath.parsePath(path)) == 0:
                return
       
        simple_path = simplepath.parsePath(path)
        startX,startY = float(simple_path[0][1][0]), float(simple_path[0][1][1])
        command = simple_path[0][0][0]
        
        yield startX, startY, command

        p = cubicsuperpath.parsePath(path)
                
        if mat:
            simpletransform.applyTransformToPath(mat, p)

        commandPile = []

        for sp in p:
                cspsubdiv.subdiv( sp, flatness)
                for csp in sp:
                    ctrl_pt1 = csp[0]
                    ctrl_pt2 = csp[1]
                    end_pt = csp[2]
                    command = csp[-1]
                    commandPile.append(command)
                    
                    yield end_pt[0], end_pt[1], command
                    rirCount += 1
   def plotPath(self, node, matTransform):
      """ Plot the path while applying the transformation defined by the matrix matTransform. """

      filledPath = (simplestyle.parseStyle(node.get("style")).get("fill", "none") != "none")

      # Plan: Turn this path into a cubicsuperpath (list of beziers)...
      d = node.get("d")
      if len(simplepath.parsePath(d)) == 0:
         return
      p = cubicsuperpath.parsePath(d)

      # ... and apply the transformation to each point.
      simpletransform.applyTransformToPath(matTransform, p)

      # p is now a list of lists of cubic beziers [cp1, cp2, endp]
      # where the start-point is the last point of the previous segment.
      # For some reason the inkscape extensions uses csp[1] as the coordinates of each point,
      # but that makes it seem like they are using control point 2 as line points.
      # Maybe that is a side-effect of the CSP subdivion process? TODO
      realPoints = []
      for sp in p:
         cspsubdiv.subdiv(sp, self.smoothness)
         for csp in sp:
            realPoints.append( (csp[1][0], csp[1][1]) )

      self.rawObjects.append( (filledPath, realPoints) )
Exemple #3
0
def point_generator(path):

        if len(simplepath.parsePath(path)) == 0:
                return
       
        simple_path = simplepath.parsePath(path)
        startX,startY = float(simple_path[0][1][0]), float(simple_path[0][1][1])
        yield startX, startY

        p = cubicsuperpath.parsePath(path)
        for sp in p:
                cspsubdiv.subdiv( sp, .2 )
                for csp in sp:
                    ctrl_pt1 = csp[0]
                    ctrl_pt2 = csp[1]
                    end_pt = csp[2]
                    yield end_pt[0], end_pt[1],    
Exemple #4
0
   def plotPath(self, node, matTransform):
      """ Plot the path while applying the transformation defined by the matrix matTransform. """

      filledPath = (simplestyle.parseStyle(node.get("style")).get("fill", "none") != "none")

      # Plan: Turn this path into a cubicsuperpath (list of beziers)...
      d = node.get("d")
      if len(simplepath.parsePath(d)) == 0:
         return
      p = cubicsuperpath.parsePath(d)

      # ... and apply the transformation to each point.
      simpletransform.applyTransformToPath(matTransform, p)

      # p is now a list of lists of cubic beziers [cp1, cp2, endp]
      # where the start-point is the last point of the previous segment.
      # For some reason the inkscape extensions uses csp[1] as the coordinates of each point,
      # but that makes it seem like they are using control point 2 as line points.
      # Maybe that is a side-effect of the CSP subdivion process? TODO
      realPoints = []
      for sp in p:
         cspsubdiv.subdiv(sp, self.smoothness)
      
      for i in range(1, len(p)):
         pStart = [p[i][0][1][0], p[i][0][1][1]]
         pClose = []
         pDist = -1
         for k in range(len(p)):
            if (k == i):
               continue
            for j in range(len(p[k])):
               csp = p[k][j];
               tDist = self.getDist(pStart, [csp[1][0], csp[1][1]])
               if (pDist < 0) or (tDist < pDist):
                  pDist = tDist
                  pClose = [k, j]
         if pClose:
            #print "close " + repr(i) + " " + repr(pClose) + " " + repr(p[pClose[0]][pClose[1]])
            p[pClose[0]][pClose[1]].append(i)
      
      self.genPoints(p, p[0], realPoints)
      self.rawObjects.append( (filledPath, realPoints) )
Exemple #5
0
def point_generator(path, mat, flatness):

        if len(simplepath.parsePath(path)) == 0:
                return
       
        simple_path = simplepath.parsePath(path)
        startX,startY = float(simple_path[0][1][0]), float(simple_path[0][1][1])
        yield startX, startY

        p = cubicsuperpath.parsePath(path)
        
        if mat:
            simpletransform.applyTransformToPath(mat, p)

        for sp in p:
                cspsubdiv.subdiv( sp, flatness)
                for csp in sp:
                    ctrl_pt1 = csp[0]
                    ctrl_pt2 = csp[1]
                    end_pt = csp[2]
                    yield end_pt[0], end_pt[1],    
Exemple #6
0
def point_generator(path, mat, flatness):

        if len(simplepath.parsePath(path)) == 0:
                return
       
        simple_path = simplepath.parsePath(path)
        startX,startY = float(simple_path[0][1][0]), float(simple_path[0][1][1])
        yield startX, startY

        p = cubicsuperpath.parsePath(path)
        
        if mat:
            simpletransform.applyTransformToPath(mat, p)

        for sp in p:
                cspsubdiv.subdiv( sp, flatness)
                for csp in sp:
                    ctrl_pt1 = csp[0]
                    ctrl_pt2 = csp[1]
                    end_pt = csp[2]
                    yield end_pt[0], end_pt[1],