(spline, height, replace_with_prev=False)
return path
Converts SplineSet to a list of tokenized commands in svg path.
Converts SplineSet to a list of tokenized commands in svg path.
Converts SplineSet to a list of tokenized commands in svg path .
def _spline_to_path_list(spline, height, replace_with_prev=False):
  """Converts SplineSet to a list of tokenized commands in svg path."""
  path = []
  prev_xy = []
  for line in spline.splitlines():
    if not line:
      continue
    tokens = line.split(' ')
    cmd = tokens[-2]
    if cmd not in 'cml':
      # COMMAND NOT RECOGNIZED.
      return []
      # assert cmd in 'cml', 'Command not recognized: {}'.format(cmd)
    args = tokens[:-2]
    args = [float(x) for x in args if x]

    if replace_with_prev and cmd in 'c':
      args[:2] = prev_xy
    prev_xy = args[-2:]

    new_y_args = []
    for i, a in enumerate(args):
      if i % 2 == 1:
        new_y_args.append((height - a))
      else:
        new_y_args.append((a))

    path.append([cmd.upper()] + new_y_args)
  return path
def _spline_to_path_list ( spline , height , replace_with_prev = False ) : path = [ ] prev_xy = [ ] for line in spline . splitlines ( ) : if not line : continue tokens = line . split ( ' ' ) cmd = tokens [ - 2 ] if cmd not in 'cml' : # COMMAND NOT RECOGNIZED. return [ ] # assert cmd in 'cml', 'Command not recognized: {}'.format(cmd) args = tokens [ : - 2 ] args = [ float ( x ) for x in args if x ] if replace_with_prev and cmd in 'c' : args [ : 2 ] = prev_xy prev_xy = args [ - 2 : ] new_y_args = [ ] for i , a in enumerate ( args ) : if i % 2 == 1 : new_y_args . append ( ( height - a ) ) else : new_y_args . append ( ( a ) ) path . append ( [ cmd . upper ( ) ] + new_y_args ) return path