Back to index

scribus-ng  1.3.4.dfsg+svn20071115
golden-mean.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 """Golden Mean for Scribus.
00005 
00006 This script creates supplementary guides on the page to
00007 help design the "right" layout in golden mean (golden
00008 ratio).
00009 
00010 See scribus.net and CVS for fresh versions to come...
00011 
00012 REQUIREMENTS:
00013 Scribus - CVS version later 02/24/2004 or later release 1.5
00014 
00015 MORE INFO:
00016 See e.g.
00017 http://home.att.net/~vmueller/prop/theo.html
00018 or Google for more theory :)
00019 
00020 CONTACT:
00021 email : petr@yarpen.cz
00022 Feature requests and bug reports welcomed
00023 
00024 
00025 LICENSE:
00026 
00027 This program is free software; you can redistribute it and/or modify
00028 it under the terms of the GNU General Public License as published by
00029 the Free Software Foundation; either version 2 of the License, or
00030 (at your option) any later version.
00031 
00032 This program is distributed in the hope that it will be useful,
00033 but WITHOUT ANY WARRANTY; without even the implied warranty of
00034 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00035 GNU General Public License for more details.
00036 
00037 You should have received a copy of the GNU General Public License
00038 along with this program; if not, write to the Free Software
00039 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00040 """
00041 
00042 import sys
00043 
00044 try:
00045     from scribus import *
00046 except ImportError:
00047     print "This script only runs from within Scribus."
00048     sys.exit(1)
00049 
00050 from math import sqrt
00051 
00052 
00053 def goldenMean(aSize=0):
00054     """x = (?5-1)/2"""
00055     return aSize * ((sqrt(5) - 1)/2)
00056 
00057 
00058 def main():
00059     # remember user settings
00060     unit = getUnit()
00061     # set my environment - points needed
00062     setUnit(0)
00063     # Paper format
00064     paper = pageDimension()
00065     # set the guides. The get* functions are for "remembering" the old ones...
00066     setVGuides(getVGuides() + [goldenMean(paper[0]), paper[0] - goldenMean(paper[0])])
00067     setHGuides(getHGuides() + [goldenMean(paper[1]), paper[1] - goldenMean(paper[1])])
00068     # restore user settings
00069     setUnit(unit)
00070 
00071 if __name__ == '__main__':
00072     if haveDoc():
00073         main()
00074     else:
00075         messageBox("Golden Mean.py", "Please run this script with a document already open", ICON_INFORMATION);