[cairo] Cairo vs. Canvas

Andrew Birkett andy at nobugs.org
Sun Sep 12 10:41:13 PDT 2004


Hi,

I am excited by the idea of a high-quality cross-platform drawing
package, but I'd like to ask if cairo is intended purely as a drawing
library, or if there will also be support to allow interactive
applications to discover which drawing primitives are at/near a
particular point (eg. under the mouse cursor hotspot)?

I have looked in the archives and found some early discussion of this
topic, eg. 
http://cairographics.org/pipermail/cairo/2003-October/000607.html.  Has
there been any concrete decisions made on this since?

As a simple example, one of the apps I work on draws electrical circuit
diagrams onscreen.  We need to detect when the mouse is within n pixels
of a wire (a polyline onscreen) in order to change mouse cursor,
indicating that the user can select the wire.  If I use cairo to draw
the line with certain thickness/join/cap then only cairo knows exactly
which floating-point coordinates are contained within the line.  So
cairo would have to allow the app to ask questions about what painted,
otherwise the app would be duplicating and second-guessing what cairo
had already done.

I have two other related points which might be relevant.  Firstly,
point-in-path isn't enough to answer "which paths are within 5 (units)
of this point" which is required to allow users to select thin one-pixel
thick wires without have to exactly position the mouse over it.  Also,
if there are multiple paths nearby, it would be useful to find the
distance to the nearest point on each. Secondly, marquee-select (eg.
dragging out a dotted rectangle to select multiple items) requires the
app to find out which paths intersect with the rectangle.  I guess
accurately supporting lasso-like selections is even harder, since that's
an arbitary path/path intersection.

Hmm, that's a slightly longer email than I intended.  I guess that, at
one end of the scale, cairo may purely be a drawing library.  At the
other end of the scale, it could support very general queries about what
was drawn and where it was drawn.  If it's the former then I worry that
each and every interactive application using cairo will end up with
their own buggy version of "what lies under the mouse" code.

Andrew

-- 
- http://www.nobugs.org -




More information about the cairo mailing list