Merge lp:~cafuego/inkscape/guides-creator-2.31-1k into lp:~inkscape.dev/inkscape/trunk

Proposed by Cafuego
Status: Merged
Merged at revision: 12404
Proposed branch: lp:~cafuego/inkscape/guides-creator-2.31-1k
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 677 lines (+421/-117)
2 files modified
share/extensions/guides_creator.inx (+83/-34)
share/extensions/guides_creator.py (+338/-83)
To merge this branch: bzr merge lp:~cafuego/inkscape/guides-creator-2.31-1k
Reviewer Review Type Date Requested Status
Martin Owens full review Approve
Review via email: mp+59606@code.launchpad.net

Description of the change

Please read https://code.launchpad.net/~cafuego/inkscape/guides-creator-1k/+merge/20332

This branch supersedes that merge request. It includes the latest upstream guides creator (version 2.31) with the guides limit raised back from 100 to 1000.

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

The code looks good and the extension functions as I would expect. I'm merging this code now.

review: Approve (full review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'share/extensions/guides_creator.inx'
2--- share/extensions/guides_creator.inx 2010-09-08 18:33:09 +0000
3+++ share/extensions/guides_creator.inx 2011-05-01 02:40:57 +0000
4@@ -1,44 +1,93 @@
5-<?xml version="1.0" encoding="UTF-8"?>
6-<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
7+<inkscape-extension>
8 <_name>Guides creator</_name>
9 <id>org.inkscape.effect.guidescreator</id>
10 <dependency type="executable" location="extensions">guides_creator.py</dependency>
11 <dependency type="executable" location="extensions">inkex.py</dependency>
12- <param name="preset" type="enum" _gui-text="Preset:">
13- <_item value="custom">Custom...</_item>
14- <_item value="golden">Golden ratio</_item>
15- <_item value="3;3">Rule-of-third</_item>
16- </param>
17- <param name="vertical_guides" type="enum" _gui-text="Vertical guide each:">
18- <_item value="0">None</_item>
19- <_item value="2">1/2</_item>
20- <_item value="3">1/3</_item>
21- <_item value="4">1/4</_item>
22- <_item value="5">1/5</_item>
23- <_item value="6">1/6</_item>
24- <_item value="7">1/7</_item>
25- <_item value="8">1/8</_item>
26- <_item value="9">1/9</_item>
27- <_item value="10">1/10</_item>
28- </param>
29- <param name="horizontal_guides" type="enum" _gui-text="Horizontal guide each:">
30- <_item value="0">None</_item>
31- <_item value="2">1/2</_item>
32- <_item value="3">1/3</_item>
33- <_item value="4">1/4</_item>
34- <_item value="5">1/5</_item>
35- <_item value="6">1/6</_item>
36- <_item value="7">1/7</_item>
37- <_item value="8">1/8</_item>
38- <_item value="9">1/9</_item>
39- <_item value="10">1/10</_item>
40- </param>
41- <param name="start_from_edges" type="boolean" _gui-text="Start from edges">false</param>
42- <param name="delete_existing_guides" type="boolean" _gui-text="Delete existing guides">false</param>
43+ <param name="tab" type="notebook">
44+ <page name="regular_guides" _gui-text="Regular guides">
45+ <param name="guides_preset" type="enum" appearance="minimal" _gui-text="Guides preset">
46+ <item value="custom">Custom...</item>
47+ <item value="golden">Golden ratio</item>
48+ <item value="3;3">Rule-of-third</item>
49+ </param>
50+ <param name="vertical_guides" type="int" min="1" max="1000" _gui-text="Columns">2</param>
51+ <param name="horizontal_guides" type="int" min="1" max="1000" _gui-text="Rows">3</param>
52+ <param name="start_from_edges" type="boolean" _gui-text="Start from edges">false</param>
53+ <param name="delete_existing_guides" type="boolean" _gui-text="Delete existing guides">false</param>
54+ </page>
55+ <page name="diagonal_guides" _gui-text="Diagonal guides">
56+ <param name="ul" type="boolean" _gui-text="Upper left corner">false</param>
57+ <param name="ur" type="boolean" _gui-text="Upper right corner">false</param>
58+ <param name="ll" type="boolean" _gui-text="Lower left corner">false</param>
59+ <param name="lr" type="boolean" _gui-text="Lower right corner">false</param>
60+ <param name="delete_existing_guides2" type="boolean" _gui-text="Delete existing guides">false</param>
61+ </page>
62+ <page name="margins" _gui-text="Margins">
63+ <param name="margins_preset" type="enum" appearance="minimal" _gui-text="Margins preset">
64+ <item value="custom">Custom...</item>
65+ <item value="book_left">Left book page</item>
66+ <item value="book_right">Right book page</item>
67+ </param>
68+ <param name="header_margin" type="enum" appearance="minimal" _gui-text="Header margin">
69+ <item value="10">1/10</item>
70+ <item value="9">1/9</item>
71+ <item value="8">1/8</item>
72+ <item value="7">1/7</item>
73+ <item value="6">1/6</item>
74+ <item value="5">1/5</item>
75+ <item value="4">1/4</item>
76+ <item value="3">1/3</item>
77+ <item value="2">1/2</item>
78+ <item value="0">None</item>
79+ </param>
80+ <param name="footer_margin" type="enum" appearance="minimal" _gui-text="Footer margin">
81+ <item value="10">1/10</item>
82+ <item value="9">1/9</item>
83+ <item value="8">1/8</item>
84+ <item value="7">1/7</item>
85+ <item value="6">1/6</item>
86+ <item value="5">1/5</item>
87+ <item value="4">1/4</item>
88+ <item value="3">1/3</item>
89+ <item value="2">1/2</item>
90+ <item value="0">None</item>
91+ </param>
92+ <param name="left_margin" type="enum" appearance="minimal" _gui-text="Left margin">
93+ <item value="10">1/10</item>
94+ <item value="9">1/9</item>
95+ <item value="8">1/8</item>
96+ <item value="7">1/7</item>
97+ <item value="6">1/6</item>
98+ <item value="5">1/5</item>
99+ <item value="4">1/4</item>
100+ <item value="3">1/3</item>
101+ <item value="2">1/2</item>
102+ <item value="0">None</item>
103+ </param>
104+ <param name="right_margin" type="enum" appearance="minimal" _gui-text="Right margin">
105+ <item value="10">1/10</item>
106+ <item value="9">1/9</item>
107+ <item value="8">1/8</item>
108+ <item value="7">1/7</item>
109+ <item value="6">1/6</item>
110+ <item value="5">1/5</item>
111+ <item value="4">1/4</item>
112+ <item value="3">1/3</item>
113+ <item value="2">1/2</item>
114+ <item value="0">None</item>
115+ </param>
116+
117+ <param name="vertical_subdivisions" type="int" min="1" max="1000" _gui-text="Columns">2</param>
118+ <param name="horizontal_subdivisions" type="int" min="1" max="1000" _gui-text="Rows">3</param>
119+ <param name="start_from_edges2" type="boolean" _gui-text="Start from edges">false</param>
120+ <param name="delete_existing_guides3" type="boolean" _gui-text="Delete existing guides">false</param>
121+
122+ </page>
123+ </param>
124 <effect>
125 <object-type>all</object-type>
126 <effects-menu>
127- <submenu _name="Render"/>
128+ <submenu _name="Guides"/>
129 </effects-menu>
130 </effect>
131 <script>
132
133=== modified file 'share/extensions/guides_creator.py'
134--- share/extensions/guides_creator.py 2009-04-13 20:05:53 +0000
135+++ share/extensions/guides_creator.py 2011-05-01 02:40:57 +0000
136@@ -1,18 +1,22 @@
137 #!/usr/bin/env python
138 '''
139-Guides Creator v2.0 (25/11/2008)
140+Guides Creator v2.31 (05/07/2009)
141 http://code.google.com/p/inkscape-guides-creator/
142
143 Copyright (C) 2008 Jonas Termeau - jonas.termeau **AT** gmail.com
144
145-Thanks to Bernard Gray - bernard.gray **AT** gmail.com
146+Thanks to:
147+
148+Bernard Gray - bernard.gray **AT** gmail.com (python helping)
149+Jamie Heames (english translation issues)
150+~suv (bug report in v2.3)
151+http://www.gutenberg.eu.org/publications/ (9x9 margins settings)
152
153 ## This basic extension allows you to automatically draw guides in inkscape.
154
155 This program is free software; you can redistribute it and/or modify
156 it under the terms of the GNU General Public License as published by
157-the Free Software Foundation; either version 2 of the License, or
158-(at your option) any later version.
159+the Free Software Foundation; version 2 of the License.
160
161 This program is distributed in the hope that it will be useful,
162 but WITHOUT ANY WARRANTY; without even the implied warranty of
163@@ -24,7 +28,7 @@
164 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
165 '''
166
167-# inspired by hello_world turorial by Blackhex and Rubikcube
168+# Inspired by hello_world turorial by Blackhex and Rubikcube
169 # (http://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial)
170
171 # Making an .INX file : http://wiki.inkscape.org/wiki/index.php/MakingAnINX
172@@ -32,7 +36,6 @@
173
174 # # # # # # # #
175 # TODO: See http://code.google.com/p/inkscape-guides-creator/wiki/Roadmap
176-#
177 # # # # # # # #
178
179
180@@ -49,17 +52,19 @@
181
182 from xml.etree import ElementTree as ET
183
184-# for golden number formulae
185+# for golden number formula and diagonal guides
186 from math import sqrt
187+from math import cos
188+from math import sin
189
190 # for printing debugging output
191 import gettext
192 _ = gettext.gettext
193
194 def printDebug(string):
195- inkex.errormsg(_(string))
196+ inkex.errormsg(_(str(string)))
197
198-def drawVerticalGuides(division,w,h,edges,parent):
199+def drawVerticalGuides(division,w,h,edges,parent,vertical_shift=0):
200 if (division > 0):
201 if (edges):
202 var = 1
203@@ -68,12 +73,12 @@
204
205 for v in range(0,division-1+2*var):
206 # setting up the guide's attributes (id is generated automatically)
207- position = str(round((w / division) + (v - var) * (w / division),4)) + ",0"
208+ position = str(round((w / division) + (v - var) * (w / division) + vertical_shift,4)) + ",0"
209 orientation = str(round(h,4)) + ",0"
210
211 createGuide(position,orientation,parent)
212
213-def drawHorizontalGuides(division,w,h,edges,parent):
214+def drawHorizontalGuides(division,w,h,edges,parent,horizontal_shift=0):
215 if (division > 0):
216 if (edges):
217 var = 1
218@@ -82,9 +87,9 @@
219
220 for x in range(0,division-1+2*var):
221 # setting up the guide's attributes (id is generated automatically)
222- position = "0," + str(round((h / division) + (x - var) * (h / division),4))
223+ position = "0," + str(round((h / division) + (x - var) * (h / division) + horizontal_shift,4))
224 orientation = "0," + str(round(w,4))
225-
226+
227 createGuide(position,orientation,parent)
228
229 def createGuide(position,orientation,parent):
230@@ -96,7 +101,6 @@
231 def getVerticalDivisionsFromPreset(preset):
232 # take a "string1;string2" preset
233 # and return "string1"
234-
235 str_array = preset.split(';')
236 result = int(str_array[0])
237
238@@ -105,12 +109,22 @@
239 def getHorizontalDivisionsFromPreset(preset):
240 # take a "string1;string2" preset
241 # and return "string2"
242-
243 str_array = preset.split(';')
244 result = int(str_array[1])
245
246 return result
247
248+def deleteAllGuides(document):
249+ # getting the parent's tag of the guides
250+ nv = document.xpath('/svg:svg/sodipodi:namedview',namespaces=inkex.NSS)[0]
251+
252+ # getting all the guides
253+ children = document.xpath('/svg:svg/sodipodi:namedview/sodipodi:guide',namespaces=inkex.NSS)
254+
255+ # removing each guides
256+ for element in children:
257+ nv.remove(element)
258+
259 class Guides_Creator(inkex.Effect):
260
261 def __init__(self):
262@@ -121,10 +135,16 @@
263 # Call the base class constructor.
264 inkex.Effect.__init__(self)
265
266+ # Define option for the tab.
267+ self.OptionParser.add_option("--tab",
268+ action="store",type="string",
269+ dest="tab", default="regular_guides",
270+ help="")
271+
272 # Define string option "--preset" with default value 'custom'.
273- self.OptionParser.add_option('--preset',
274+ self.OptionParser.add_option('--guides_preset',
275 action = 'store',type = 'string',
276- dest = 'preset',default = 'custom',
277+ dest = 'guides_preset',default = 'custom',
278 help = 'Preset')
279
280 # Define string option "--vertical_guides" with default value '0'.
281@@ -139,95 +159,330 @@
282 dest = 'horizontal_guides',default = 0,
283 help = 'Horizontal guides each:')
284
285- # Define string option "--start_from_edges" with default value False.
286+ # Define boolean option "--start_from_edges" with default value False.
287 self.OptionParser.add_option('--start_from_edges',
288 action = 'store',type = 'inkbool',
289 dest = 'start_from_edges',default = False,
290 help = 'Start from edges')
291
292- # Define string option "--delete_existing_guides" with default value False.
293+ # Define boolean option "--delete_existing_guides" with default value False.
294 self.OptionParser.add_option('--delete_existing_guides',
295 action = 'store',type = 'inkbool',
296 dest = 'delete_existing_guides',default = False,
297 help = 'Delete existing guides')
298+
299+ # Define boolean option "--upper_left_corner" with default value False.
300+ self.OptionParser.add_option('--ul',
301+ action = 'store',type = 'inkbool',
302+ dest = 'ul',default = False,
303+ help = 'Upper left corner')
304+
305+ # Define boolean option "--upper_right_corner" with default value False.
306+ self.OptionParser.add_option('--ur',
307+ action = 'store',type = 'inkbool',
308+ dest = 'ur',default = False,
309+ help = 'Upper right corner')
310+
311+ # Define boolean option "--lower_left_corner" with default value False.
312+ self.OptionParser.add_option('--ll',
313+ action = 'store',type = 'inkbool',
314+ dest = 'll',default = False,
315+ help = 'Lower left corner')
316+
317+ # Define boolean option "--upper_left_corner" with default value False.
318+ self.OptionParser.add_option('--lr',
319+ action = 'store',type = 'inkbool',
320+ dest = 'lr',default = False,
321+ help = 'Lower right corner')
322+
323+ # Define boolean option "--delete_existing_guides2" with default value False.
324+ self.OptionParser.add_option('--delete_existing_guides2',
325+ action = 'store',type = 'inkbool',
326+ dest = 'delete_existing_guides2',default = False,
327+ help = 'Delete existing guides')
328+
329+ # Define string option "--margins_preset" with default value 'custom'.
330+ self.OptionParser.add_option('--margins_preset',
331+ action = 'store',type = 'string',
332+ dest = 'margins_preset',default = 'custom',
333+ help = 'Margins preset')
334+
335+ # Define boolean option "--delete_existing_guides3" with default value False.
336+ self.OptionParser.add_option('--delete_existing_guides3',
337+ action = 'store',type = 'inkbool',
338+ dest = 'delete_existing_guides3',default = False,
339+ help = 'Delete existing guides')
340+
341+ # Define string option "--vertical_subdivisions" with default value '0'.
342+ self.OptionParser.add_option('--vertical_subdivisions',
343+ action = 'store',type = 'string',
344+ dest = 'vertical_subdivisions',default = 0,
345+ help = 'Vertical subdivisions')
346+
347+ # Define string option "--horizontal_subdivisions" with default value '0'.
348+ self.OptionParser.add_option('--horizontal_subdivisions',
349+ action = 'store',type = 'string',
350+ dest = 'horizontal_subdivisions',default = 0,
351+ help = 'Horizontal subdivisions')
352+
353+ # Define string option "--header_margin" with default value '6'.
354+ self.OptionParser.add_option('--header_margin',
355+ action = 'store',type = 'string',
356+ dest = 'header_margin',default = 6,
357+ help = 'Header margin')
358+
359+ # Define string option "--footer_margin" with default value '6'.
360+ self.OptionParser.add_option('--footer_margin',
361+ action = 'store',type = 'string',
362+ dest = 'footer_margin',default = 6,
363+ help = 'Footer margin')
364+
365+ # Define string option "--left_margin" with default value '6'.
366+ self.OptionParser.add_option('--left_margin',
367+ action = 'store',type = 'string',
368+ dest = 'left_margin',default = 6,
369+ help = 'Left margin')
370+
371+ # Define string option "--right_margin" with default value '6'.
372+ self.OptionParser.add_option('--right_margin',
373+ action = 'store',type = 'string',
374+ dest = 'right_margin',default = 6,
375+ help = 'Right margin')
376+
377+ # Define boolean option "--start_from_edges2" with default value False.
378+ self.OptionParser.add_option('--start_from_edges2',
379+ action = 'store',type = 'inkbool',
380+ dest = 'start_from_edges2',default = False,
381+ help = 'Start from edges')
382
383 def effect(self):
384
385 # Get script's options value.
386+
387+ tab = self.options.tab
388+
389+ # first tab
390+ guides_preset = self.options.guides_preset
391+ h_division = int(self.options.horizontal_guides)
392+ v_division = int(self.options.vertical_guides)
393 from_edges = self.options.start_from_edges
394 delete_existing = self.options.delete_existing_guides
395- h_division = int(self.options.horizontal_guides)
396- v_division = int(self.options.vertical_guides)
397- preset = self.options.preset
398-
399- # Get access to main SVG document element and get its dimensions.
400+
401+ # second tab
402+ upper_left = self.options.ul
403+ upper_right = self.options.ur
404+ lower_left = self.options.ll
405+ lower_right = self.options.lr
406+ delete_existing2 = self.options.delete_existing_guides2
407+
408+ # third tab
409+ margins_preset = self.options.margins_preset
410+ header_margin = int(self.options.header_margin)
411+ footer_margin = int(self.options.footer_margin)
412+ left_margin = int(self.options.left_margin)
413+ right_margin = int(self.options.right_margin)
414+ h_subdiv = int(self.options.horizontal_subdivisions)
415+ v_subdiv = int(self.options.vertical_subdivisions)
416+ from_edges2 = self.options.start_from_edges2
417+ delete_existing3 = self.options.delete_existing_guides3
418+
419+ # getting the main SVG document element (canvas)
420 svg = self.document.getroot()
421
422 # getting the width and height attributes of the canvas
423 width = inkex.unittouu(svg.get('width'))
424 height = inkex.unittouu(svg.attrib['height'])
425
426- # getting the parent tag of the guide
427+ # getting edges coordinates
428+ h_orientation = '0,' + str(round(width,4))
429+ v_orientation = str(round(height,4)) + ',0'
430+
431+ # getting parent tag of the guides
432 nv = self.document.xpath('/svg:svg/sodipodi:namedview',namespaces=inkex.NSS)[0]
433
434- if (delete_existing):
435- # getting all the guides
436- children = self.document.xpath('/svg:svg/sodipodi:namedview/sodipodi:guide',namespaces=inkex.NSS)
437-
438- # removing each guides
439- for element in children:
440- nv.remove(element)
441-
442- if (preset == 'custom'):
443-
444- # creating vertical guides
445- drawVerticalGuides(v_division,width,height,from_edges,nv)
446+ if (tab == "\"regular_guides\""):
447+
448+ if (delete_existing):
449+ deleteAllGuides(self.document)
450+
451+ if (guides_preset == 'custom'):
452+
453+ if ((v_division == 0) and (from_edges)):
454+ v_division = 1
455+
456+ if ((h_division == 0) and (from_edges)):
457+ h_division = 1
458+
459+ # creating vertical guides
460+ drawVerticalGuides(v_division,width,height,from_edges,nv)
461+
462+ # creating horizontal guides
463+ drawHorizontalGuides(h_division,width,height,from_edges,nv)
464+
465+ elif (guides_preset == 'golden'):
466+
467+ gold = (1 + sqrt(5)) / 2
468
469- # creating horizontal guides
470- drawHorizontalGuides(h_division,width,height,from_edges,nv)
471-
472- elif (preset == 'golden'):
473-
474- gold = (1 + sqrt(5)) / 2
475-
476- # horizontal golden guides
477- position1 = '0,' + str(height / gold)
478- position2 = '0,'+ str(height - (height / gold))
479- h_orientation = '0,' + str(round(width,4))
480-
481- createGuide(position1,h_orientation,nv)
482- createGuide(position2,h_orientation,nv)
483-
484- # vertical golden guides
485- position1 = str(width / gold) + ',0'
486- position2 = str(width - (width / gold)) + ',0'
487- v_orientation = str(round(height,4)) + ',0'
488-
489- createGuide(position1,v_orientation,nv)
490- createGuide(position2,v_orientation,nv)
491-
492- if (from_edges):
493- # horizontal borders
494- createGuide('0,' + str(height),h_orientation,nv)
495- createGuide(str(height) + ',0',h_orientation,nv)
496-
497- # horizontal borders
498- createGuide('0,' + str(width),v_orientation,nv)
499- createGuide(str(width) + ',0',v_orientation,nv)
500-
501-
502- else:
503-
504- v_division = getVerticalDivisionsFromPreset(preset)
505- h_division = getHorizontalDivisionsFromPreset(preset)
506-
507- drawVerticalGuides(v_division,width,height,from_edges,nv)
508- drawHorizontalGuides(h_division,width,height,from_edges,nv)
509-
510-
511-if __name__ == '__main__': #pragma: no cover
512- # Create effect instance and apply it.
513- effect = Guides_Creator()
514- effect.affect()
515+ # horizontal golden guides
516+ position1 = '0,' + str(height / gold)
517+ position2 = '0,'+ str(height - (height / gold))
518+
519+ createGuide(position1,h_orientation,nv)
520+ createGuide(position2,h_orientation,nv)
521+
522+ # vertical golden guides
523+ position1 = str(width / gold) + ',0'
524+ position2 = str(width - (width / gold)) + ',0'
525+
526+ createGuide(position1,v_orientation,nv)
527+ createGuide(position2,v_orientation,nv)
528+
529+ if (from_edges):
530+ # horizontal borders
531+ createGuide('0,' + str(height),h_orientation,nv)
532+ createGuide(str(height) + ',0',h_orientation,nv)
533+
534+ # vertical borders
535+ createGuide('0,' + str(width),v_orientation,nv)
536+ createGuide(str(width) + ',0',v_orientation,nv)
537+
538+
539+ else:
540+
541+ v_division = getVerticalDivisionsFromPreset(guides_preset)
542+ h_division = getHorizontalDivisionsFromPreset(guides_preset)
543+
544+ drawVerticalGuides(v_division,width,height,from_edges,nv)
545+ drawHorizontalGuides(h_division,width,height,from_edges,nv)
546+
547+ elif (tab == "\"diagonal_guides\""):
548+
549+ if (delete_existing2):
550+ deleteAllGuides(self.document)
551+
552+ # diagonal
553+ angle = 45
554+
555+ # X axe
556+ left = 0
557+ right = width
558+
559+ # Y axe
560+ down = 0
561+ up = height
562+
563+ ul_corner = str(up) + ',' + str(left)
564+ ur_corner = str(right) + ',' + str(up)
565+ ll_corner = str(down) + ',' + str(left)
566+ lr_corner = str(down) + ',' + str(right)
567+
568+ from_ul_to_lr = str(cos(angle)) + ',' + str(cos(angle))
569+ from_ur_to_ll = str(-sin(angle)) + ',' + str(sin(angle))
570+ from_ll_to_ur = str(-cos(angle)) + ',' + str(cos(angle))
571+ from_lr_to_ul = str(-sin(angle)) + ',' + str(-sin(angle))
572+
573+ if (upper_left):
574+ createGuide(ul_corner,from_ul_to_lr,nv)
575+
576+ if (upper_right):
577+ createGuide(ur_corner,from_ur_to_ll,nv)
578+
579+ if (lower_left):
580+ createGuide(ll_corner,from_ll_to_ur,nv)
581+ if (lower_right):
582+ createGuide(lr_corner,from_lr_to_ul,nv)
583+
584+ elif (tab == "\"margins\""):
585+
586+ if (delete_existing3):
587+ deleteAllGuides(self.document)
588+
589+ if (from_edges2):
590+
591+ # horizontal borders
592+ createGuide('0,' + str(height),h_orientation,nv)
593+ createGuide(str(height) + ',0',h_orientation,nv)
594+
595+ # vertical borders
596+ createGuide('0,' + str(width),v_orientation,nv)
597+ createGuide(str(width) + ',0',v_orientation,nv)
598+
599+ if (margins_preset == 'custom'):
600+
601+ y_header = height
602+ y_footer = 0
603+ x_left = 0
604+ x_right = width
605+
606+ if (header_margin != 0):
607+ y_header = (height / header_margin) * (header_margin - 1)
608+ createGuide('0,' + str(y_header),h_orientation,nv)
609+
610+ if (footer_margin != 0):
611+ y_footer = height / footer_margin
612+ createGuide('0,' + str(y_footer),h_orientation,nv)
613+
614+ if (left_margin != 0):
615+ x_left = width / left_margin
616+ createGuide(str(x_left) + ',0',v_orientation,nv)
617+
618+ if (right_margin != 0):
619+ x_right = (width / right_margin) * (right_margin - 1)
620+ createGuide(str(x_right) + ',0',v_orientation,nv)
621+
622+ elif (margins_preset == 'book_left'):
623+ # 1/9th header
624+ y_header = (height / 9) * 8
625+ createGuide('0,' + str(y_header),h_orientation,nv)
626+
627+ # 2/9th footer
628+ y_footer = (height / 9) * 2
629+ createGuide('0,' + str(y_footer),h_orientation,nv)
630+
631+ # 2/9th left margin
632+ x_left = (width / 9) * 2
633+ createGuide(str(x_left) + ',0',v_orientation,nv)
634+
635+ # 1/9th right margin
636+ x_right = (width / 9) * 8
637+ createGuide(str(x_right) + ',0',v_orientation,nv)
638+
639+ elif (margins_preset == 'book_right'):
640+ # 1/9th header
641+ y_header = (height / 9) * 8
642+ createGuide('0,' + str(y_header),h_orientation,nv)
643+
644+ # 2/9th footer
645+ y_footer = (height / 9) * 2
646+ createGuide('0,' + str(y_footer),h_orientation,nv)
647+
648+ # 2/9th left margin
649+ x_left = (width / 9)
650+ createGuide(str(x_left) + ',0',v_orientation,nv)
651+
652+ # 1/9th right margin
653+ x_right = (width / 9) * 7
654+ createGuide(str(x_right) + ',0',v_orientation,nv)
655+
656+
657+ # setting up properties of the rectangle created between guides
658+ rectangle_height = y_header - y_footer
659+ rectangle_width = x_right - x_left
660+
661+ if (h_subdiv != 0):
662+ begin_from = y_footer
663+
664+ # creating horizontal guides
665+ drawHorizontalGuides(h_subdiv,rectangle_width,rectangle_height,0,nv,begin_from)
666+
667+ if (v_subdiv != 0):
668+ begin_from = x_left
669+
670+ # creating vertical guides
671+ drawVerticalGuides(v_subdiv,rectangle_width,rectangle_height,0,nv,begin_from)
672+
673+# Create effect instance and apply it.
674+effect = Guides_Creator()
675+effect.affect()
676
677 ## end of file guide_creator.py ##