@@ -205,6 +205,7 @@ GCAgg::GCAgg(const Py::Object &gc, double dpi) :
205
205
_set_clip_path (gc);
206
206
_set_snap (gc);
207
207
_set_hatch_path (gc);
208
+ _set_sketch_params (gc);
208
209
}
209
210
210
211
@@ -375,6 +376,24 @@ GCAgg::_set_hatch_path(const Py::Object& gc)
375
376
throw Py::Exception ();
376
377
}
377
378
379
+ void
380
+ GCAgg::_set_sketch_params (const Py::Object& gc)
381
+ {
382
+ _VERBOSE (" GCAgg::_get_sketch_params" );
383
+
384
+ Py::Object method_obj = gc.getAttr (" get_sketch_params" );
385
+ Py::Callable method (method_obj);
386
+ Py::Object result = method.apply (Py::Tuple ());
387
+ if (result.ptr () == Py_None) {
388
+ sketch_scale = 0.0 ;
389
+ } else {
390
+ Py::Tuple sketch_params (result);
391
+ sketch_scale = Py::Float (sketch_params[0 ]);
392
+ sketch_length = Py::Float (sketch_params[1 ]);
393
+ sketch_randomness = Py::Float (sketch_params[2 ]);
394
+ }
395
+ }
396
+
378
397
379
398
const size_t
380
399
RendererAgg::PIXELS_PER_INCH (96 );
@@ -1397,6 +1416,7 @@ RendererAgg::draw_path(const Py::Tuple& args)
1397
1416
typedef PathSnapper<clipped_t > snapped_t ;
1398
1417
typedef PathSimplifier<snapped_t > simplify_t ;
1399
1418
typedef agg::conv_curve<simplify_t > curve_t ;
1419
+ typedef Sketch<curve_t > sketch_t ;
1400
1420
1401
1421
_VERBOSE (" RendererAgg::draw_path" );
1402
1422
args.verify_length (3 , 4 );
@@ -1430,10 +1450,11 @@ RendererAgg::draw_path(const Py::Tuple& args)
1430
1450
snapped_t snapped (clipped, gc.snap_mode , path.total_vertices (), snapping_linewidth);
1431
1451
simplify_t simplified (snapped, simplify, path.simplify_threshold ());
1432
1452
curve_t curve (simplified);
1453
+ sketch_t sketch (curve, gc.sketch_scale , gc.sketch_length , gc.sketch_randomness );
1433
1454
1434
1455
try
1435
1456
{
1436
- _draw_path (curve , has_clippath, face, gc);
1457
+ _draw_path (sketch , has_clippath, face, gc);
1437
1458
}
1438
1459
catch (const char * e)
1439
1460
{
@@ -2102,7 +2123,6 @@ RendererAgg::write_rgba(const Py::Tuple& args)
2102
2123
if ((py_file = npy_PyFile_OpenFile (py_fileobj.ptr (), (char *)" wb" )) == NULL ) {
2103
2124
throw Py::Exception ();
2104
2125
}
2105
- close_file = true ;
2106
2126
}
2107
2127
else
2108
2128
{
0 commit comments