From 15a05eea4575e8b8a8ecd6dccbddfdf36403a104 Mon Sep 17 00:00:00 2001 From: stuphi Date: Thu, 13 Nov 2014 21:49:22 +0000 Subject: [PATCH] Add 45deg alignement grid to svg sheets to aid posterprint layout --- svg.py | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/svg.py b/svg.py index fb162848..040e9a2a 100755 --- a/svg.py +++ b/svg.py @@ -1,4 +1,3 @@ -## {{{ http://code.activestate.com/recipes/325823/ (r1) #!/usr/bin/env python """\ SVG.py - Construct/display SVG scenes. @@ -23,8 +22,12 @@ def add(self,item): self.items.append(item) def strarray(self): var = ["\n", '\n' % (self.height,self.width), - ' \n' + ' \n' ] + grid = Grid(self.width,self.height) + var += grid.strarray() + var += [" \n", + ' \n'] for item in self.items: var += item.strarray() var += [" \n\n"] return var @@ -43,6 +46,34 @@ def display(self): os.system("%s" % (self.svgname)) return +class Grid: + def __init__(self,width,height,spacing=20): + self.width = width + self.height = height + return + def strarray(self): + w = self.width + h = self.height + return [' \n' % + (0,0,w,h), + ' \n' % + (0,h,w,0), + ' \n' % + (0,h*0.3333,w*0.3333,0), + ' \n' % + (0,h*0.6667,w*0.6667,0), + ' \n' % + (0,h*0.3333,w*0.6667,h), + ' \n' % + (0,h*0.6667,w*0.3333,h), + ' \n' % + (w*0.3333,h,w,h*0.3333), + ' \n' % + (w*0.3333,0,w,h*0.6667), + ' \n' % + (w*0.6667,0,w,h*0.3333), + ' \n' % + (w*0.6667,h,w,h*0.6667)] class Line: def __init__(self,start,end): @@ -108,5 +139,5 @@ def test(): scene.display() return -if __name__ == '__main__': test() -## end of http://code.activestate.com/recipes/325823/ }}} +if __name__ == '__main__': + test()