[cairo] Drawing an arrow

Andrea Canciani ranma42 at gmail.com
Wed Nov 24 02:25:10 PST 2010

On Wed, Nov 24, 2010 at 11:11 AM, donn <donn.ingle at gmail.com> wrote:
> On 24/11/2010 11:58, Andrea Canciani wrote:
> Thanks Andrea. I am a Pythoneer, so it will take a while to figure out
> your "->" shorthand, but I appreciate anything that nudges me towards an
> algorithm.

Uhm, right, maybe the notation wasn't very clear.
a->b in that context is just a shorthand for "the direction from point
a to point b"
If a and b are points (for example objects whose class implements the usual
vector operations), the direction a->b can be computed by subtracting a from b:

a = (2,5)
b = (8,12)
"a -> b" = b-a = (8,12) - (2,5) = (8-2, 12-5) = (6,7)

You might want to normalize the vector to make its length 1, but that depends
on what you will do with it.


More information about the cairo mailing list