def doit(token): # each token one svg file # create name "generated/token_{0}.svg" # calcTokenValue(front, back) fileName = sys.argv[2].format(token.idno) svgfile = open(fileName, "w") svg = SvgWriter(svgfile) svg.begin() # write symbols svg.beginDefs() writeTokenFront(svg, token) writeTokenBack(svg, token) svg.endDefs() # write drawings svg.file.write('<use xlink:href="#{0}" x="{1}mm" y="{2}mm" width="22mm" height="27mm" />\n'.format(token.idno+'f', 0, 0)) svg.file.write('<use xlink:href="#{0}" x="{1}mm" y="{2}mm" width="22mm" height="27mm" />\n'.format(token.idno+'b', "7", 0)) svg.end() svgfile.close() print("{0}-{1}-{2}-{3}".format(token.idno, token.directions, token.attack, token.defense)) pass
class OverviewContext: outfile = None svg = None x_pos = 1.5 y_pos = 1.5 rows = 0 cols = 0 count = 0 def __init__(self, fileName): self.outfile = open(fileName, "w") self.svg = SvgWriter(self.outfile) self.svg.beginFormat("210mm", "297mm") def __del__(self): self.svg.end() self.outfile.close() def next(self): # width= 22mm height=27mm # calculate the possible elements per column and row for din a4 paper # 10 rows 7 columns currently doesn't make sense self.count += 1 step_x = 8 step_y = 8 self.x_pos += step_x self.cols += 1 if self.x_pos >= 50: self.cols = 0 self.rows += 1 self.x_pos = 1.5 self.y_pos += step_y def write(self, libfile, value): self.svg.file.write( '<use xlink:href="{0}#{1}" x="{2}mm" y="{3}mm" width="22mm" height="27mm" />\n'.format( libfile, value, self.x_pos, self.y_pos ) ) self.next() # possible elements left def space_left(self): return (10 * 7) - self.count
class OverviewContext(): outfile = None svg = None x_pos = 1.5 y_pos = 1.5 rows = 0 cols = 0 count = 0 def __init__(self, fileName): self.outfile = open(fileName, "w") self.svg = SvgWriter(self.outfile) self.svg.beginFormat('210mm', '297mm') def __del__(self): self.svg.end() self.outfile.close() def next(self): # width= 22mm height=27mm # calculate the possible elements per column and row for din a4 paper # 10 rows 7 columns currently doesn't make sense self.count += 1 step_x = 8 step_y = 8 self.x_pos += step_x self.cols += 1 if (self.x_pos >= 50): self.cols = 0 self.rows += 1 self.x_pos = 1.5 self.y_pos += step_y def write(self, libfile, value): self.svg.file.write( '<use xlink:href="{0}#{1}" x="{2}mm" y="{3}mm" width="22mm" height="27mm" />\n' .format(libfile, value, self.x_pos, self.y_pos)) self.next() # possible elements left def space_left(self): return (10 * 7) - self.count
def __init__(self, fileName): self.outfile = open(fileName, "w") self.svg = SvgWriter(self.outfile) self.svg.beginFormat('210mm', '297mm')
import sys import re from lib.SvgWriter import SvgWriter from lib.Token import TokenDB, Token from lib.TokenWriter import writeTokenFront, writeTokenBack if len(sys.argv) < 3: sys.exit("Usage: genLibrary TokenDB.txt SingelView.svg") print("Create svg library...") #start svg file svgfile = open(sys.argv[2], "w") svg = SvgWriter(svgfile) svg.begin() svg.beginDefs() #the function to write the definitions def doit(token): #frontside writeTokenFront(svg, token) #backside writeTokenBack(svg, token) print("{0}-{1}-{2}-{3}".format(token.idno, token.directions, token.attack, token.defense))
def __init__(self, fileName): self.outfile = open(fileName, "w") self.svg = SvgWriter(self.outfile) self.svg.beginFormat("210mm", "297mm")
import sys import re from lib.SvgWriter import SvgWriter from lib.Token import TokenDB, Token from lib.TokenWriter import writeTokenFront, writeTokenBack if len(sys.argv) < 3: sys.exit("Usage: genLibrary TokenDB.txt SingelView.svg") print("Create svg library...") #start svg file svgfile = open(sys.argv[2], "w") svg = SvgWriter(svgfile) svg.begin() svg.beginDefs() #the function to write the definitions def doit(token): #frontside writeTokenFront(svg, token) #backside writeTokenBack(svg, token)