Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/gencards.py
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-12-21 23:52:13 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-12-21 23:52:13 (GMT)
commit7fe1968767b8e49a2b9e1533bfd2cd441a8cdcea (patch)
tree7162d68ef00ca6ad7147a71a3b69f5255db03afe /gencards.py
parente07254d6a4d2275d706cc911636224196bd46ecd (diff)
adding bold and italic to word cards
Diffstat (limited to 'gencards.py')
-rwxr-xr-xgencards.py71
1 files changed, 49 insertions, 22 deletions
diff --git a/gencards.py b/gencards.py
index 10193e4..d04861b 100755
--- a/gencards.py
+++ b/gencards.py
@@ -35,15 +35,15 @@ PURPLE_FILL = "#E4AAE4"
color_pairs = ([RED_STROKE,RED_FILL],
[GREEN_STROKE,GREEN_FILL],
[BLUE_STROKE,BLUE_FILL])
-# [BLUE_STROKE,BLUE_FILL],
-# [PURPLE_STROKE,PURPLE_FILL])
fill_styles = ("none","gradient","solid")
card_types = ("X","O","C")
def background(f,stroke,fill,width):
- f.write("<rect width=\"124.5\" height=\"74.5\" rx=\"11\" ry=\"9\" x=\"0.25\" y=\"0.25\"\n")
- f.write("style=\"fill:" + fill + ";fill-opacity:1;stroke:" + stroke + ";stroke-width:"+width+"\" />\n")
+ f.write("<rect width=\"124.5\" height=\"74.5\" rx=\"11\" ry=\"9\"" +\
+ " x=\"0.25\" y=\"0.25\"\n")
+ f.write("style=\"fill:" + fill + ";fill-opacity:1;stroke:" + stroke + \
+ ";stroke-width:"+width+"\" />\n")
def header(f,stroke,fill,width):
f.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n")
@@ -104,46 +104,54 @@ def die(f, n, x, y, stroke):
f.write(" ry=\"2\"\n")
f.write(" x=\"0\"\n")
f.write(" y=\"0\"\n")
- f.write(" style=\"fill:none;stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:none;stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
if n in [2,3,4,5,6]:
f.write(" <circle\n")
f.write(" cx=\"6\"\n")
f.write(" cy=\"6\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
f.write(" <circle\n")
f.write(" cx=\"19\"\n")
f.write(" cy=\"19\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
if n in [1,3,5]:
f.write(" <circle\n")
f.write(" cx=\"12.5\"\n")
f.write(" cy=\"12.5\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
if n in [4,5,6]:
f.write(" <circle\n")
f.write(" cx=\"19\"\n")
f.write(" cy=\"6\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
f.write(" <circle\n")
f.write(" cx=\"6\"\n")
f.write(" cy=\"19\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
if n in [6]:
f.write(" <circle\n")
f.write(" cx=\"6\"\n")
f.write(" cy=\"12.5\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
f.write(" <circle\n")
f.write(" cx=\"19\"\n")
f.write(" cy=\"12.5\"\n")
f.write(" r=\"1.5\"\n")
- f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+";stroke-width:2;stroke-opacity:1\" />\n")
+ f.write(" style=\"fill:"+str(stroke)+";stroke:"+str(stroke)+\
+ ";stroke-width:2;stroke-opacity:1\" />\n")
f.write(" </g>\n")
def circle(f, x, style, stroke, fill):
@@ -164,7 +172,10 @@ def circle(f, x, style, stroke, fill):
";stroke-width:1.8;\" />\n")
def check(f, x, style, stroke, fill):
- f.write("<path d=\"m 28.3575,70.160499 -5.861,5.861 -5.861,-5.866001 -4.102,-4.1 c -0.747,-0.747999 -1.212,-1.784999 -1.212,-2.93 0,-2.288998 1.854,-4.145998 4.146,-4.145998 1.143,0 2.18,0.465 2.93,1.214 l 4.099,4.101999 14.102,-14.102998 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856001 4.146,4.145001 0,1.146 -0.467,2.18 -1.217,2.932 l -14.104,14.104997 z\"\n")
+ f.write("<path d=\"m 28.4,70.2 -5.9,5.9 -5.9,-5.9 -4.1,-4.1 c -0.7,-0.7" +\
+ " -1.2,-1.8 -1.2,-2.9 0,-2.3 1.9,-4.1 4.1,-4.1 1.1,0 2.2,0.5" +\
+ " 2.9,1.2 l 4.1,4.1 14.1,-14.1 c 0.8,-0.7 1.8,-1.2 2.9,-1.2 2.3,"+\
+ "0 4.1,1.9 4.1,4.1 0,1.1 -0.5,2.2 -1.2,2.9 l -14.1,14.1 z\"\n")
f.write(" transform=\"translate(" + str(x-10) + ", -25)\"\n")
if style == "none":
f.write(" style=\"fill:#FFFFFF;stroke:" + stroke + \
@@ -177,7 +188,13 @@ def check(f, x, style, stroke, fill):
";stroke-width:1.8;\" />\n")
def cross(f, x, style, stroke, fill):
- f.write("<path d=\"m 33.3585,62.5035 10.102,10.1 c 0.752,0.75 1.217,1.783 1.217,2.932 0,2.287 -1.855,4.143 -4.146,4.143 -1.145,0 -2.178,-0.463 -2.932,-1.211 l -10.102,-10.103 -10.1,10.1 c -0.75,0.75 -1.787,1.211 -2.934,1.211 -2.284,0 -4.143,-1.854 -4.143,-4.141 0,-1.146 0.465,-2.184 1.212,-2.934 l 10.104,-10.102 -10.102,-10.1 c -0.747,-0.748 -1.212,-1.785 -1.212,-2.93 0,-2.289 1.854,-4.146 4.146,-4.146 1.143,0 2.18,0.465 2.93,1.214 l 10.099,10.102 10.102,-10.103 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856 4.146,4.145 0,1.146 -0.467,2.18 -1.217,2.932 l -10.104,10.105 z\"\n")
+ f.write("<path d=\"m 33.4,62.5 10.1,10.1 c 0.8,0.8 1.2,1.8 1.2,2.9 0,2.3"+\
+ " -1.9,4.1 -4.1,4.1 -1.1,0 -2.2,-0.5 -2.9,-1.2 l -10.1,-10.1"+\
+ " -10.1,10.1 c -0.8,0.8 -1.8,1.2 -2.9,1.2 -2.3,0 -4.1,-1.9 -4.1,"+\
+ "-4.1 0,-1.1 0.5,-2.2 1.2,-2.9 l 10.1,-10.1 -10.1,-10.1 c -0.7,"+\
+ "-0.7 -1.2,-1.8 -1.2,-2.9 0,-2.3 1.9,-4.1 4.1,-4.1 1.1,0 2.2,"+\
+ "0.5 2.9,1.2 l 10.1,10.1 10.1,-10.1 c 0.8,-0.7 1.8,-1.2 2.9,-1.2"+\
+ " 2.3,0 4.1,1.9 4.1,4.1 0,1.1 -0.5,2.2 -1.2,2.9 l -10.1,10.1 z\"\n")
f.write(" transform=\"translate(" + str(x-10) + ", -25)\"\n")
if style == "none":
f.write(" style=\"fill:#FFFFFF;stroke:" + stroke + \
@@ -224,7 +241,9 @@ def circle_card(f, n, style, stroke, fill):
def number(f, x, string, stroke):
f.write(" <text\n")
- f.write(" style=\"font-size:12px;text-anchor:middle;text-align:center;font-family:Bitstream Vera Sans;fill:"+stroke+"\">\n")
+ f.write(" style=\"font-size:12px;text-anchor:middle;"+\
+ "text-align:center;font-family:Bitstream Vera Sans;fill:"+\
+ stroke+"\">\n")
f.write(" <tspan\n")
f.write(" x=\""+str(x)+"\"\n")
f.write(" y=\"55.25\"\n")
@@ -277,17 +296,24 @@ def number_card(f, t, n, stroke):
else:
dots(f, n, 5, 5, stroke)
-def word(f, x, string, stroke):
+def word(f, x, string, stroke,style):
f.write(" <text\n")
- f.write(" style=\"font-size:12px;text-anchor:middle;text-align:center;font-family:Bitstream Vera Sans;fill:"+stroke+"\">\n")
+ f.write(" style=\"font-size:12px;text-anchor:middle;"+style+\
+ "text-align:center;font-family:Bitstream Vera Sans;fill:"+\
+ stroke+"\">\n")
f.write(" <tspan\n")
f.write(" x=\""+str(x)+"\"\n")
f.write(" y=\"45.25\"\n")
f.write(" style=\"font-size:30px;\">"+string+"</tspan>\n")
f.write(" </text>")
-def word_card(f, s, string, stroke):
- word(f, 63.5, string[s], stroke)
+def word_card(f, t, s, string, stroke):
+ if t == 'X':
+ word(f, 63.5, string[s], stroke, "font-weight:bold;")
+ elif t == 'O':
+ word(f, 63.5, string[s], stroke, "font-style:italic;")
+ else:
+ word(f, 63.5, string[s], stroke, "")
def open_file(datapath, filename):
return file(os.path.join(datapath, filename), "w")
@@ -339,11 +365,12 @@ def generator(datapath):
f = open_file(datapath, filename)
header(f,"#000000",c[1],"0.5")
if n == 0:
- word_card(f,s,[_("dog"),_("cat"),_("mouse")],c[0])
+ word_card(f,t,s,[_("dog"),_("cat"),_("mouse")],c[0])
elif n == 1:
- word_card(f,s,[_("apple"),_("bread"),_("cheese")],c[0])
+ word_card(f,t,s,[_("apple"),_("bread"),_("cheese")],
+ c[0])
else:
- word_card(f,s,[_("sun"),_("moon"),_("earth")],c[0])
+ word_card(f,t,s,[_("sun"),_("moon"),_("earth")],c[0])
footer(f)
close_file(f)
i += 1