home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / teken / scribus-1.3.3.9-win32-install.exe / share / samples / golden-mean.py < prev    next >
Text File  |  2004-12-20  |  2KB  |  76 lines

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """Golden Mean for Scribus.
  5.  
  6. This script creates supplementary guides on the page to
  7. help design the "right" layout in golden mean (golden
  8. ratio).
  9.  
  10. See scribus.net and CVS for fresh versions to come...
  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
  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
  39. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  40. """
  41.  
  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.  
  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.  
  58. def main():
  59.     # remember user settings
  60.     unit = getUnit()
  61.     # set my environment - points needed
  62.     setUnit(0)
  63.     # Paper format
  64.     paper = pageDimension()
  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])])
  68.     # restore user settings
  69.     setUnit(unit)
  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);
  76.