docs/userguide/genuserguide.py
author aaron_watters
Thu, 22 Jun 2000 19:05:24 +0000
changeset 301 5ad57f31ae75
parent 300 44c954f72e2b
child 304 3d53a0b5d429
permissions -rw-r--r--
added quickhack for font changes in paragraphs and lots of new text
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     1
#!/bin/env python
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     2
###############################################################################
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     3
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     4
#	ReportLab Public License Version 1.0
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     5
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     6
#   Except for the change of names the spirit and intention of this
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     7
#   license is the same as that of Python
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     8
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     9
#	(C) Copyright ReportLab Inc. 1998-2000.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    10
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    11
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    12
# All Rights Reserved
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    13
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    14
# Permission to use, copy, modify, and distribute this software and its
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    15
# documentation for any purpose and without fee is hereby granted, provided
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    16
# that the above copyright notice appear in all copies and that both that
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    17
# copyright notice and this permission notice appear in supporting
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    18
# documentation, and that the name of ReportLab not be used
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    19
# in advertising or publicity pertaining to distribution of the software
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    20
# without specific, written prior permission. 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    21
# 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    22
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    23
# Disclaimer
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    24
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    25
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    26
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    27
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    28
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    29
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    30
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    31
# PERFORMANCE OF THIS SOFTWARE. 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    32
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    33
###############################################################################
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    34
#	$Log: genuserguide.py,v $
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    35
#	Revision 1.8  2000/06/22 19:05:24  aaron_watters
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    36
#	added quickhack for font changes in paragraphs and lots of new text
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    37
#
300
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
    38
#	Revision 1.7  2000/06/22 13:55:59  aaron_watters
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
    39
#	showPage resets all state parameters warning.
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    40
#	
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
    41
#	Revision 1.6  2000/06/22 13:35:28  aaron_watters
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
    42
#	textobject and pathobject methods, among other things
300
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
    43
#	
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
    44
#	Revision 1.5  2000/06/21 21:19:29  aaron_watters
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
    45
#	colors, line styles, more examples
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
    46
#	
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
    47
#	Revision 1.4  2000/06/21 15:16:05  aaron_watters
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
    48
#	Lots of graphical examples added
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
    49
#	
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
    50
#	Revision 1.3  2000/06/20 20:31:42  aaron_watters
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
    51
#	typos and more examples
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
    52
#	
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
    53
#	Revision 1.2  2000/06/19 21:13:02  aaron_watters
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
    54
#	2nd try. more text
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
    55
#	
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    56
#	Revision 1.1  2000/06/17 02:57:56  aaron_watters
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    57
#	initial checkin. user guide generation framework.
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
    58
#	
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    59
__version__=''' $Id: genuserguide.py,v 1.8 2000/06/22 19:05:24 aaron_watters Exp $ '''
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    60
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    61
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    62
__doc__ = """
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    63
This module contains the script for building the user guide.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    64
"""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    65
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    66
from reportlab.platypus.doctemplate import SimpleDocTemplate
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    67
from reportlab.platypus.flowables import Flowable
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    68
from reportlab.lib.units import inch
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    69
from reportlab.lib.pagesizes import letter
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    70
from reportlab.platypus import Paragraph, Spacer, Preformatted, PageBreak
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    71
from reportlab.lib.styles import PropertySet, getSampleStyleSheet, ParagraphStyle
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    72
from reportlab.lib import colors
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    73
import examples
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    74
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    75
styleSheet = getSampleStyleSheet()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    76
from reportlab.lib.corp import ReportLabLogo
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    77
LOGO = ReportLabLogo(0.25*inch, 0.25*inch, inch, 0.75*inch)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    78
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    79
from t_parse import Template
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    80
QFcodetemplate = Template("X$X$", "X")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    81
codesubst = "%s<font name=courier color=green>%s</font>"
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    82
QFreptemplate = Template("X^X^", "X")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    83
QFsubst = "%s<font name=Helvetica color=blue><i>%s</i></font>"
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    84
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    85
def quickfix(text):
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    86
    """inside text find any subsequence of form $subsequence$.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    87
       Format the subsequence as code.  If similarly if text contains ^arg^
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    88
       format the arg as replaceable.  The escape sequence for literal
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    89
       $ is $\\$ (^ is ^\\^.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    90
    """
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    91
    from string import join
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    92
    for (template,subst) in [(QFcodetemplate, codesubst), (QFreptemplate, QFsubst)]:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    93
        fragment = text
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    94
        parts = []
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    95
        try:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    96
            while fragment:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    97
                try:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    98
                    (matches, index) = template.PARSE(fragment)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
    99
                except: raise ValueError
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   100
                else:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   101
                    [prefix, code] = matches
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   102
                    if code == "\\":
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   103
                        part = fragment[:index]
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   104
                    else:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   105
                        part = subst % (prefix, code)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   106
                    parts.append(part)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   107
                    fragment = fragment[index:]
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   108
        except ValueError:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   109
            parts.append(fragment)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   110
        text = join(parts, "")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   111
    return text
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   112
#print quickfix("$testing$ testing $one$ ^two^ $three(^four^)$")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   113
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   114
class PageAnnotations:
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   115
    """ "closure" containing onfirstpage, onnextpage actions
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   116
        and any data they might want to use.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   117
    """
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   118
    pagesize = letter
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   119
    pagenumber = 1
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   120
    def onFirstPage(self, canvas, doc):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   121
        (xsize, ysize) = self.pagesize
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   122
        LOGO.draw(canvas)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   123
        #  width=6.25*inch,height=0.62*inch)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   124
        canvas.setFont("Helvetica", 12)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   125
        canvas.drawRightString(xsize-inch, ysize-0.8*inch, "ReportLab User Guide")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   126
        self.pagenumber = self.pagenumber+1
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   127
    def onNextPage(self, canvas, doc):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   128
        canvas.saveState()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   129
        (xsize, ysize) = self.pagesize
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   130
        canvas.setFont("Helvetica", 12)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   131
        canvas.drawString(inch, ysize-0.8*inch, "Page %s" % self.pagenumber)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   132
        self.onFirstPage(canvas, doc)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   133
        canvas.restoreState()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   134
        
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   135
class Guide:
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   136
    def __init__(self):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   137
        self.myannotations = PageAnnotations()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   138
        self.story = story()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   139
    def go(self, filename="userguide.pdf"):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   140
        # generate the doc...
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   141
	doc = SimpleDocTemplate(filename,pagesize = letter ,showBoundary=0,
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   142
	  leftMargin=inch, rightMargin=inch, topMargin=1.7*inch, bottomMargin=inch+90)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   143
	story = self.story
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   144
	doc.build(story, self.myannotations.onFirstPage, self.myannotations.onNextPage)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   145
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   146
H = styleSheet['Heading2']
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   147
lessonnamestyle = ParagraphStyle("lessonname", parent=H)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   148
lessonnamestyle.fontName = 'Helvetica-Bold'
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   149
B = styleSheet['BodyText']
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   150
discussiontextstyle = ParagraphStyle("discussiontext", parent=B)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   151
discussiontextstyle.fontName= 'Helvetica'
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   152
exampletextstyle = styleSheet['Code']
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   153
# size for every example
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   154
examplefunctionxinches = 5.5
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   155
examplefunctionyinches = 3
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   156
examplefunctiondisplaysizes = (examplefunctionxinches*inch, examplefunctionyinches*inch)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   157
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   158
# for testing
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   159
def NOP(*x,**y):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   160
    return None
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   161
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   162
BODY = []
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   163
def story():
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   164
    return BODY
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   165
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   166
def disc(text, klass=Paragraph, style=discussiontextstyle):
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   167
    text = quickfix(text)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   168
    P = klass(text, style)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   169
    BODY.append(P)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   170
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   171
def eg(text):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   172
    BODY.append(Spacer(0.1*inch, 0.1*inch))
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   173
    disc(text, klass=Preformatted, style=exampletextstyle)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   174
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   175
#eg("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   176
#this
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   177
#  is 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   178
#    an 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   179
#     example""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   180
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   181
def head(text):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   182
    disc(text, style=lessonnamestyle)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   183
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   184
#head("this is a header")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   185
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   186
def lesson(text):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   187
    BODY.append(PageBreak())
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   188
    head(text)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   189
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   190
def canvasdemo(function):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   191
    BODY.append(Spacer(0.1*inch, 0.1*inch))
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   192
    BODY.append(OperationWrapper(function))
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   193
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   194
class OperationWrapper(Flowable):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   195
    """wrap a drawing operation as a flowable.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   196
       the operation should respect the examplefunctiondisplaysizes
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   197
       limitations.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   198
       This example wraps a drawing operator f(pdfgen.canvas).
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   199
       Always enclosed in a rectangle.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   200
    """
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   201
    def __init__(self, operation):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   202
        self.operation = operation
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   203
        
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   204
    def wrap(self, aw, ah):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   205
        return examplefunctiondisplaysizes # always the same
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   206
        
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   207
    def draw(self):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   208
        canvas = self.canv
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   209
        canvas.saveState()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   210
        (x,y) = examplefunctiondisplaysizes
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   211
        self.operation(canvas)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   212
        canvas.restoreState()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   213
        canvas.rect(0,0,x,y)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   214
        
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   215
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   216
def pencilnote():
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   217
    BODY.append(examples.NoteAnnotation())
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   218
        
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   219
###### testing...
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   220
#canvasdemo(NOP)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   221
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   222
#lesson("this is a new lesson")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   223
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   224
#disc("this explains the example")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   225
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   226
#eg("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   227
#this
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   228
#  is the
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   229
#    example
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   230
#      code""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   231
      
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   232
#disc("the execution of the example follows")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   233
      
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   234
#canvasdemo(NOP) # execute some code
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   235
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   236
#pencilnote()
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   237
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   238
head("ReportLab User Guide")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   239
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   240
disc("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   241
This document is intended to be a conversational introduction
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   242
to the use of the ReportLab packages.  Some previous programming experience
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   243
is presumed and familiarity with the Python Programming language is
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   244
recommended.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   245
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   246
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   247
#canvasdemo(NOP) # execute some code
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   248
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   249
pencilnote()
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   250
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   251
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   252
This document is in a <em>very</em> preliminary form.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   253
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   254
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   255
lesson("Introduction to $pdfgen$")
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   256
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   257
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   258
The $pdfgen$ package is the lowest level interface for
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   259
generating PDF documents.  A $pdfgen$ program is essentially
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   260
a sequence of instructions for "painting" a document onto
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   261
a sequence of pages.  The interface object which provides the
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   262
painting operations is the $pdfgen$ canvas.  
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   263
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   264
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   265
disc("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   266
The canvas should be thought of as a sheet of white paper
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   267
with points on the sheet identified using Cartesian ^(X,Y)^ coordinates
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   268
which by default have the ^(0,0)^ origin point at the lower
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   269
left corner of the page.  Furthermore the first coordinate ^x^
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   270
goes to the right and the second coordinate ^y^ goes up, by
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   271
default.""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   272
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   273
disc("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   274
A simple example
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   275
program that uses a canvas follows.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   276
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   277
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   278
eg("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   279
    from reportlab.pdfgen import canvas
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   280
    c = canvas.Canvas("hello.pdf")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   281
    hello(c)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   282
    c.showPage()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   283
    c.save()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   284
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   285
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   286
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   287
The above code creates a $canvas$ object which will generate
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   288
a PDF file named $hello.pdf$ in the current working directory.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   289
It then calls the $hello$ function passing the $canvas$ as an argument.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   290
Finally the $showPage$ method saves the current page of the canvas
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   291
and the $save$ method stores the file and closes the canvas.""")
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   292
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   293
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   294
The $showPage$ method causes the $canvas$ to stop drawing on the
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   295
current page and any further operations will draw on a subsequent
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   296
page (if there are any further operations -- if not no
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   297
new page is created).  The $save$ method must be called after the
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   298
construction of the document is complete -- it generates the PDF
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   299
document, which is the whole purpose of the $canvas$ object.
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   300
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   301
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   302
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   303
Suppose the $hello$ function referenced above is implemented as
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   304
follows (we will not explain each of the operations in detail
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   305
yet).
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   306
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   307
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   308
eg(examples.testhello)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   309
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   310
disc("""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   311
Examining this code notice that there are essentially two types
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   312
of operations performed using a canvas.  The first type draws something
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   313
on the page such as a text string or a rectangle or a line.  The second
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   314
type changes the state of the canvas such as
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   315
changing the current fill or stroke color or changing the current font
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   316
type and size.  
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   317
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   318
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   319
disc("""
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   320
If we imagine the program as a painter working on
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   321
the canvas the "draw" operations apply paint to the canvas using
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   322
the current set of tools (colors, line styles, fonts, etcetera)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   323
and the "state change" operations change one of the current tools
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   324
(changing the fill color from whatever it was to blue, or changing
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   325
the current font to $Times-Roman$ in 15 points, for example).
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   326
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   327
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   328
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   329
The document generated by the "hello world" program listed above would contain
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   330
the following graphics.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   331
""")
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   332
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   333
canvasdemo(examples.hello)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   334
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   335
head("About the demos in this document")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   336
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   337
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   338
This document contains demonstrations of the code discussed like the one shown
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   339
in the rectangle above.  These demos are drawn on a "tiny page" embedded
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   340
within the real pages of the guide.  The tiny pages are %s inches wide
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   341
and %s inches tall.  The demo displays show the actual output of the demo
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   342
code.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   343
""" % (examplefunctionxinches, examplefunctionyinches))
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   344
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   345
lesson('The tools: the "draw" operations')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   346
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   347
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   348
This section briefly lists the tools available to the program
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   349
for painting information onto a page using the canvas interface.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   350
These will be discussed in detail in later sections.  They are listed
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   351
here for easy reference and for summary purposes.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   352
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   353
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   354
head("Line methods")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   355
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   356
eg("""canvas.line(x1,y1,x2,y2)""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   357
eg("""canvas.lines(linelist)""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   358
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   359
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   360
The line methods draw straight line segments on the canvas.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   361
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   362
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   363
head("Shape methods")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   364
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   365
eg("""canvas.grid(xlist, ylist) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   366
eg("""canvas.bezier(x1, y1, x2, y2, x3, y3, x4, y4)""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   367
eg("""canvas.arc(x1,y1,x2,y2) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   368
eg("""canvas.rect(x, y, width, height, stroke=1, fill=0) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   369
eg("""canvas.ellipse(x, y, width, height, stroke=1, fill=0)""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   370
eg("""canvas.wedge(x1,y1, x2,y2, startAng, extent, stroke=1, fill=0) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   371
eg("""canvas.circle(x_cen, y_cen, r, stroke=1, fill=0)""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   372
eg("""canvas.roundRect(x, y, width, height, radius, stroke=1, fill=0) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   373
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   374
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   375
The shape methods draw common complex shapes on the canvas.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   376
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   377
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   378
head("String drawing methods")
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   379
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   380
eg("""canvas.drawString(x, y, text):""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   381
eg("""canvas.drawRightString(x, y, text) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   382
eg("""canvas.drawCentredString(x, y, text)""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   383
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   384
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   385
The draw string methods draw single lines of text on the canvas.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   386
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   387
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   388
head("The text object methods")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   389
eg("""textobject = canvas.beginText(x, y) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   390
eg("""canvas.drawText(textobject) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   391
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   392
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   393
Text objects are used to format text in ways that
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   394
are not supported directly by the canvas interface.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   395
A program creates a text object from the canvas using beginText
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   396
and then formats text by invoking textobject methods.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   397
Finally the textobject is drawn onto the canvas using
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   398
drawText.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   399
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   400
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   401
head("The path object methods")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   402
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   403
eg("""path = canvas.beginPath() """)
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   404
eg("""canvas.drawPath(path, stroke=1, fill=0) """)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   405
eg("""canvas.clipPath(path, stroke=1, fill=0) """)
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   406
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   407
head("Image methods")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   408
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   409
eg("""canvas.drawInlineImage(self, image, x,y, width=None,height=None) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   410
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   411
head("Ending a page")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   412
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   413
eg("""canvas.showPage()""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   414
300
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   415
disc("""The showPage method finishes the current page.  All additional drawing will
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   416
be done on another page.""")
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   417
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   418
pencilnote()
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   419
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   420
disc("""Warning!  All state changes (font changes, color settings, geometry transforms, etcetera)
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   421
are FORGOTTEN when you advance to a new page in $pdfgen$.  Any state settings you wish to preserve
300
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   422
must be set up again before the program proceeds with drawing!""")
44c954f72e2b showPage resets all state parameters warning.
aaron_watters
parents: 299
diff changeset
   423
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   424
lesson('The toolbox: the "state change" operations')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   425
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   426
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   427
This section briefly lists the ways to switch the tools used by the
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   428
program
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   429
for painting information onto a page using the canvas interface.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   430
These too will be discussed in detail in later sections.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   431
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   432
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   433
head("Changing Colors")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   434
eg("""canvas.setFillColorCMYK(c, m, y, k) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   435
eg("""canvas.setStrikeColorCMYK(c, m, y, k) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   436
eg("""canvas.setFillColorRGB(r, g, b) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   437
eg("""canvas.setStrokeColorRGB(r, g, b) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   438
eg("""canvas.setFillColor(acolor) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   439
eg("""canvas.setStrokeColor(acolor) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   440
eg("""canvas.setFillGray(gray) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   441
eg("""canvas.setStrokeGray(gray) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   442
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   443
head("Changing Fonts")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   444
eg("""canvas.setFont(psfontname, size, leading = None) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   445
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   446
head("Changing Graphical Styles")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   447
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   448
eg("""canvas.setLineWidth(width) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   449
eg("""canvas.setLineCap(mode) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   450
eg("""canvas.setLineJoin(mode) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   451
eg("""canvas.setMiterLimit(limit) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   452
eg("""canvas.setDash(self, array=[], phase=0) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   453
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   454
head("Changing Geometry")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   455
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   456
eg("""canvas.setPageSize(pair) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   457
eg("""canvas.transform(a,b,c,d,e,f): """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   458
eg("""canvas.translate(dx, dy) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   459
eg("""canvas.scale(x, y) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   460
eg("""canvas.rotate(theta) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   461
eg("""canvas.skew(alpha, beta) """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   462
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   463
head("State control")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   464
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   465
eg("""canvas.saveState() """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   466
eg("""canvas.restoreState() """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   467
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   468
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   469
lesson("Other canvas methods.")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   470
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   471
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   472
Not all methods of the canvas object fit into the "tool" or "toolbox"
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   473
categories.  Below are some of the misfits, included here for completeness.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   474
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   475
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   476
eg("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   477
 canvas.setAuthor()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   478
 canvas.addOutlineEntry(title, key, level=0, closed=None)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   479
 canvas.setTitle(title)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   480
 canvas.setSubject(subj)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   481
 canvas.pageHasData()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   482
 canvas.showOutline()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   483
 canvas.bookmarkPage(name)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   484
 canvas.bookmarkHorizontalAbsolute(name, yhorizontal)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   485
 canvas.doForm()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   486
 canvas.beginForm(name, lowerx=0, lowery=0, upperx=None, uppery=None)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   487
 canvas.endForm()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   488
 canvas.linkAbsolute(contents, destinationname, Rect=None, addtopage=1, name=None, **kw)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   489
 canvas.getPageNumber()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   490
 canvas.addLiteral()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   491
 canvas.getAvailableFonts()
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   492
 canvas.stringWidth(self, text, fontName, fontSize)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   493
 canvas.setPageCompression(onoff=1)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   494
 canvas.setPageTransition(self, effectname=None, duration=1, 
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   495
                        direction=0,dimension='H',motion='I')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   496
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   497
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   498
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   499
lesson('Coordinates (default user space)')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   500
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   501
disc("""
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   502
By default locations on a page are identified by a pair of numbers.
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   503
For example the pair $(4.5*inch, 1*inch)$ identifies the location
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   504
found on the page by starting at the lower left corner and moving to
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   505
the right 4.5 inches and up one inch.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   506
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   507
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   508
disc("""For example, the following function draws
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   509
a number of elements on a canvas.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   510
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   511
eg(examples.testcoords)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   512
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   513
disc("""In the default user space the "origin" ^(0,0)^ point is at the lower
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   514
left corner.  Executing the $coords$ function in the default user space
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   515
(for the "demo minipage") we obtain the following.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   516
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   517
canvasdemo(examples.coords)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   518
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   519
head("Moving the origin: the $translate$ method")
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   520
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   521
disc("""Often it is useful to "move the origin" to a new point off
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   522
the lower left corner.  The $canvas.translate(^x,y^)$ method moves the origin
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   523
for the current page to the point currently identified by ^(x,y)^.""")
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   524
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   525
disc("""For example the following translate function first moves
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   526
the origin before drawing the same objects as shown above.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   527
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   528
eg(examples.testtranslate)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   529
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   530
disc("""This produces the following.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   531
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   532
canvasdemo(examples.translate)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   533
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   534
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   535
#canvasdemo(NOP) # execute some code
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   536
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   537
pencilnote()
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   538
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   539
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   540
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   541
<i>Note:</i> As illustrated in the example it is perfectly possible to draw objects 
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   542
or parts of objects "off the page".
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   543
In particular a common confusing bug is a translation operation that translates the
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   544
entire drawing off the visible area of the page.  If a program produces a blank page
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   545
it is possible that all the drawn objects are off the page.
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   546
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   547
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   548
head("Shrinking and growing: the scale operation")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   549
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   550
disc("""Another important operation is scaling.  The scaling operation $canvas.scale(^dx,dy^)$
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   551
stretches or shrinks the ^x^ and ^y^ dimensions by the ^dx^, ^dy^ factors respectively.  Often
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   552
^dx^ and ^dy^ are the same -- for example to reduce a drawing by half in all dimensions use
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   553
$dx = dy = 0.5$.  However for the purposes of illustration we show an example where
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   554
$dx$ and $dy$ are different.
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   555
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   556
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   557
eg(examples.testscale)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   558
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   559
disc("""This produces a "short and fat" reduced version of the previously displayed operations.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   560
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   561
canvasdemo(examples.scale)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   562
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   563
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   564
#canvasdemo(NOP) # execute some code
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   565
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   566
pencilnote()
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   567
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   568
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   569
disc("""<i>Note:</i> scaling may also move objects or parts of objects off the page,
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   570
or may cause objects to "shrink to nothing." """)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   571
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   572
disc("""Scaling and translation can be combined, but the order of the
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   573
operations are important.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   574
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   575
eg(examples.testscaletranslate)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   576
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   577
disc("""This example function first saves the current canvas state
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   578
and then does a $scale$ followed by a $translate$.  Afterward the function
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   579
restores the state (effectively removing the effects of the scaling and
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   580
translation) and then does the <i>same</i> operations in a different order.
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   581
Observe the effect below.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   582
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   583
canvasdemo(examples.scaletranslate)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   584
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   585
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   586
#canvasdemo(NOP) # execute some code
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   587
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   588
pencilnote()
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   589
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   590
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   591
disc("""<em>Note:</em> scaling shrinks or grows everything including line widths
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   592
so using the canvas.scale method to render a microscopic drawing in 
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   593
scaled microscopic units
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   594
may produce a blob (because all line widths will get expanded a huge amount).  
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   595
Also rendering an aircraft wing in meters scaled to centimeters may cause the lines
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   596
to shrink to the point where they disappear.  For engineering or scientific purposes
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   597
such as these scale and translate
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   598
the units externally before rendering them using the canvas.""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   599
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   600
head("Saving and restoring the canvas state: $saveState$ and $restoreState$")
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   601
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   602
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   603
The $scaletranslate$ function used an important feature of the canvas object:
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   604
the ability to save and restore the current parameters of the canvas.
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   605
By enclosing a sequence of operations in a matching pair of $canvas.saveState()$
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   606
an $canvas.restoreState()$ operations all changes of font, color, line style,
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   607
scaling, translation, or other aspects of the canvas graphics state can be
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   608
restored to the state at the point of the $saveState()$.  Remember that the save/restore
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   609
calls must match: a stray save or restore operation may cause unexpected
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   610
and undesirable behavior.  Also, remember that <i>no</i> canvas state is
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   611
preserved across page breaks, and the save/restore mechanism does not work
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   612
across page breaks.
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   613
""")
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   614
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   615
head("Mirror image")
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   616
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   617
disc("""
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   618
It is interesting although perhaps not terribly useful to note that
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   619
scale factors can be negative.  For example the following function
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   620
""")
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   621
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   622
eg(examples.testmirror)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   623
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   624
disc("""
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   625
creates a mirror image of the elements drawn by the $coord$ function.
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   626
""")
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   627
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   628
canvasdemo(examples.mirror)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   629
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   630
disc("""
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   631
Notice that the text strings are painted backwards.
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   632
""")
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   633
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   634
lesson("Colors")
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   635
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   636
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   637
There are four way to specify colors in $pdfgen$: by name (using the $color$
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   638
module, by red/green/blue (additive, $RGB$) value,
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   639
by cyan/magenta/yellow/darkness (subtractive, $CMYK$), or by gray level.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   640
The $colors$ function below exercises each of the four methods.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   641
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   642
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   643
eg(examples.testcolors)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   644
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   645
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   646
The $RGB$ or additive color specification follows the way a computer
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   647
screen adds different levels of the red, green, or blue light to make
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   648
any color, where white is formed by turning all three lights on full
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   649
$(1,1,1)$.""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   650
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   651
disc("""The $CMYK$ or subtractive method follows the way a printer
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   652
mixes three pigments (cyan, magenta, and yellow) to form colors.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   653
Because mixing chemicals is more difficult than combining light there
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   654
is a fourth parameter for darkness.  For example a chemical
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   655
combination of the $CMY$ pigments generally never makes a perfect
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   656
black -- instead producing a muddy color -- so, to get black printers
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   657
don't use the $CMY$ pigments but use a direct black ink.  Because
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   658
$CMYK$ maps more directly to the way printer hardware works it may
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   659
be the case that colors specified in $CMYK$ will provide better fidelity
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   660
and better control when printed.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   661
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   662
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   663
canvasdemo(examples.colors)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   664
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   665
lesson('Painting back to front')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   666
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   667
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   668
Objects may be painted over other objects to good effect in $pdfgen$.  As
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   669
in painting with oils the object painted last will show up on top.  For
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   670
example, the $spumoni$ function below paints up a base of colors and then
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   671
paints a white text over the base.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   672
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   673
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   674
eg(examples.testspumoni)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   675
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   676
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   677
The word "SPUMONI" is painted in white over the colored rectangles,
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   678
with the apparent effect of "removing" the color inside the body of
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   679
the word.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   680
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   681
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   682
canvasdemo(examples.spumoni)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   683
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   684
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   685
The last letters of the word are not visible because the default canvas
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   686
background is white and painting white letters over a white background
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   687
leaves no visible effect.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   688
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   689
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   690
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   691
This method of building up complex paintings in layers can be done
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   692
in very many layers in $pdfgen$ -- there are fewer physical limitations
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   693
than there are when dealing with physical paints.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   694
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   695
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   696
eg(examples.testspumoni2)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   697
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   698
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   699
The $spumoni2$ function layers an ice cream cone over the
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   700
$spumoni$ drawing.  Note that different parts of the cone
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   701
and scoops layer over eachother as well.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   702
""")
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   703
canvasdemo(examples.spumoni2)
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   704
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   705
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   706
lesson('Fonts and text objects')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   707
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   708
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   709
Text may be drawn in many different colors, fonts, and sizes in $pdfgen$.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   710
The $textsize$ function demonstrates how to change the color and font and
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   711
size of text and how to place text on the page.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   712
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   713
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   714
eg(examples.testtextsize)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   715
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   716
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   717
The $textsize$ function generates the following page.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   718
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   719
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   720
canvasdemo(examples.textsize)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   721
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   722
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   723
A number of different fonts are always available in $pdfgen$.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   724
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   725
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   726
eg(examples.testfonts)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   727
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   728
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   729
The $fonts$ function lists the fonts that are always available.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   730
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   731
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   732
canvasdemo(examples.fonts)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   733
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   734
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   735
Other fonts can be added to a PDF document as well.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   736
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   737
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   738
lesson("Text object methods")
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   739
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   740
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   741
For the dedicated presentation of text in a PDF document, use a text object.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   742
The text object interface provides detailed control of text layout parameters
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   743
not available directly at the canvas level.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   744
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   745
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   746
eg("""textobject.setTextOrigin(x,y)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   747
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   748
eg("""textobject.setTextTransform(a,b,c,d,e,f)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   749
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   750
eg("""textobject.moveCursor(dx, dy) # from start of current LINE""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   751
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   752
eg("""(x,y) = textobject.getCursor()""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   753
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   754
eg("""x = textobject.getX(); y = textobject.getY()""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   755
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   756
eg("""textobject.setFont(psfontname, size, leading = None)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   757
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   758
eg("""textobject.textOut(text)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   759
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   760
eg("""textobject.textLine(text='')""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   761
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   762
eg("""textobject.textLines(stuff, trim=1)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   763
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   764
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   765
The text object methods shown above relate to basic text geometry.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   766
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   767
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   768
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   769
A text object maintains a text cursor which moves about the page when 
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   770
text is drawn.  For example the $setTextOrigin$ places the cursor
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   771
in a known position and the $textLine$ and $textLines$ methods move
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   772
the text cursor down past the lines that have been missing.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   773
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   774
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   775
eg(examples.testcursormoves1)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   776
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   777
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   778
The $testcursormoves1$ function relies on the automatic
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   779
movement of the text cursor for placing text after the origin
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   780
has been set.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   781
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   782
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   783
canvasdemo(examples.cursormoves1)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   784
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   785
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   786
It is also possible to control the movement of the cursor
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   787
more explicitly by using the $moveCursor$ method (which moves
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   788
the cursor as an offset from the start of the current <i>line</i>
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   789
NOT the current cursor, and which also has positive ^y^ offsets
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   790
move <i>down</i> (in contrast to the normal geometry where
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   791
positive ^y^ usually moves up.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   792
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   793
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   794
eg(examples.testcursormoves2)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   795
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   796
disc("""
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   797
Here the $textOut$ does not move the down a line in contrast
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   798
to the $textLine$ function which does move down.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   799
""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   800
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   801
canvasdemo(examples.cursormoves2)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   802
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   803
head("Character Spacing")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   804
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   805
eg("""textobject.setCharSpace(charSpace)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   806
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   807
disc("""The $setCharSpace$ method adjusts one of the parameters of text -- the inter-character
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   808
spacing.""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   809
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   810
eg(examples.testcharspace)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   811
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   812
disc("""The 
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   813
$charspace$ function exercises various spacing settings.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   814
It produces the following page.""")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   815
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   816
canvasdemo(examples.charspace)\
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   817
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   818
head("Word Spacing")
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   819
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   820
eg("""textobject.setWordSpace(wordSpace)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   821
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   822
eg(examples.testwordspace)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   823
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   824
canvasdemo(examples.wordspace)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   825
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   826
eg("""textobject.setHorizScale(horizScale)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   827
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   828
eg(examples.testhorizontalscale)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   829
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   830
canvasdemo(examples.horizontalscale)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   831
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   832
eg("""textobject.setLeading(leading)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   833
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   834
eg(examples.testleading)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   835
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   836
canvasdemo(examples.leading)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   837
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   838
eg("""textobject.setTextRenderMode(mode)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   839
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   840
eg("""textobject.setRise(rise)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   841
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   842
eg("""textobject.setFillColor(aColor); 
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   843
textobject.setStrokeColor(self, aColor) 
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   844
# and similar""")
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   845
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   846
lesson('Paths and Lines')
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   847
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   848
eg(examples.teststar)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   849
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   850
canvasdemo(examples.star)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   851
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   852
eg(examples.testjoins)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   853
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   854
canvasdemo(examples.joins)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   855
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   856
eg(examples.testcaps)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   857
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   858
canvasdemo(examples.caps)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   859
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   860
eg(examples.testdashes)
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   861
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   862
canvasdemo(examples.dashes)
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   863
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   864
eg(examples.testpenciltip)
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   865
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   866
canvasdemo(examples.penciltip)
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   867
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   868
lesson('Rectangles, circles, ellipses')
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   869
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   870
eg(examples.testpencil)
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   871
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   872
canvasdemo(examples.pencil)
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   873
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   874
lesson('Bezier curves')
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   875
293
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   876
eg(examples.testbezier)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   877
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   878
canvasdemo(examples.bezier)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   879
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   880
eg(examples.testbezier2)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   881
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   882
canvasdemo(examples.bezier2)
84a2635a8c30 typos and more examples
aaron_watters
parents: 283
diff changeset
   883
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   884
lesson("Path object methods")
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   885
299
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   886
eg("""pathobject.moveTo(x,y)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   887
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   888
eg("""pathobject.lineTo(x,y)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   889
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   890
eg("""pathobject.curveTo(x1, y1, x2, y2, x3, y3) """)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   891
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   892
eg("""pathobject.arc(x1,y1, x2,y2, startAng=0, extent=90) """)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   893
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   894
eg("""pathobject.arcTo(x1,y1, x2,y2, startAng=0, extent=90) """)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   895
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   896
eg("""pathobject.rect(x, y, width, height) """)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   897
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   898
eg("""pathobject.ellipse(x, y, width, height)""")
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   899
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   900
eg("""pathobject.circle(x_cen, y_cen, r) """)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   901
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   902
eg("""pathobject.close() """)
909b83ce750c textobject and pathobject methods, among other things
aaron_watters
parents: 298
diff changeset
   903
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   904
eg(examples.testhand)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   905
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   906
canvasdemo(examples.hand)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   907
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   908
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   909
eg(examples.testhand2)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   910
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   911
canvasdemo(examples.hand2)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   912
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   913
298
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   914
##### FILL THEM IN
0e23c189f665 colors, line styles, more examples
aaron_watters
parents: 296
diff changeset
   915
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   916
lesson("...more lessons...")
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   917
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   918
#####################################################################################################3
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   919
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   920
lesson("Introduction to Platypus")
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   921
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   922
lesson("A very simple Flowable")
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   923
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   924
eg(examples.testnoteannotation)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   925
    
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   926
if __name__=="__main__":
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   927
    g = Guide()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   928
    g.go()
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   929