From 1cd9255f38389c42f13b3ca4f44677f52ff38d48 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Fri, 7 Apr 2023 14:25:02 +0200 Subject: [PATCH] Fix issue with sketch not working on PathCollection in Agg --- src/_backend_agg.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/_backend_agg.h b/src/_backend_agg.h index 6325df357b1b..5549978cfb80 100644 --- a/src/_backend_agg.h +++ b/src/_backend_agg.h @@ -919,6 +919,10 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc, typedef PathSnapper snapped_t; typedef agg::conv_curve snapped_curve_t; typedef agg::conv_curve curve_t; + typedef Sketch sketch_clipped_t; + typedef Sketch sketch_curve_t; + typedef Sketch sketch_snapped_t; + typedef Sketch sketch_snapped_curve_t; size_t Npaths = path_generator.num_paths(); size_t Noffsets = safe_first_shape(offsets); @@ -994,31 +998,29 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc, } } + gc.isaa = antialiaseds(i % Naa); + transformed_path_t tpath(path, trans); + nan_removed_t nan_removed(tpath, true, has_codes); + clipped_t clipped(nan_removed, do_clip, width, height); if (check_snap) { - gc.isaa = antialiaseds(i % Naa); - - transformed_path_t tpath(path, trans); - nan_removed_t nan_removed(tpath, true, has_codes); - clipped_t clipped(nan_removed, do_clip, width, height); snapped_t snapped( clipped, gc.snap_mode, path.total_vertices(), points_to_pixels(gc.linewidth)); if (has_codes) { snapped_curve_t curve(snapped); - _draw_path(curve, has_clippath, face, gc); + sketch_snapped_curve_t sketch(curve, gc.sketch.scale, gc.sketch.length, gc.sketch.randomness); + _draw_path(sketch, has_clippath, face, gc); } else { - _draw_path(snapped, has_clippath, face, gc); + sketch_snapped_t sketch(snapped, gc.sketch.scale, gc.sketch.length, gc.sketch.randomness); + _draw_path(sketch, has_clippath, face, gc); } } else { - gc.isaa = antialiaseds(i % Naa); - - transformed_path_t tpath(path, trans); - nan_removed_t nan_removed(tpath, true, has_codes); - clipped_t clipped(nan_removed, do_clip, width, height); if (has_codes) { curve_t curve(clipped); - _draw_path(curve, has_clippath, face, gc); + sketch_curve_t sketch(curve, gc.sketch.scale, gc.sketch.length, gc.sketch.randomness); + _draw_path(sketch, has_clippath, face, gc); } else { - _draw_path(clipped, has_clippath, face, gc); + sketch_clipped_t sketch(clipped, gc.sketch.scale, gc.sketch.length, gc.sketch.randomness); + _draw_path(sketch, has_clippath, face, gc); } } }