(path, categorical=False)
return new_path
Converts path's commands to a series of vectors.
Converts path's commands to a series of vectors.
Converts path s commands to a series of vectors .
def path_to_vector(path, categorical=False):
  """Converts path's commands to a series of vectors."""
  # Notes:
  #   - The SimpleSVG dataset does not have any 't', 'q', 'Z', 'T', or 'Q'.
  #     Thus, we don't handle those here.
  #   - We also removed all 'z's.
  #   - The x-axis-rotation argument to a commands is always 0 in this
  #     dataset, so we ignore it

  # Many commands have args that correspond to args in other commands.
  #   v  __,__ _______________ ______________,_________ __,__ __,__ _,y
  #   h  __,__ _______________ ______________,_________ __,__ __,__ x,_
  #   z  __,__ _______________ ______________,_________ __,__ __,__ _,_
  #   a  rx,ry x-axis-rotation large-arc-flag,sweepflag __,__ __,__ x,y
  #   l  __,__ _______________ ______________,_________ __,__ __,__ x,y
  #   c  __,__ _______________ ______________,_________ x1,y1 x2,y2 x,y
  #   m  __,__ _______________ ______________,_________ __,__ __,__ x,y
  #   s  __,__ _______________ ______________,_________ __,__ x2,y2 x,y

  # So each command will be converted to a vector where the dimension is the
  # minimal number of arguments to all commands:
  #   [rx, ry, large-arc-flag, sweepflag, x1, y1, x2, y2, x, y]
  # If a command does not output a certain arg, it is set to 0.
  #   "l 5,5" becomes [0, 0, 0, 0, 0, 0, 0, 0, 5, 5]

  # Also note, as of now we also output an extra dimension at index 0, which
  # indicates which command is being outputted (integer).
  new_path = []
  for cmd in path:
    new_path.append(cmd_to_vector(cmd, categorical=categorical))
  return new_path
def path_to_vector ( path , categorical = False ) : # Notes: #   - The SimpleSVG dataset does not have any 't', 'q', 'Z', 'T', or 'Q'. #     Thus, we don't handle those here. #   - We also removed all 'z's. #   - The x-axis-rotation argument to a commands is always 0 in this #     dataset, so we ignore it # Many commands have args that correspond to args in other commands. #   v  __,__ _______________ ______________,_________ __,__ __,__ _,y #   h  __,__ _______________ ______________,_________ __,__ __,__ x,_ #   z  __,__ _______________ ______________,_________ __,__ __,__ _,_ #   a  rx,ry x-axis-rotation large-arc-flag,sweepflag __,__ __,__ x,y #   l  __,__ _______________ ______________,_________ __,__ __,__ x,y #   c  __,__ _______________ ______________,_________ x1,y1 x2,y2 x,y #   m  __,__ _______________ ______________,_________ __,__ __,__ x,y #   s  __,__ _______________ ______________,_________ __,__ x2,y2 x,y # So each command will be converted to a vector where the dimension is the # minimal number of arguments to all commands: #   [rx, ry, large-arc-flag, sweepflag, x1, y1, x2, y2, x, y] # If a command does not output a certain arg, it is set to 0. #   "l 5,5" becomes [0, 0, 0, 0, 0, 0, 0, 0, 5, 5] # Also note, as of now we also output an extra dimension at index 0, which # indicates which command is being outputted (integer). new_path = [ ] for cmd in path : new_path . append ( cmd_to_vector ( cmd , categorical = categorical ) ) return new_path