def create_file(commandList, plotList, fileName): ''' Takes a List of paths found in the .ps and makes js compatible syntax input: Multidimensional list of strings similar to .ps commands output: Similar to input but formatted to be paperpJS readable. ''' writefile = open(fileName, 'w') if fileName.endswith(".html"): write_html_header(writefile, fileName) # add the auto sorting functions for the compound path array, and empty path remover. write_sorting_functions(writefile) write_empty_path_removal_function(writefile) # add postscript functions written in javascript glyphCounter = 0 for newPath in commandList: functionName = "draw_glyph_" + str(glyphCounter) write_postscript_functions(newPath, functionName, writefile) glyphCounter += 1 #for primitive in plotList: # print(primitive) if fileName.endswith(".html"): write_html_footer(writefile, rectWidth, rectHeight) # done. writefile.close()
def create_file(commandList, fileName): ''' Takes a List of paths found in the .ps and makes js compatible syntax input: Multidimensional list of strings similar to .ps commands output: Similar to input but formatted to be paperpJS readable. ''' primaryCommands, secondaryCommands = commandList writefile = open(fileName, 'w') if fileName.endswith(".html"): write_html_header(writefile, fileName) # add the auto sorting functions for the compound path array, and empty path remover. write_sorting_functions(writefile) write_empty_path_removal_function(writefile) primaryCounter = 0 for obj in primaryCommands: functionName = "draw_primary_" + str(primaryCounter) write_primary_postScript(obj, functionName, writefile) primaryCounter += 1 secondaryCounter = 0 for obj in secondaryCommands: functionName = "draw_primary_" + str(secondaryCounter) write_secondary_postScript(obj, functionName, writefile) secondaryCounter += 1 if fileName.endswith(".html"): write_html_footer(writefile, rectWidth, rectHeight) # done. writefile.close()
def create_file(commandList, plotList, fileName): """ Takes a List of paths found in the .ps and makes js compatible syntax input: Multidimensional list of strings similar to .ps commands output: Similar to input but formatted to be paperpJS readable. """ writefile = open(fileName, "w") if fileName.endswith(".html"): write_html_header(writefile, fileName) # add the auto sorting functions for the compound path array, and empty path remover. write_sorting_functions(writefile) write_empty_path_removal_function(writefile) # add postscript functions written in javascript glyphCounter = 0 for newPath in commandList: if len(newPath) > 4: functionName = "draw_glyph_" + str(glyphCounter) write_postscript_functions(newPath, functionName, writefile) glyphCounter += 1 primitiveCounter = 0 if len(plotList) is not 0: # user info print(str(len(plotList)) + " primitives to plot") for primitive in plotList: primitive = strip_strings_in_list(primitive) functionName = "draw_primitive_" + str(primitiveCounter) write_primitive_postScript(primitive, functionName, writefile) primitiveCounter += 1 if fileName.endswith(".html"): write_html_footer(writefile, rectWidth, rectHeight) # done. writefile.close()