Commits

ch...@lee-messer.net  committed 6e35d81

dot game grid, basic done no bottom boxes yet

  • Participants

Comments (0)

Files changed (1)

+# the dot game
+# create a pdf for working on concepts of placeholders, units etc.
+from __future__ import division
+from reportlab.pdfgen import canvas
+from reportlab.lib.pagesizes import *
+import reportlab.lib.colors as colors
+#landscape
+pw,ph = letter
+landscape = ph,pw
+pagesize = landscape
+can = canvas.Canvas("dotgame.pdf", pagesize=landscape)
+
+# create a frame
+p = can.beginPath()
+
+
+p2i = 72.0 # 72pt per inch
+x0, y0 = 0.5*p2i, 0.5*p2i
+w, h = pagesize[0]-p2i, pagesize[1]-p2i
+c,d = x0+w, y0+h
+
+p.moveTo(x0,y0)
+p.lineTo(c, y0)
+p.lineTo(c,d)
+p.lineTo(x0,d)
+#p.lineTo(0,0)
+p.close()
+
+can.drawPath(p)
+
+
+# now try to do the little grids
+
+lgy0 = y0+2.0*p2i
+lgy1 = lgy0 + 4.0*p2i
+dy = (lgy1-lgy0)/10.0
+
+lgx0,lgx1 = x0,c
+can.setLineWidth(0.3)
+#p = can.beginPath()
+#p.moveTo(lgx0, lgy0)
+y = lgy0
+for ii in range(11):
+    can.line(lgx0, y, lgx1, y)
+    y += dy
+    print y
+
+# now do vertical lines
+print "frame width: %f" % w
+
+nplaces = 4
+nbox =40
+print "divide by nplaces and then by 10:", w/nplaces, w/float(nbox)
+boxwid = w/float(nbox)
+
+x = x0
+
+for ii in range(nbox):
+    print x
+    if not ii%10 and x != x0:
+        can.setLineWidth(5.0)
+    can.line(x,lgy0, x,lgy1)
+    if not ii%10:
+        can.setLineWidth(0.3)
+    x+= boxwid
+
+can.setFont('Helvetica', 20)
+x=x0+ 5.0*boxwid
+lgyline = lgy1+3.0
+can.setFillColor(colors.green)
+can.drawCentredString(x, lgyline, "1000")
+x+= 10*boxwid
+can.setFillColor(colors.blue)
+can.drawCentredString(x, lgyline, "100")
+x+= 10*boxwid
+can.setFillColor(colors.red)
+can.drawCentredString(x, lgyline, "10")
+x+= 10*boxwid
+can.setFillColor(colors.green)
+can.drawCentredString(x, lgyline, "1")
+
+
+can.save()