Subversion Repositories Scribus

Rev

Rev 9672 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
899 cbradney 1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
 
382 Franz 4
"""Golden Mean for Scribus.
5
 
938 subik 6
This script creates supplementary guides on the page to
382 Franz 7
help design the "right" layout in golden mean (golden
8
ratio).
9
 
938 subik 10
See scribus.net and CVS for fresh versions to come...
382 Franz 11
 
12
REQUIREMENTS:
13
Scribus - CVS version later 02/24/2004 or later release 1.5
14
 
15
MORE INFO:
16
See e.g.
17
http://home.att.net/~vmueller/prop/theo.html
18
or Google for more theory :)
19
 
20
CONTACT:
21
email : petr@yarpen.cz
22
Feature requests and bug reports welcomed
652 fschmid 23
 
24
 
25
LICENSE:
26
 
27
This program is free software; you can redistribute it and/or modify
28
it under the terms of the GNU General Public License as published by
29
the Free Software Foundation; either version 2 of the License, or
30
(at your option) any later version.
31
 
32
This program is distributed in the hope that it will be useful,
33
but WITHOUT ANY WARRANTY; without even the implied warranty of
34
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35
GNU General Public License for more details.
36
 
37
You should have received a copy of the GNU General Public License
38
along with this program; if not, write to the Free Software
18122 mrdocs 39
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
382 Franz 40
"""
41
 
899 cbradney 42
import sys
43
 
44
try:
45
    from scribus import *
46
except ImportError:
47
    print "This script only runs from within Scribus."
48
    sys.exit(1)
49
 
382 Franz 50
from math import sqrt
51
 
52
 
53
def goldenMean(aSize=0):
54
    """x = (?5-1)/2"""
55
    return aSize * ((sqrt(5) - 1)/2)
56
 
57
 
899 cbradney 58
def main():
382 Franz 59
    # remember user settings
652 fschmid 60
    unit = getUnit()
382 Franz 61
    # set my environment - points needed
652 fschmid 62
    setUnit(0)
382 Franz 63
    # Paper format
652 fschmid 64
    paper = pageDimension()
938 subik 65
    # set the guides. The get* functions are for "remembering" the old ones...
66
    setVGuides(getVGuides() + [goldenMean(paper[0]), paper[0] - goldenMean(paper[0])])
67
    setHGuides(getHGuides() + [goldenMean(paper[1]), paper[1] - goldenMean(paper[1])])
382 Franz 68
    # restore user settings
652 fschmid 69
    setUnit(unit)
899 cbradney 70
 
71
if __name__ == '__main__':
72
    if haveDoc():
73
        main()
74
    else:
75
        messageBox("Golden Mean.py", "Please run this script with a document already open", ICON_INFORMATION);