@@ -1165,7 +1165,6 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1165
1165
static PyObject*
1166
1166
GraphicsContext_draw_path_collection (GraphicsContext* self, PyObject* args)
1167
1167
{
1168
- PyObject* master_transform;
1169
1168
PyObject* cliprect;
1170
1169
PyObject* clippath;
1171
1170
PyObject* clippath_transform;
@@ -1187,19 +1186,18 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1187
1186
return NULL ;
1188
1187
}
1189
1188
1190
- if (!PyArg_ParseTuple (args, " OOOOOOOOOOOOO" , &master_transform,
1191
- &cliprect,
1192
- &clippath,
1193
- &clippath_transform,
1194
- &paths,
1195
- &transforms,
1196
- &offsets,
1197
- &offset_transform,
1198
- &facecolors,
1199
- &edgecolors,
1200
- &linewidths,
1201
- &linestyles,
1202
- &antialiaseds))
1189
+ if (!PyArg_ParseTuple (args, " OOOOOOOOOOOO" , &cliprect,
1190
+ &clippath,
1191
+ &clippath_transform,
1192
+ &paths,
1193
+ &transforms,
1194
+ &offsets,
1195
+ &offset_transform,
1196
+ &facecolors,
1197
+ &edgecolors,
1198
+ &linewidths,
1199
+ &linestyles,
1200
+ &antialiaseds))
1203
1201
return NULL ;
1204
1202
1205
1203
int ok = 1 ;
@@ -1235,43 +1233,22 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1235
1233
PyErr_SetString (PyExc_ValueError, " transforms must be a sequence object" );
1236
1234
return NULL ;
1237
1235
}
1238
- Py_ssize_t Ntransforms = PySequence_Size (transforms);
1239
-
1240
- CGContextSaveGState (cr);
1241
- /* ------------------- Set master transform --------------------------- */
1242
-
1243
- if (Ntransforms)
1236
+ const Py_ssize_t Ntransforms = PySequence_Size (transforms);
1237
+ if (Ntransforms==0 )
1244
1238
{
1245
- CGAffineTransform master;
1246
- double a, b, c, d, tx, ty;
1247
- PyObject* values = PyObject_CallMethod (master_transform, " to_values" , " " );
1248
- if (!values)
1249
- {
1250
- ok = 0 ;
1251
- goto exit ;
1252
- }
1253
- if (!PyTuple_Check (values))
1254
- {
1255
- Py_DECREF (values);
1256
- ok = 0 ;
1257
- goto exit ;
1258
- }
1259
- /* CGAffineTransform contains CGFloat; cannot use master directly */
1260
- ok = PyArg_ParseTuple (values, " dddddd" , &a, &b, &c, &d, &tx, &ty);
1261
- Py_DECREF (values);
1262
- master.a = a;
1263
- master.b = b;
1264
- master.c = c;
1265
- master.d = d;
1266
- master.tx = tx;
1267
- master.ty = ty;
1268
- if (!ok) goto exit ;
1269
- CGContextConcatCTM (cr, master);
1239
+ PyErr_SetString (PyExc_ValueError, " transforms should contain at least one item" );
1240
+ return NULL ;
1270
1241
}
1271
1242
1272
- /* ------------------- Check offsets array ---------------------------- */
1243
+ /* ------------------- Read drawing arrays ---------------------------- */
1273
1244
1245
+ CGContextSaveGState (cr);
1274
1246
offsets = PyArray_FromObject (offsets, NPY_DOUBLE, 0 , 2 );
1247
+ facecolors = PyArray_FromObject (facecolors, NPY_DOUBLE, 1 , 2 );
1248
+ edgecolors = PyArray_FromObject (edgecolors, NPY_DOUBLE, 1 , 2 );
1249
+
1250
+ /* ------------------- Check offsets array ---------------------------- */
1251
+
1275
1252
if (!offsets ||
1276
1253
(PyArray_NDIM (offsets)==2 && PyArray_DIM (offsets, 1 )!=2 ) ||
1277
1254
(PyArray_NDIM (offsets)==1 && PyArray_DIM (offsets, 0 )!=0 ))
@@ -1282,11 +1259,36 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1282
1259
}
1283
1260
const Py_ssize_t Noffsets = PyArray_DIM (offsets, 0 );
1284
1261
1262
+ /* ------------------- Check facecolors array ------------------------- */
1263
+
1264
+ if (!facecolors ||
1265
+ (PyArray_NDIM (facecolors)==1 && PyArray_DIM (facecolors, 0 )!=0 ) ||
1266
+ (PyArray_NDIM (facecolors)==2 && PyArray_DIM (facecolors, 1 )!=4 ))
1267
+ {
1268
+ PyErr_SetString (PyExc_ValueError, " Facecolors must by a Nx4 numpy array or empty" );
1269
+ ok = 0 ;
1270
+ goto exit ;
1271
+ }
1272
+
1273
+ /* ------------------- Check edgecolors array ------------------------- */
1274
+
1275
+ if (!edgecolors ||
1276
+ (PyArray_NDIM (edgecolors)==1 && PyArray_DIM (edgecolors, 0 )!=0 ) ||
1277
+ (PyArray_NDIM (edgecolors)==2 && PyArray_DIM (edgecolors, 1 )!=4 ))
1278
+ {
1279
+ PyErr_SetString (PyExc_ValueError, " Edgecolors must by a Nx4 numpy array or empty" );
1280
+ ok = 0 ;
1281
+ goto exit ;
1282
+ }
1283
+
1284
+ /* -------------------------------------------------------------------- */
1285
+
1286
+ if (Npaths==0 ) goto exit ; /* Nothing to do */
1287
+
1285
1288
/* -------------------------------------------------------------------- */
1286
1289
1287
1290
Np = Npaths > Ntransforms ? Npaths : Ntransforms;
1288
1291
N = Np > Noffsets ? Np : Noffsets;
1289
- if (N < Ntransforms) Ntransforms = N;
1290
1292
1291
1293
p = malloc (Np*sizeof (CGMutablePathRef ));
1292
1294
if (!p)
@@ -1305,35 +1307,22 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1305
1307
ok = 0 ;
1306
1308
goto exit ;
1307
1309
}
1308
- if (Ntransforms)
1310
+ transform = PySequence_ITEM (transforms, i % Ntransforms);
1311
+ if (!transform)
1309
1312
{
1310
- transform = PySequence_ITEM (transforms, i % Ntransforms);
1311
- if (!transform)
1312
- {
1313
- PyErr_SetString (PyExc_RuntimeError,
1314
- " failed to obtain transform" );
1315
- ok = 0 ;
1316
- goto exit ;
1317
- }
1318
- iterator = get_path_iterator (path,
1319
- transform,
1320
- 1 ,
1321
- 0 ,
1322
- rect,
1323
- mode,
1324
- 0 );
1325
- Py_DECREF (transform);
1326
- }
1327
- else
1328
- {
1329
- iterator = get_path_iterator (path,
1330
- master_transform,
1331
- 1 ,
1332
- 0 ,
1333
- rect,
1334
- mode,
1335
- 0 );
1313
+ PyErr_SetString (PyExc_RuntimeError, " failed to obtain transform" );
1314
+ Py_DECREF (path);
1315
+ ok = 0 ;
1316
+ goto exit ;
1336
1317
}
1318
+ iterator = get_path_iterator (path,
1319
+ transform,
1320
+ 1 ,
1321
+ 0 ,
1322
+ rect,
1323
+ mode,
1324
+ 0 );
1325
+ Py_DECREF (transform);
1337
1326
Py_DECREF (path);
1338
1327
if (!iterator)
1339
1328
{
@@ -1381,30 +1370,6 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1381
1370
if (n > 0 ) CGContextClip (cr);
1382
1371
}
1383
1372
1384
- /* ------------------- Check facecolors array ------------------------- */
1385
-
1386
- facecolors = PyArray_FromObject (facecolors, NPY_DOUBLE, 1 , 2 );
1387
- if (!facecolors ||
1388
- (PyArray_NDIM (facecolors)==1 && PyArray_DIM (facecolors, 0 )!=0 ) ||
1389
- (PyArray_NDIM (facecolors)==2 && PyArray_DIM (facecolors, 1 )!=4 ))
1390
- {
1391
- PyErr_SetString (PyExc_ValueError, " Facecolors must by a Nx4 numpy array or empty" );
1392
- ok = 0 ;
1393
- goto exit ;
1394
- }
1395
-
1396
- /* ------------------- Check edgecolors array ------------------------- */
1397
-
1398
- edgecolors = PyArray_FromObject (edgecolors, NPY_DOUBLE, 1 , 2 );
1399
- if (!edgecolors ||
1400
- (PyArray_NDIM (edgecolors)==1 && PyArray_DIM (edgecolors, 0 )!=0 ) ||
1401
- (PyArray_NDIM (edgecolors)==2 && PyArray_DIM (edgecolors, 1 )!=4 ))
1402
- {
1403
- PyErr_SetString (PyExc_ValueError, " Edgecolors must by a Nx4 numpy array or empty" );
1404
- ok = 0 ;
1405
- goto exit ;
1406
- }
1407
-
1408
1373
/* ------------------- Check the other arguments ---------------------- */
1409
1374
1410
1375
if (!PySequence_Check (linewidths))
@@ -1610,7 +1575,6 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
1610
1575
free (p);
1611
1576
}
1612
1577
if (!ok) return NULL ;
1613
-
1614
1578
Py_INCREF (Py_None);
1615
1579
return Py_None;
1616
1580
}
@@ -2390,7 +2354,6 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
2390
2354
PyErr_SetString (PyExc_RuntimeError, " ATSUDrawText failed" );
2391
2355
return NULL ;
2392
2356
}
2393
-
2394
2357
Py_INCREF (Py_None);
2395
2358
return Py_None;
2396
2359
}
0 commit comments