<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<body bgcolor="#ffffff" text="#000000">
this isnt a cario specific solution but if you only have a few
different, but very complex primitives that you need to hit test, could
render them as opaque to a separate surface each with their own color,
then sample the color to determine which primitive you hit. if you
need: you can scale up / down your drawing to increase / decrease the
amount of precision you need in your clicks. -- you do have to worry
about antialiasing at the edges of polys tho you
may ( i'm still new to using cairo ) be able to turn that off. <br>
Kalle Vahlman wrote:
<pre wrap="">2007/8/28, Deepankar Sharma <a class="moz-txt-link-rfc2396E" href="mailto:firstname.lastname@example.org"><email@example.com></a>:
<pre wrap="">I am just beginning to play with cairo and am currently battling with this
problem. I have a few cairo curves (drawn with cairo_curve_to) on the
screen. I am storing the begin, end, thickness and control points for the
curves. When I detect a click, I want to check if I just clicked over a
curve. In essence, I want to check if an x,y co-ordinate lies on a curve.
Any ideas / hints / approaches ?
Maybe you could keep the resulting paths around and use cairo_in_stroke()?
<a class="moz-txt-link-freetext" href="http://cairographics.org/manual/cairo-cairo-t.html#cairo-in-stroke">http://cairographics.org/manual/cairo-cairo-t.html#cairo-in-stroke</a>
Not sure how efficient it is though, nor if you really want that level
of precision (usually within user interfaces you'll want to allow the
user to miss a little to prevent frustration of pixel-perfect clicking
if the targets are small).