parameters: (self, trans=None)
return_statement: return SVG("path", d="".join(output), **self.attr)
docstring: Apply the transformation "trans" and return an SVG object.
docstring_summary: Apply the transformation "trans" and return an SVG object.
docstring_tokens: Apply the transformation trans and return an SVG object .
function: def SVG(self, trans=None):
          """Apply the transformation "trans" and return an SVG object."""
          if isinstance(trans, basestring):
              trans = totrans(trans)
  
          x, y, X, Y = None, None, None, None
          output = []
          for datum in self.d:
              if not isinstance(datum, (tuple, list)):
                  raise TypeError("pathdata elements must be tuples/lists")
  
              command = datum[0]
  
              ######################
              if command in ("Z", "z"):
                  x, y, X, Y = None, None, None, None
                  output.append("Z")
  
              ######################
              elif command in ("H", "h", "V", "v"):
                  command, num1 = datum
  
                  if command == "H" or (command == "h" and x is None):
                      x = num1
                  elif command == "h":
                      x += num1
                  elif command == "V" or (command == "v" and y is None):
                      y = num1
                  elif command == "v":
                      y += num1
  
                  if trans is None:
                      X, Y = x, y
                  else:
                      X, Y = trans(x, y)
  
                  output.append("L%g %g" % (X, Y))
  
              ######################
              elif command in ("M", "m", "L", "l", "T", "t"):
                  command, num1, num2, isglobal12 = datum
  
                  if trans is None or isglobal12:
                      if command.isupper() or X is None or Y is None:
                          X, Y = num1, num2
                      else:
                          X += num1
                          Y += num2
                      x, y = X, Y
  
                  else:
                      if command.isupper() or x is None or y is None:
                          x, y = num1, num2
                      else:
                          x += num1
                          y += num2
                      X, Y = trans(x, y)
  
                  COMMAND = command.capitalize()
                  output.append("%s%g %g" % (COMMAND, X, Y))
  
              ######################
              elif command in ("S", "s", "Q", "q"):
                  command, num1, num2, isglobal12, num3, num4, isglobal34 = datum
  
                  if trans is None or isglobal12:
                      if command.isupper() or X is None or Y is None:
                          CX, CY = num1, num2
                      else:
                          CX = X + num1
                          CY = Y + num2
  
                  else:
                      if command.isupper() or x is None or y is None:
                          cx, cy = num1, num2
                      else:
                          cx = x + num1
                          cy = y + num2
                      CX, CY = trans(cx, cy)
  
                  if trans is None or isglobal34:
                      if command.isupper() or X is None or Y is None:
                          X, Y = num3, num4
                      else:
                          X += num3
                          Y += num4
                      x, y = X, Y
  
                  else:
                      if command.isupper() or x is None or y is None:
                          x, y = num3, num4
                      else:
                          x += num3
                          y += num4
                      X, Y = trans(x, y)
  
                  COMMAND = command.capitalize()
                  output.append("%s%g %g %g %g" % (COMMAND, CX, CY, X, Y))
  
              ######################
              elif command in ("C", "c"):
                  command, num1, num2, isglobal12, num3, num4, isglobal34, num5, num6, isglobal56 = datum
  
                  if trans is None or isglobal12:
                      if command.isupper() or X is None or Y is None:
                          C1X, C1Y = num1, num2
                      else:
                          C1X = X + num1
                          C1Y = Y + num2
  
                  else:
                      if command.isupper() or x is None or y is None:
                          c1x, c1y = num1, num2
                      else:
                          c1x = x + num1
                          c1y = y + num2
                      C1X, C1Y = trans(c1x, c1y)
  
                  if trans is None or isglobal34:
                      if command.isupper() or X is None or Y is None:
                          C2X, C2Y = num3, num4
                      else:
                          C2X = X + num3
                          C2Y = Y + num4
  
                  else:
                      if command.isupper() or x is None or y is None:
                          c2x, c2y = num3, num4
                      else:
                          c2x = x + num3
                          c2y = y + num4
                      C2X, C2Y = trans(c2x, c2y)
  
                  if trans is None or isglobal56:
                      if command.isupper() or X is None or Y is None:
                          X, Y = num5, num6
                      else:
                          X += num5
                          Y += num6
                      x, y = X, Y
  
                  else:
                      if command.isupper() or x is None or y is None:
                          x, y = num5, num6
                      else:
                          x += num5
                          y += num6
                      X, Y = trans(x, y)
  
                  COMMAND = command.capitalize()
                  output.append("%s%g %g %g %g %g %g" % (COMMAND, C1X, C1Y, C2X, C2Y, X, Y))
  
              ######################
              elif command in ("A", "a"):
                  command, num1, num2, isglobal12, angle, large_arc_flag, sweep_flag, num3, num4, isglobal34 = datum
  
                  oldx, oldy = x, y
                  OLDX, OLDY = X, Y
  
                  if trans is None or isglobal34:
                      if command.isupper() or X is None or Y is None:
                          X, Y = num3, num4
                      else:
                          X += num3
                          Y += num4
                      x, y = X, Y
  
                  else:
                      if command.isupper() or x is None or y is None:
                          x, y = num3, num4
                      else:
                          x += num3
                          y += num4
                      X, Y = trans(x, y)
  
                  if x is not None and y is not None:
                      centerx, centery = (x + oldx)/2., (y + oldy)/2.
                  CENTERX, CENTERY = (X + OLDX)/2., (Y + OLDY)/2.
  
                  if trans is None or isglobal12:
                      RX = CENTERX + num1
                      RY = CENTERY + num2
  
                  else:
                      rx = centerx + num1
                      ry = centery + num2
                      RX, RY = trans(rx, ry)
  
                  COMMAND = command.capitalize()
                  output.append("%s%g %g %g %d %d %g %g" % (COMMAND, RX - CENTERX, RY - CENTERY, angle, large_arc_flag, sweep_flag, X, Y))
  
              elif command in (",", "."):
                  command, num1, num2, isglobal12, angle, num3, num4, isglobal34 = datum
                  if trans is None or isglobal34:
                      if command == "." or X is None or Y is None:
                          X, Y = num3, num4
                      else:
                          X += num3
                          Y += num4
                          x, y = None, None
  
                  else:
                      if command == "." or x is None or y is None:
                          x, y = num3, num4
                      else:
                          x += num3
                          y += num4
                      X, Y = trans(x, y)
  
                  if trans is None or isglobal12:
                      RX = X + num1
                      RY = Y + num2
  
                  else:
                      rx = x + num1
                      ry = y + num2
                      RX, RY = trans(rx, ry)
  
                  RX, RY = RX - X, RY - Y
  
                  X1, Y1 = X + RX * math.cos(angle*math.pi/180.), Y + RX * math.sin(angle*math.pi/180.)
                  X2, Y2 = X + RY * math.sin(angle*math.pi/180.), Y - RY * math.cos(angle*math.pi/180.)
                  X3, Y3 = X - RX * math.cos(angle*math.pi/180.), Y - RX * math.sin(angle*math.pi/180.)
                  X4, Y4 = X - RY * math.sin(angle*math.pi/180.), Y + RY * math.cos(angle*math.pi/180.)
  
                  output.append("M%g %gA%g %g %g 0 0 %g %gA%g %g %g 0 0 %g %gA%g %g %g 0 0 %g %gA%g %g %g 0 0 %g %g" % (
                                X1, Y1, RX, RY, angle, X2, Y2, RX, RY, angle, X3, Y3, RX, RY, angle, X4, Y4, RX, RY, angle, X1, Y1))
  
          return SVG("path", d="".join(output), **self.attr)
function_tokens: def SVG ( self , trans = None ) : if isinstance ( trans , basestring ) : trans = totrans ( trans ) x , y , X , Y = None , None , None , None output = [ ] for datum in self . d : if not isinstance ( datum , ( tuple , list ) ) : raise TypeError ( "pathdata elements must be tuples/lists" ) command = datum [ 0 ] ###################### if command in ( "Z" , "z" ) : x , y , X , Y = None , None , None , None output . append ( "Z" ) ###################### elif command in ( "H" , "h" , "V" , "v" ) : command , num1 = datum if command == "H" or ( command == "h" and x is None ) : x = num1 elif command == "h" : x += num1 elif command == "V" or ( command == "v" and y is None ) : y = num1 elif command == "v" : y += num1 if trans is None : X , Y = x , y else : X , Y = trans ( x , y ) output . append ( "L%g %g" % ( X , Y ) ) ###################### elif command in ( "M" , "m" , "L" , "l" , "T" , "t" ) : command , num1 , num2 , isglobal12 = datum if trans is None or isglobal12 : if command . isupper ( ) or X is None or Y is None : X , Y = num1 , num2 else : X += num1 Y += num2 x , y = X , Y else : if command . isupper ( ) or x is None or y is None : x , y = num1 , num2 else : x += num1 y += num2 X , Y = trans ( x , y ) COMMAND = command . capitalize ( ) output . append ( "%s%g %g" % ( COMMAND , X , Y ) ) ###################### elif command in ( "S" , "s" , "Q" , "q" ) : command , num1 , num2 , isglobal12 , num3 , num4 , isglobal34 = datum if trans is None or isglobal12 : if command . isupper ( ) or X is None or Y is None : CX , CY = num1 , num2 else : CX = X + num1 CY = Y + num2 else : if command . isupper ( ) or x is None or y is None : cx , cy = num1 , num2 else : cx = x + num1 cy = y + num2 CX , CY = trans ( cx , cy ) if trans is None or isglobal34 : if command . isupper ( ) or X is None or Y is None : X , Y = num3 , num4 else : X += num3 Y += num4 x , y = X , Y else : if command . isupper ( ) or x is None or y is None : x , y = num3 , num4 else : x += num3 y += num4 X , Y = trans ( x , y ) COMMAND = command . capitalize ( ) output . append ( "%s%g %g %g %g" % ( COMMAND , CX , CY , X , Y ) ) ###################### elif command in ( "C" , "c" ) : command , num1 , num2 , isglobal12 , num3 , num4 , isglobal34 , num5 , num6 , isglobal56 = datum if trans is None or isglobal12 : if command . isupper ( ) or X is None or Y is None : C1X , C1Y = num1 , num2 else : C1X = X + num1 C1Y = Y + num2 else : if command . isupper ( ) or x is None or y is None : c1x , c1y = num1 , num2 else : c1x = x + num1 c1y = y + num2 C1X , C1Y = trans ( c1x , c1y ) if trans is None or isglobal34 : if command . isupper ( ) or X is None or Y is None : C2X , C2Y = num3 , num4 else : C2X = X + num3 C2Y = Y + num4 else : if command . isupper ( ) or x is None or y is None : c2x , c2y = num3 , num4 else : c2x = x + num3 c2y = y + num4 C2X , C2Y = trans ( c2x , c2y ) if trans is None or isglobal56 : if command . isupper ( ) or X is None or Y is None : X , Y = num5 , num6 else : X += num5 Y += num6 x , y = X , Y else : if command . isupper ( ) or x is None or y is None : x , y = num5 , num6 else : x += num5 y += num6 X , Y = trans ( x , y ) COMMAND = command . capitalize ( ) output . append ( "%s%g %g %g %g %g %g" % ( COMMAND , C1X , C1Y , C2X , C2Y , X , Y ) ) ###################### elif command in ( "A" , "a" ) : command , num1 , num2 , isglobal12 , angle , large_arc_flag , sweep_flag , num3 , num4 , isglobal34 = datum oldx , oldy = x , y OLDX , OLDY = X , Y if trans is None or isglobal34 : if command . isupper ( ) or X is None or Y is None : X , Y = num3 , num4 else : X += num3 Y += num4 x , y = X , Y else : if command . isupper ( ) or x is None or y is None : x , y = num3 , num4 else : x += num3 y += num4 X , Y = trans ( x , y ) if x is not None and y is not None : centerx , centery = ( x + oldx ) / 2. , ( y + oldy ) / 2. CENTERX , CENTERY = ( X + OLDX ) / 2. , ( Y + OLDY ) / 2. if trans is None or isglobal12 : RX = CENTERX + num1 RY = CENTERY + num2 else : rx = centerx + num1 ry = centery + num2 RX , RY = trans ( rx , ry ) COMMAND = command . capitalize ( ) output . append ( "%s%g %g %g %d %d %g %g" % ( COMMAND , RX - CENTERX , RY - CENTERY , angle , large_arc_flag , sweep_flag , X , Y ) ) elif command in ( "," , "." ) : command , num1 , num2 , isglobal12 , angle , num3 , num4 , isglobal34 = datum if trans is None or isglobal34 : if command == "." or X is None or Y is None : X , Y = num3 , num4 else : X += num3 Y += num4 x , y = None , None else : if command == "." or x is None or y is None : x , y = num3 , num4 else : x += num3 y += num4 X , Y = trans ( x , y ) if trans is None or isglobal12 : RX = X + num1 RY = Y + num2 else : rx = x + num1 ry = y + num2 RX , RY = trans ( rx , ry ) RX , RY = RX - X , RY - Y X1 , Y1 = X + RX * math . cos ( angle * math . pi / 180. ) , Y + RX * math . sin ( angle * math . pi / 180. ) X2 , Y2 = X + RY * math . sin ( angle * math . pi / 180. ) , Y - RY * math . cos ( angle * math . pi / 180. ) X3 , Y3 = X - RX * math . cos ( angle * math . pi / 180. ) , Y - RX * math . sin ( angle * math . pi / 180. ) X4 , Y4 = X - RY * math . sin ( angle * math . pi / 180. ) , Y + RY * math . cos ( angle * math . pi / 180. ) output . append ( "M%g %gA%g %g %g 0 0 %g %gA%g %g %g 0 0 %g %gA%g %g %g 0 0 %g %gA%g %g %g 0 0 %g %g" % ( X1 , Y1 , RX , RY , angle , X2 , Y2 , RX , RY , angle , X3 , Y3 , RX , RY , angle , X4 , Y4 , RX , RY , angle , X1 , Y1 ) ) return SVG ( "path" , d = "" . join ( output ) , * * self . attr )