papersize.py :  » GUI » Sketch » skencil-0.6.17 » Sketch » Graphics » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » Sketch 
Sketch » skencil 0.6.17 » Sketch » Graphics » papersize.py
# Sketch - A Python-based interactive drawing program
# Copyright (C) 1997, 1998, 2000 by Bernhard Herzog
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#
# Define some standard Papersizes
#
# This module exports the following variables:
#
# Papersize:
#
# A dictionary that maps the name of paper formats such as 'letter' or
# 'A4' to their widths and heights. The value of an entry is a tuple
# (width, height).
#
#
# PapersizesList:
#
# A list containing all sizes defined in Papersize. The list items are
# tuples of the form (name, width, height)
#
#
# All sizes are given in units of PostScript points (1/72 inch)
#

from Sketch.Lib.units import m_to_pt,in_to_pt


# Compute the European paper sizes.
#
# While this is a cute approach, it also is less accurate than simply
# listing the papersizes because the standard defines the sizes in mm.
# I've left the code in here for entertainment and educational value
# :-).
#
# The definition is that A0 has an area of 1m^2 and its sides have a
# ratio of sqrt(2). A1 is A0 cut in half and so on. Therefore A0's
# height is 2**0.25 and its width 0.5**0.25 (both in meters)
def _european_sizes():
    sizes = []
    width = 0.5**0.25
    height = 2.0**0.25
    for i in range(8):
  sizes.append(('A' + `i`, width * m_to_pt, height * m_to_pt))
  width, height = height / 2, width
    return sizes[3:]

# The more accurate way to specify the european sizes, contributed by
# Martin Glaser:

_din_sizes = [
#    ('A0', 0.841 * m_to_pt, 1.189 * m_to_pt),
#    ('A1', 0.594 * m_to_pt, 0.841 * m_to_pt),
#    ('A2', 0.420 * m_to_pt, 0.594 * m_to_pt),
    ('A3', 0.297 * m_to_pt, 0.420 * m_to_pt),
    ('A4', 0.210 * m_to_pt, 0.297 * m_to_pt),
    ('A5', 0.148 * m_to_pt, 0.210 * m_to_pt),
    ('A6', 0.105 * m_to_pt, 0.148 * m_to_pt),
    ('A7', 0.074 * m_to_pt, 0.105 * m_to_pt),
    ]



_american_sizes = [
    ('letter',    8.5  * in_to_pt, 11   * in_to_pt),
    ('legal',    8.5  * in_to_pt, 14   * in_to_pt),
    ('executive',  7.25 * in_to_pt, 10.5 * in_to_pt)
    ]


Papersize = {}
PapersizesList = _din_sizes + _american_sizes


for name, width, height in PapersizesList:
    Papersize[name] = (width, height)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.