reportlab/demos/pythonpoint/customshapes.py
author rgbecker
Wed, 25 Oct 2000 08:57:46 +0000
changeset 494 54257447cfe9
parent 76 dff7aff2fe03
permissions -rw-r--r--
Changed to indirect copyright
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 76
diff changeset
     1
#copyright ReportLab Inc. 2000
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 76
diff changeset
     2
#see license.txt for license details
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 76
diff changeset
     3
#history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/demos/pythonpoint/customshapes.py?cvsroot=reportlab
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 76
diff changeset
     4
#$Header: /tmp/reportlab/reportlab/demos/pythonpoint/Attic/customshapes.py,v 1.3 2000/10/25 08:57:44 rgbecker Exp $
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 76
diff changeset
     5
__version__=''' $Id: customshapes.py,v 1.3 2000/10/25 08:57:44 rgbecker Exp $ '''
75
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
     6
# xml parser stuff for PythonPoint
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
     7
# PythonPoint Markup Language!
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
     8
__doc__="""
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
     9
This demonstrates a custom shape for use with the <customshape> tag.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    10
The shape must fulfil a very simple interface, which may change in
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    11
future.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    12
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    13
The XML tag currently has this form:
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    14
        <customshape
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    15
            module="customshapes.py"
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    16
            class = "MyShape"
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    17
            initargs="(100,200,3)"
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    18
        />
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    19
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    20
PythonPoint will look in the given module for the given class,
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    21
evaluate the arguments string and pass it to the constructor.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    22
Then, it will call
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    23
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    24
    object.drawOn(canvas)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    25
    
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    26
Thus your object must be fully defined by the constructor.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    27
For this one, we pass three argumenyts: x, y and scale.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    28
This does a five-tile jigsaw over which words can be overlaid; based
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    29
on work done for a customer's presentation.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    30
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    31
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    32
"""
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    33
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    34
import reportlab.pdfgen.canvas
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    35
from reportlab.lib import colors
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    36
## custom shape for use with PythonPoint.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    37
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    38
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    39
class Jigsaw:
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    40
    """This draws a jigsaw patterm.  By default it is centred on 0,0
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    41
    and has dimensions of 200 x 140; use the x/y/scale attributes
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    42
    to move it around."""
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    43
    #Using my usual bulldozer coding style - I am sure a mathematician could
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    44
    #derive an elegant way to draw this, but I just took a ruler, guessed at
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    45
    #the control points, and reflected a few lists at the interactive prompt.
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    46
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    47
    def __init__(self, x, y, scale=1):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    48
        self.width = 200
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    49
        self.height = 140
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    50
        self.x = x
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    51
        self.y = y
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    52
        self.scale = scale
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    53
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    54
    def drawOn(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    55
        canvas.saveState()
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    56
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    57
        canvas.setFont('Helvetica-Bold',24)        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    58
        canvas.drawString(100,700,'A Custom Shape')
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    59
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    60
        canvas.translate(self.x, self.y)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    61
        canvas.scale(self.scale, self.scale)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    62
        self.drawBounds(canvas)        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    63
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    64
        self.drawCentre(canvas)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    65
        self.drawTopLeft(canvas)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    66
        self.drawBottomLeft(canvas)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    67
        self.drawBottomRight(canvas)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    68
        self.drawTopRight(canvas)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    69
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    70
        canvas.restoreState()
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    71
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    72
    def curveThrough(self, path, pointlist):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    73
        """Helper to curve through set of control points."""
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    74
        assert len(pointlist) % 3 == 1, "No. of points must be 3n+1 for integer n"
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    75
        (x,y) = pointlist[0]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    76
        path.moveTo(x, y)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    77
        idx = 1
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    78
        while idx < len(pointlist)-2:
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    79
            p1, p2, p3 = pointlist[idx:idx+3]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    80
            path.curveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1])
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    81
            idx = idx + 3
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    82
            
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    83
    def drawShape(self, canvas, controls, color):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    84
        """Utlity to draw a closed shape through a list of control points;
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    85
        extends the previous proc"""
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    86
        canvas.setFillColor(color)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    87
        p = canvas.beginPath()
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    88
        self.curveThrough(p, controls)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    89
        p.close()
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    90
        canvas.drawPath(p, stroke=1, fill=1)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    91
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    92
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    93
    def drawBounds(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    94
        """Guidelines to help me draw - not needed in production"""
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    95
        canvas.setStrokeColor(colors.red)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    96
        canvas.rect(-100,-70,200,140)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    97
        canvas.line(-100,0,100,0)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    98
        canvas.line(0,70,0,-70)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
    99
        canvas.setStrokeColor(colors.black)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   100
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   101
    
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   102
    def drawCentre(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   103
        controls = [ (0,50),   #top
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   104
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   105
                #top right edge - duplicated for that corner piece                     
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   106
                (5,50),(10,45),(10,40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   107
                (10,35),(15,30),(20,30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   108
                (25,30),(30,25),(30,20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   109
                (30,15),(35,10),(40,10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   110
                (45,10),(50,5),(50,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   111
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   112
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   113
                #bottom right edge
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   114
                (50, -5), (45,-10), (40,-10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   115
                (35,-10), (30,-15), (30, -20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   116
                (30,-25), (25,-30), (20,-30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   117
                (15,-30), (10,-35), (10,-40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   118
                (10,-45),(5,-50),(0,-50),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   119
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   120
                #bottom left                     
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   121
                (-5,-50),(-10,-45),(-10,-40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   122
                (-10,-35),(-15,-30),(-20,-30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   123
                (-25,-30),(-30,-25),(-30,-20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   124
                (-30,-15),(-35,-10),(-40,-10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   125
                (-45,-10),(-50,-5),(-50,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   126
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   127
                #top left
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   128
                (-50,5),(-45,10),(-40,10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   129
                (-35,10),(-30,15),(-30,20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   130
                (-30,25),(-25,30),(-20,30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   131
                (-15,30),(-10,35),(-10,40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   132
                (-10,45),(-5,50),(0,50)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   133
                     
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   134
                ]            
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   135
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   136
        self.drawShape(canvas, controls, colors.yellow)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   137
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   138
    def drawTopLeft(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   139
        controls = [(-100,70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   140
            (-100,69),(-100,1),(-100,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   141
            (-99,0),(-91,0),(-90,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   142
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   143
            #jigsaw interlock - 4 sections
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   144
            (-90,5),(-92,5),(-92,10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   145
            (-92,15), (-85,15), (-80,15),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   146
            (-75,15),(-68,15),(-68,10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   147
            (-68,5),(-70,5),(-70,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   148
            (-69,0),(-51,0),(-50,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   149
            
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   150
            #five distinct curves
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   151
            (-50,5),(-45,10),(-40,10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   152
            (-35,10),(-30,15),(-30,20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   153
            (-30,25),(-25,30),(-20,30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   154
            (-15,30),(-10,35),(-10,40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   155
            (-10,45),(-5,50),(0,50),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   156
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   157
            (0,51),(0,69),(0,70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   158
            (-1,70),(-99,70),(-100,70)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   159
            ]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   160
        self.drawShape(canvas, controls, colors.teal)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   161
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   162
    def drawBottomLeft(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   163
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   164
        controls = [(-100,-70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   165
            (-99,-70),(-1,-70),(0,-70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   166
            (0,-69),(0,-51),(0,-50),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   167
            
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   168
            #wavyline
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   169
            (-5,-50),(-10,-45),(-10,-40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   170
            (-10,-35),(-15,-30),(-20,-30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   171
            (-25,-30),(-30,-25),(-30,-20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   172
            (-30,-15),(-35,-10),(-40,-10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   173
            (-45,-10),(-50,-5),(-50,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   174
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   175
            #jigsaw interlock - 4 sections
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   176
                    
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   177
            (-51, 0), (-69, 0), (-70, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   178
            (-70, 5), (-68, 5), (-68, 10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   179
            (-68, 15), (-75, 15), (-80, 15),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   180
            (-85, 15), (-92, 15), (-92, 10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   181
            (-92, 5), (-90, 5), (-90, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   182
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   183
            (-91,0),(-99,0),(-100,0)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   184
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   185
            ]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   186
        self.drawShape(canvas, controls, colors.green)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   187
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   188
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   189
    def drawBottomRight(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   190
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   191
        controls = [ (100,-70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   192
            (100,-69),(100,-1),(100,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   193
            (99,0),(91,0),(90,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   194
            
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   195
            #jigsaw interlock - 4 sections
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   196
            (90, -5), (92, -5), (92, -10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   197
            (92, -15), (85, -15), (80, -15),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   198
            (75, -15), (68, -15), (68, -10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   199
            (68, -5), (70, -5), (70, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   200
            (69, 0), (51, 0), (50, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   201
                    
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   202
            #wavyline
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   203
            (50, -5), (45,-10), (40,-10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   204
            (35,-10), (30,-15), (30, -20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   205
            (30,-25), (25,-30), (20,-30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   206
            (15,-30), (10,-35), (10,-40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   207
            (10,-45),(5,-50),(0,-50),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   208
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   209
            (0,-51), (0,-69), (0,-70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   210
            (1,-70),(99,-70),(100,-70)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   211
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   212
            ]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   213
        self.drawShape(canvas, controls, colors.navy)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   214
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   215
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   216
    def drawBottomLeft(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   217
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   218
        controls = [(-100,-70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   219
            (-99,-70),(-1,-70),(0,-70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   220
            (0,-69),(0,-51),(0,-50),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   221
            
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   222
            #wavyline
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   223
            (-5,-50),(-10,-45),(-10,-40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   224
            (-10,-35),(-15,-30),(-20,-30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   225
            (-25,-30),(-30,-25),(-30,-20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   226
            (-30,-15),(-35,-10),(-40,-10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   227
            (-45,-10),(-50,-5),(-50,0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   228
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   229
            #jigsaw interlock - 4 sections
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   230
                    
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   231
            (-51, 0), (-69, 0), (-70, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   232
            (-70, 5), (-68, 5), (-68, 10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   233
            (-68, 15), (-75, 15), (-80, 15),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   234
            (-85, 15), (-92, 15), (-92, 10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   235
            (-92, 5), (-90, 5), (-90, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   236
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   237
            (-91,0),(-99,0),(-100,0)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   238
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   239
            ]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   240
        self.drawShape(canvas, controls, colors.green)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   241
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   242
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   243
    def drawTopRight(self, canvas):
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   244
        controls = [(100, 70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   245
            (99, 70), (1, 70), (0, 70),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   246
            (0, 69), (0, 51), (0, 50),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   247
            (5, 50), (10, 45), (10, 40),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   248
            (10, 35), (15, 30), (20, 30),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   249
            (25, 30), (30, 25), (30, 20),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   250
            (30, 15), (35, 10), (40, 10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   251
            (45, 10), (50, 5), (50, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   252
            (51, 0), (69, 0), (70, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   253
            (70, -5), (68, -5), (68, -10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   254
            (68, -15), (75, -15), (80, -15),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   255
            (85, -15), (92, -15), (92, -10),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   256
            (92, -5), (90, -5), (90, 0),
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   257
            (91, 0), (99, 0), (100, 0)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   258
                    ]
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   259
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   260
        self.drawShape(canvas, controls, colors.magenta)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   261
        
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   262
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   263
def run():
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   264
    c = reportlab.pdfgen.canvas.Canvas('customshape.pdf')
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   265
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   266
    J = Jigsaw(300, 540, 2)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   267
    J.drawOn(c)
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   268
    c.save()
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   269
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   270
if __name__ == '__main__':
daedbd33f33e Added several new shape tags.
andy_robinson
parents:
diff changeset
   271
    run()
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 76
diff changeset
   272