# -*- coding: utf-8 -*- #Copyright (c) 2009, Walter Bender #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #copies of the Software, and to permit persons to whom the Software is #furnished to do so, subject to the following conditions: #The above copyright notice and this permission notice shall be included in #all copies or substantial portions of the Software. #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN #THE SOFTWARE. RED_STROKE = "#FF6040" RED_FILL = "#FFC4B8" BLUE_STROKE = "#0060C8" BLUE_FILL = "#ACC8E4" GREEN_STROKE = "#00B418" GREEN_FILL = "#AFE8A8" PURPLE_STROKE = "#780078" PURPLE_FILL = "#E4AAE4" color_pairs = ([RED_STROKE,RED_FILL], [GREEN_STROKE,GREEN_FILL], [BLUE_STROKE,BLUE_FILL], [PURPLE_STROKE,PURPLE_FILL]) fill_styles = ("none","gradient","solid") card_types = ("X","O","C") def background(f): f.write("\n") def header(f): f.write("\n") f.write("\n") f.write("\n") background(f) f.write("\n") def footer(f): f.write("\n") f.write("\n") def circle(f, y, style, stroke, fill): f.write("\n") elif style == "gradient": f.write(" style=\"fill:" + fill + ";stroke:" + stroke + \ ";stroke-width:1.8;\" />\n") else: f.write(" style=\"fill:" + stroke + ";stroke:" + stroke + \ ";stroke-width:1.8;\" />\n") f.write("\n") def check(f, y, style, stroke, fill): f.write("\n") elif style == "gradient": f.write(" style=\"fill:" + fill + ";stroke:" + stroke + \ ";stroke-width:1.8;\" />\n") else: f.write(" style=\"fill:" + stroke + ";stroke:" + stroke + \ ";stroke-width:1.8;\" />\n") def cross(f, y, style, stroke, fill): f.write("\n") elif style == "gradient": f.write(" style=\"fill:" + fill + ";stroke:" + stroke + \ ";stroke-width:1.8;\" />\n") else: f.write(" style=\"fill:" + stroke + ";stroke:" + stroke + \ ";stroke-width:1.8;\" />\n") def check_card(f, n, style, stroke, fill): if n == 1: check(f, 41.5,style, stroke, fill) elif n == 2: check(f, 21.5,style, stroke, fill) check(f, 61.5,style, stroke, fill) else: check(f, 1.5,style, stroke, fill) check(f, 41.5,style, stroke, fill) check(f, 81.5,style, stroke, fill) def cross_card(f, n, style, stroke, fill): if n == 1: cross(f, 41.5,style, stroke, fill) elif n == 2: cross(f, 21.5,style, stroke, fill) cross(f, 61.5,style, stroke, fill) else: cross(f, 1.5,style, stroke, fill) cross(f, 41.5,style, stroke, fill) cross(f, 81.5,style, stroke, fill) def circle_card(f, n, style, stroke, fill): if n == 1: circle(f, 41.5,style, stroke, fill) elif n == 2: circle(f, 21.5,style, stroke, fill) circle(f, 61.5,style, stroke, fill) else: circle(f, 1.5,style, stroke, fill) circle(f, 41.5,style, stroke, fill) circle(f, 81.5,style, stroke, fill) def open_file(i): return file("images/card-"+str(i)+".svg", "w") def close_file(f): f.close() i = 0 for t in card_types: for c in color_pairs: for n in range(1,4): for s in fill_styles: i += 1 f = open_file(i) header(f) if t == "O": circle_card(f,n,s,c[0],c[1]) elif t == "C": check_card(f,n,s,c[0],c[1]) else: cross_card(f,n,s,c[0],c[1]) footer(f) close_file(f)