#!/usr/bin/env python #Copyright (c) 2009,10 Walter Bender # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. import os from constants import C XCOR = ["-188.17646", "11.823541"] YCOR = ["162.71119", "362.71119"] def _svg_header(): """ the common header every card shares """ a = '\n' b = '\n' c = '\n' return a + b def _svg_lower_right(color): """ draw an arc in the upper right quadrant """ a = _svg_circle(XCOR[0], YCOR[1]) b = ' style="fill:' + color + ';fill-opacity:1;fill-rule:nonzero;stroke:none" />\n' return a + b def _svg_upper_left(color): """ draw an arc in the upper right quadrant """ a = _svg_circle(XCOR[1], YCOR[0]) b = ' style="fill:' + color + ';fill-opacity:1;fill-rule:nonzero;stroke:none" />\n' return a + b def _svg_lower_left(color): """ draw an arc in the upper right quadrant """ a = _svg_circle(XCOR[1], YCOR[1]) b = ' style="fill:' + color + ';fill-opacity:1;fill-rule:nonzero;stroke:none" />\n' return a + b def _svg_footer(): """ A common footer """ a = ' \n' b = '\n' return a + b def open_file(datapath, filename): """ Create a file for writing """ return file(os.path.join(datapath, filename), "w") def generator(datapath): """ Make all of the cards """ for i, c in enumerate(C): f = open_file(datapath, "card-%d.svg" % (i)) svg = _svg_header() svg += _svg_upper_left(c[0]) svg += _svg_lower_left(c[1]) svg += _svg_lower_right(c[2]) svg += _svg_upper_right(c[3]) svg += _svg_footer() f.write(svg) f.close() def main(): """ Command line version for testing """ return 0 if __name__ == "__main__": if not os.path.exists(os.path.join(os.path.abspath('.'), 'images')): os.mkdir(os.path.join(os.path.abspath('.'), 'images')) generator(os.path.join(os.path.abspath('.'), 'images')) main()