99
1010#include " CXX/Extensions.hxx"
1111
12+ #include " agg_conv_contour.h"
1213#include " agg_conv_curve.h"
1314#include " agg_conv_stroke.h"
1415#include " agg_conv_transform.h"
@@ -225,12 +226,13 @@ point_in_path_impl(const double tx, const double ty, T& path)
225226}
226227
227228inline bool
228- point_in_path (double x, double y, PathIterator& path,
229+ point_in_path (double x, double y, double r, PathIterator& path,
229230 const agg::trans_affine& trans)
230231{
231232 typedef agg::conv_transform<PathIterator> transformed_path_t ;
232233 typedef PathNanRemover<transformed_path_t > no_nans_t ;
233234 typedef agg::conv_curve<no_nans_t > curve_t ;
235+ typedef agg::conv_contour<curve_t > contour_t ;
234236
235237 if (path.total_vertices () < 3 )
236238 {
@@ -240,7 +242,9 @@ point_in_path(double x, double y, PathIterator& path,
240242 transformed_path_t trans_path (path, trans);
241243 no_nans_t no_nans_path (trans_path, true , path.has_curves ());
242244 curve_t curved_path (no_nans_path);
243- return point_in_path_impl (x, y, curved_path);
245+ contour_t contoured_path (curved_path);
246+ contoured_path.width (fabs (r));
247+ return point_in_path_impl (x, y, contoured_path);
244248}
245249
246250inline bool
@@ -263,14 +267,15 @@ point_on_path(double x, double y, double r, PathIterator& path,
263267Py::Object
264268_path_module::point_in_path (const Py::Tuple& args)
265269{
266- args.verify_length (4 );
270+ args.verify_length (5 );
267271
268272 double x = Py::Float (args[0 ]);
269273 double y = Py::Float (args[1 ]);
270- PathIterator path (args[2 ]);
271- agg::trans_affine trans = py_to_agg_transformation_matrix (args[3 ].ptr (), false );
274+ double r = Py::Float (args[2 ]);
275+ PathIterator path (args[3 ]);
276+ agg::trans_affine trans = py_to_agg_transformation_matrix (args[4 ].ptr (), false );
272277
273- if (::point_in_path (x, y, path, trans))
278+ if (::point_in_path (x, y, r, path, trans))
274279 {
275280 return Py::Int (1 );
276281 }
@@ -664,7 +669,7 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
664669
665670 if (filled)
666671 {
667- if (::point_in_path (x, y, path, trans))
672+ if (::point_in_path (x, y, radius, path, trans))
668673 result.append (Py::Int ((int )i));
669674 }
670675 else
@@ -696,7 +701,7 @@ path_in_path(PathIterator& a, const agg::trans_affine& atrans,
696701 b_curved.rewind (0 );
697702 while (b_curved.vertex (&x, &y) != agg::path_cmd_stop)
698703 {
699- if (!::point_in_path (x, y, a, atrans))
704+ if (!::point_in_path (x, y, 0.0 , a, atrans))
700705 return false ;
701706 }
702707
0 commit comments