# Common drawing utilities. Most of this stuff exists in ad hoc form in the
# individual drawing programs, but it should get migrated here in the interest
# of cleanup.

linescale = 1
flags = {}

import sys

def setlinewidth(width = 1):
    print width * linescale, 'setlinewidth'

def parse_cmdline():
    figname = None
    global flags
    flagname = None
    args = []
    for arg in sys.argv[1:]:
	if arg.startswith('-') and flagname is None:
	    flagname = arg[1:]
	else:
	    if flagname:
		flags[flagname] = arg
		flagname = None
	    elif figname is None:
		figname = arg
	    else:
		args.append(arg)
    if figname and figname.endswith('.pdf'):
	figname = figname[:-4]
    #print '%', figname, args, flags
    if 'linescale' in flags:
	global linescale
	linescale = float(flags['linescale'])
    return figname, args, flags
