<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<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>
<br>
Kalle Vahlman wrote:
<blockquote
cite="mid:177e83dd0708272340p67e9ddc3gbe6107a97721ada9@mail.gmail.com"
type="cite">
<pre wrap="">2007/8/28, Deepankar Sharma <a class="moz-txt-link-rfc2396E" href="mailto:deepankar.sharma@gmail.com"><deepankar.sharma@gmail.com></a>:
</pre>
<blockquote type="cite">
<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 ?
</pre>
</blockquote>
<pre wrap=""><!---->
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).
</pre>
</blockquote>
</body>
</html>