'''
Copyright (C) 2007 Terry Brown, terry_n_brown@yahoo.com
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'''
import inkex
import sys
try:
except:
try:
except:
try:
except:
in Python 2.5 or supplied by lxml or elementtree modules.
""")
('', '--rows', 'int', 'rows', '2', ''),
('', '--cols', 'int', 'cols', '2', ''),
('', '--paddingTop', 'string', 'paddingTop', '', ''),
('', '--paddingBottom', 'string', 'paddingBottom', '', ''),
('', '--paddingLeft', 'string', 'paddingLeft', '', ''),
('', '--paddingRight', 'string', 'paddingRight', '', ''),
('', '--marginTop', 'string', 'marginTop', '', ''),
('', '--marginBottom', 'string', 'marginBottom', '', ''),
('', '--marginLeft', 'string', 'marginLeft', '', ''),
('', '--marginRight', 'string', 'marginRight', '', ''),
('', '--pgSizeX', 'string', 'pgSizeX', '', ''),
('', '--pgSizeY', 'string', 'pgSizeY', '', ''),
('', '--sizeX', 'string', 'sizeX', '', ''),
('', '--sizeY', 'string', 'sizeY', '', ''),
('', '--pgMarginTop', 'string', 'pgMarginTop', '', ''),
('', '--pgMarginBottom', 'string', 'pgMarginBottom', '', ''),
('', '--pgMarginLeft', 'string', 'pgMarginLeft', '', ''),
('', '--pgMarginRight', 'string', 'pgMarginRight', '', ''),
('', '--tab', 'string', 'tab', '', ''),
]
for o in opts:
showList = []
for i in ['showHolder','showCrosses','showInner','showOuter',
'showInnerBox','showOuterBox',]:
)
try:
iter(x)
except:
return None
raise Exception("expandTuple: requires 2 or 4 item tuple")
try:
except:
return None
unit="px",
size=None,
show=['default'],
container='svg',
returnTree = False,
):
"""Generate the SVG. Inputs are run through 'eval(str(x))' so you can use
'8.5*72' instead of 612. Margin / padding dimension tuples can be
(top & bottom, left & right) or (top, right, bottom, left).
Keyword arguments:
pgSize -- page size, width x height
pgMargin -- extra space around each page
pgPadding -- added to pgMargin
n -- rows x cols
size -- override calculated size, width x height
margin -- white space around each piece
padding -- inner padding for each piece
show -- list of keywords indicating what to show
- 'crosses' - cutting guides
- 'inner' - inner boundary
- 'outer' - outer boundary
container -- 'svg' or 'g'
returnTree -- whether to return the ElementTree or the string
"""
if 'default' in show:
# num = tuple(map(lambda ev: eval(str(ev)), num))
)
else:
# sep is separation between same points on pieces
style = 'stroke:#000000;stroke-opacity:1;fill:none;fill-opacity:1;'
padbox = 'rect', {
'style': style,
}
margbox = 'rect', {
'style': style,
}
{'xmlns:inkscape':"http://www.inkscape.org/namespaces/inkscape",
'xmlns:xlink':"http://www.w3.org/1999/xlink",
}))
if r == 0 and c == 0: continue
'transform': 'translate(%f,%f)' %
# guidelayer #####################################################
'inkscape:groupmode':'layer'})
if 'inner' in show:
'stroke:#8080ff')
'stroke:#000000')
if 'outer' in show:
'stroke:#8080ff')
'stroke:#000000')
# crosslayer #####################################################
'inkscape:groupmode':'layer'})
if 'crosses' in show:
crosslen = 12
x,y = 0,0
for r in 0, 1:
for c in 0, 1:
if r or c:
'xlink:href': '#crossmarker',
'transform': 'translate(%f,%f)' %
(x,y)})
# clonelayer #####################################################
# mainlayer ######################################################
if 'innerbox' in show:
if 'outerbox' in show:
if 'holder' in show:
path += ' Z'
if returnTree:
return doc
else:
e = Nup()
e.affect()