[cairo] Drawing an arrow

necko necko opustenom at hotmail.com
Fri Nov 26 07:36:32 PST 2010

I decided to draw a circle on the line AB, close to B. That would determine the direction.
However, I have problem drawing the circle while drawing the line. Consider the following
block from the while loop:
        cairo_move_to (cr, *firstIter, *(firstIter+1));
        cairo_line_to (cr, *secondIter, *(secondIter+1));
        // here I calculate the coordinates of the wished circles...
Note that placing 
cairo_arc(cr, rectOrigin[0], rectOrigin[1], circleRad*0.5, 0, 2*M_PI);
instead of comment above leads to unwanted results.
What would be the way to draw these circles (given their origins) while drawing lines?

From: jeremy at emperorlinux.com
To: cairo at cairographics.org
Date: Wed, 24 Nov 2010 23:42:45 -0500
Subject: Re: [cairo] Drawing an arrow

On Tue, 2010-11-23 at 16:27 +0000, necko necko wrote:
> A set of 2D coordinates needs be connected by lines, but some of these
> lines need be arrows;
> meaning, the sequence
>     cairo_move_to (cr, A.x, A.y);
>     cairo_line_to (cr, B.x, B.y);
> that draws a line from A to B, needs to be replaced with an arrow from
> A to B.
> Any help on how to achieve this is highly welcome.
> Thanks
It turns out, Behdad has already provided some code that does something
very similar to this! I include the code in Cairocks, the function is
called "map_path_onto" and I got it from some of his code... somewhere.
Please see the attached image for a demonstration. I only use a simple
arc as the path, but you could just as well use anything.
Weee! :)
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

cairo mailing list
cairo at cairographics.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101126/ba3ffcbd/attachment.htm>

More information about the cairo mailing list