@@ -205,6 +205,7 @@ GCAgg::GCAgg(const Py::Object &gc, double dpi) :
205205 _set_clip_path (gc);
206206 _set_snap (gc);
207207 _set_hatch_path (gc);
208+ _set_sketch_params (gc);
208209}
209210
210211
@@ -375,6 +376,24 @@ GCAgg::_set_hatch_path(const Py::Object& gc)
375376 throw Py::Exception ();
376377}
377378
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+
378397
379398const size_t
380399RendererAgg::PIXELS_PER_INCH (96 );
@@ -1397,6 +1416,7 @@ RendererAgg::draw_path(const Py::Tuple& args)
13971416 typedef PathSnapper<clipped_t > snapped_t ;
13981417 typedef PathSimplifier<snapped_t > simplify_t ;
13991418 typedef agg::conv_curve<simplify_t > curve_t ;
1419+ typedef Sketch<curve_t > sketch_t ;
14001420
14011421 _VERBOSE (" RendererAgg::draw_path" );
14021422 args.verify_length (3 , 4 );
@@ -1430,10 +1450,11 @@ RendererAgg::draw_path(const Py::Tuple& args)
14301450 snapped_t snapped (clipped, gc.snap_mode , path.total_vertices (), snapping_linewidth);
14311451 simplify_t simplified (snapped, simplify, path.simplify_threshold ());
14321452 curve_t curve (simplified);
1453+ sketch_t sketch (curve, gc.sketch_scale , gc.sketch_length , gc.sketch_randomness );
14331454
14341455 try
14351456 {
1436- _draw_path (curve , has_clippath, face, gc);
1457+ _draw_path (sketch , has_clippath, face, gc);
14371458 }
14381459 catch (const char * e)
14391460 {
@@ -2102,7 +2123,6 @@ RendererAgg::write_rgba(const Py::Tuple& args)
21022123 if ((py_file = npy_PyFile_OpenFile (py_fileobj.ptr (), (char *)" wb" )) == NULL ) {
21032124 throw Py::Exception ();
21042125 }
2105- close_file = true ;
21062126 }
21072127 else
21082128 {
0 commit comments