@@ -1158,132 +1158,132 @@ def insertPage(
1158
1158
)
1159
1159
return rc
1160
1160
1161
- def drawLine (page , p1 , p2 , color = None , dashes = None , width = 1 , roundCap = False , overlay = True , morph = None ):
1161
+ def drawLine (page , p1 , p2 , color = None , dashes = None , width = 1 , lineCap = 0 , lineJoin = 0 , overlay = True , morph = None , roundcap = None ):
1162
1162
"""Draw a line from point p1 to point p2.
1163
1163
"""
1164
1164
img = page .newShape ()
1165
1165
p = img .drawLine (Point (p1 ), Point (p2 ))
1166
1166
img .finish (color = color , dashes = dashes , width = width , closePath = False ,
1167
- roundCap = roundCap , morph = morph )
1167
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundcap )
1168
1168
img .commit (overlay )
1169
1169
1170
1170
return p
1171
1171
1172
1172
def drawSquiggle (page , p1 , p2 , breadth = 2 , color = None , dashes = None ,
1173
- width = 1 , roundCap = False , overlay = True , morph = None ):
1173
+ width = 1 , lineCap = 0 , lineJoin = 0 , overlay = True , morph = None , roundCap = None ):
1174
1174
"""Draw a squiggly line from point p1 to point p2.
1175
1175
"""
1176
1176
img = page .newShape ()
1177
1177
p = img .drawSquiggle (Point (p1 ), Point (p2 ), breadth = breadth )
1178
1178
img .finish (color = color , dashes = dashes , width = width , closePath = False ,
1179
- roundCap = roundCap , morph = morph )
1179
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap )
1180
1180
img .commit (overlay )
1181
1181
1182
1182
return p
1183
1183
1184
1184
def drawZigzag (page , p1 , p2 , breadth = 2 , color = None , dashes = None ,
1185
- width = 1 , roundCap = False , overlay = True , morph = None ):
1185
+ width = 1 , lineCap = 0 , lineJoin = 0 , overlay = True , morph = None , roundCap = None ):
1186
1186
"""Draw a zigzag line from point p1 to point p2.
1187
1187
"""
1188
1188
img = page .newShape ()
1189
1189
p = img .drawZigzag (Point (p1 ), Point (p2 ), breadth = breadth )
1190
1190
img .finish (color = color , dashes = dashes , width = width , closePath = False ,
1191
- roundCap = roundCap , morph = morph )
1191
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap )
1192
1192
img .commit (overlay )
1193
1193
1194
1194
return p
1195
1195
1196
1196
def drawRect (page , rect , color = None , fill = None , dashes = None ,
1197
- width = 1 , roundCap = False , morph = None , overlay = True ):
1197
+ width = 1 , lineCap = 0 , lineJoin = 0 , morph = None , roundCap = None , overlay = True ):
1198
1198
"""Draw a rectangle.
1199
1199
"""
1200
1200
img = page .newShape ()
1201
1201
Q = img .drawRect (Rect (rect ))
1202
1202
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1203
- roundCap = roundCap , morph = morph )
1203
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap )
1204
1204
img .commit (overlay )
1205
1205
1206
1206
return Q
1207
1207
1208
1208
def drawQuad (page , quad , color = None , fill = None , dashes = None ,
1209
- width = 1 , roundCap = False , morph = None , overlay = True ):
1209
+ width = 1 , lineCap = 0 , lineJoin = 0 , morph = None , roundCap = None , overlay = True ):
1210
1210
"""Draw a quadrilateral.
1211
1211
"""
1212
1212
img = page .newShape ()
1213
1213
Q = img .drawQuad (Quad (quad ))
1214
1214
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1215
- roundCap = roundCap , morph = morph )
1215
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap )
1216
1216
img .commit (overlay )
1217
1217
1218
1218
return Q
1219
1219
1220
1220
def drawPolyline (page , points , color = None , fill = None , dashes = None ,
1221
- width = 1 , morph = None , roundCap = False , overlay = True ,
1221
+ width = 1 , morph = None , lineCap = 0 , lineJoin = 0 , roundCap = None , overlay = True ,
1222
1222
closePath = False ):
1223
1223
"""Draw multiple connected line segments.
1224
1224
"""
1225
1225
img = page .newShape ()
1226
1226
Q = img .drawPolyline (points )
1227
1227
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1228
- roundCap = roundCap , morph = morph , closePath = closePath )
1228
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap , closePath = closePath )
1229
1229
img .commit (overlay )
1230
1230
1231
1231
return Q
1232
1232
1233
1233
def drawCircle (page , center , radius , color = None , fill = None ,
1234
1234
morph = None , dashes = None , width = 1 ,
1235
- roundCap = False , overlay = True ):
1235
+ lineCap = 0 , lineJoin = 0 , roundCap = None , overlay = True ):
1236
1236
"""Draw a circle given its center and radius.
1237
1237
"""
1238
1238
img = page .newShape ()
1239
1239
Q = img .drawCircle (Point (center ), radius )
1240
1240
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1241
- roundCap = roundCap , morph = morph )
1241
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap )
1242
1242
img .commit (overlay )
1243
1243
return Q
1244
1244
1245
1245
def drawOval (page , rect , color = None , fill = None , dashes = None ,
1246
- morph = None ,
1247
- width = 1 , roundCap = False , overlay = True ):
1246
+ morph = None ,roundCap = None ,
1247
+ width = 1 , lineCap = 0 , lineJoin = 0 , overlay = True ):
1248
1248
"""Draw an oval given its containing rectangle or quad.
1249
1249
"""
1250
1250
img = page .newShape ()
1251
1251
Q = img .drawOval (rect )
1252
1252
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1253
- roundCap = roundCap , morph = morph )
1253
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap )
1254
1254
img .commit (overlay )
1255
1255
1256
1256
return Q
1257
1257
1258
1258
def drawCurve (page , p1 , p2 , p3 , color = None , fill = None , dashes = None ,
1259
- width = 1 , morph = None , closePath = False ,
1260
- roundCap = False , overlay = True ):
1259
+ width = 1 , morph = None , roundCap = None , closePath = False ,
1260
+ lineCap = 0 , lineJoin = 0 , overlay = True ):
1261
1261
"""Draw a special Bezier curve from p1 to p3, generating control points on lines p1 to p2 and p2 to p3.
1262
1262
"""
1263
1263
img = page .newShape ()
1264
1264
Q = img .drawCurve (Point (p1 ), Point (p2 ), Point (p3 ))
1265
1265
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1266
- roundCap = roundCap , morph = morph , closePath = closePath )
1266
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap , closePath = closePath )
1267
1267
img .commit (overlay )
1268
1268
1269
1269
return Q
1270
1270
1271
1271
def drawBezier (page , p1 , p2 , p3 , p4 , color = None , fill = None ,
1272
- dashes = None , width = 1 , morph = None ,
1273
- closePath = False , roundCap = False , overlay = True ):
1272
+ dashes = None , width = 1 , morph = None , roundCap = None ,
1273
+ closePath = False , lineCap = 0 , lineJoin = 0 , overlay = True ):
1274
1274
"""Draw a general cubic Bezier curve from p1 to p4 using control points p2 and p3.
1275
1275
"""
1276
1276
img = page .newShape ()
1277
1277
Q = img .drawBezier (Point (p1 ), Point (p2 ), Point (p3 ), Point (p4 ))
1278
1278
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1279
- roundCap = roundCap , morph = morph , closePath = closePath )
1279
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap , closePath = closePath )
1280
1280
img .commit (overlay )
1281
1281
1282
1282
return Q
1283
1283
1284
1284
def drawSector (page , center , point , beta , color = None , fill = None ,
1285
- dashes = None , fullSector = True , morph = None ,
1286
- width = 1 , closePath = False , roundCap = False , overlay = True ):
1285
+ dashes = None , fullSector = True , morph = None , roundCap = None ,
1286
+ width = 1 , closePath = False , lineCap = 0 , lineJoin = 0 , overlay = True ):
1287
1287
""" Draw a circle sector given circle center, one arc end point and the angle of the arc.
1288
1288
1289
1289
Parameters:
@@ -1295,7 +1295,7 @@ def drawSector(page, center, point, beta, color=None, fill=None,
1295
1295
img = page .newShape ()
1296
1296
Q = img .drawSector (Point (center ), Point (point ), beta , fullSector = fullSector )
1297
1297
img .finish (color = color , fill = fill , dashes = dashes , width = width ,
1298
- roundCap = roundCap , morph = morph , closePath = closePath )
1298
+ lineCap = lineCap , lineJoin = lineJoin , morph = morph , roundCap = roundCap , closePath = closePath )
1299
1299
img .commit (overlay )
1300
1300
1301
1301
return Q
@@ -2060,11 +2060,13 @@ def updateRect(self, x):
2060
2060
2061
2061
else :
2062
2062
if len (x ) == 2 :
2063
+ x = Point (x )
2063
2064
self .rect .x0 = min (self .rect .x0 , x .x )
2064
2065
self .rect .y0 = min (self .rect .y0 , x .y )
2065
2066
self .rect .x1 = max (self .rect .x1 , x .x )
2066
2067
self .rect .y1 = max (self .rect .y1 , x .y )
2067
2068
else :
2069
+ x = Rect (x )
2068
2070
self .rect .x0 = min (self .rect .x0 , x .x0 )
2069
2071
self .rect .y0 = min (self .rect .y0 , x .y0 )
2070
2072
self .rect .x1 = max (self .rect .x1 , x .x1 )
@@ -2742,7 +2744,9 @@ def finish(
2742
2744
width = 1 ,
2743
2745
color = None ,
2744
2746
fill = None ,
2745
- roundCap = False ,
2747
+ lineCap = 0 ,
2748
+ lineJoin = 0 ,
2749
+ roundCap = None ,
2746
2750
dashes = None ,
2747
2751
even_odd = False ,
2748
2752
morph = None ,
@@ -2757,15 +2761,22 @@ def finish(
2757
2761
"""
2758
2762
if self .draw_cont == "" : # treat empty contents as no-op
2759
2763
return
2760
-
2764
+ if roundCap is not None :
2765
+ warnings .warn ("roundCap is replaced by lineCap / lineJoin" , DeprecationWarning )
2766
+ lineCap = lineJoin = roundCap
2767
+
2768
+ if width == 0 : # border color makes no sense then
2769
+ color = None
2770
+ elif color is None : # vice versa
2771
+ width = 0
2761
2772
color_str = ColorCode (color , "c" ) # ensure proper color string
2762
2773
fill_str = ColorCode (fill , "f" ) # ensure proper fill string
2763
2774
2764
- if width != 1 :
2775
+ if width not in ( 0 , 1 ) :
2765
2776
self .draw_cont += "%g w\n " % width
2766
2777
2767
- if roundCap :
2768
- self .draw_cont += "%i J %i j\n " % (roundCap , roundCap )
2778
+ if lineCap + lineJoin > 0 :
2779
+ self .draw_cont += "%i J %i j\n " % (lineCap , lineJoin )
2769
2780
2770
2781
if dashes is not None and len (dashes ) > 0 :
2771
2782
self .draw_cont += "%s d\n " % dashes
@@ -2779,10 +2790,16 @@ def finish(
2779
2790
2780
2791
if fill is not None :
2781
2792
self .draw_cont += fill_str
2782
- if not even_odd :
2783
- self .draw_cont += "B\n "
2793
+ if color is not None :
2794
+ if not even_odd :
2795
+ self .draw_cont += "B\n "
2796
+ else :
2797
+ self .draw_cont += "B*\n "
2784
2798
else :
2785
- self .draw_cont += "B*\n "
2799
+ if not even_odd :
2800
+ self .draw_cont += "f\n "
2801
+ else :
2802
+ self .draw_cont += "f*\n "
2786
2803
else :
2787
2804
self .draw_cont += "S\n "
2788
2805
0 commit comments