[cairo] Coordinate from device to user space without a context

Donn donn.ingle at gmail.com
Wed Nov 6 15:14:03 CET 2013


Hi,
(I'm using vala - fwiw)

My code is in an event handler that does not have a Cairo.Context -- I 
am in a drag operation and I want to pass my mouse x,y into the drag-object.

  The drag-object has pre-stored its Cairo.Matrix - when it was asked to 
draw() in the past, it had a Context passed to it. In there, a SM = 
cr.get_matrix() was done.

  I now want the object to transform the mouse x,y into coordinates that 
are in user space according to the stored matrix (SM).

(The drag object may have been under an arbitrary number of matrix 
transforms in the past.)

I'm just not math smart and I don't even know if what I'm asking is 
possible. I see these kinds of funcs in Cairo:
cairo_matrix_transform_point
cairo_matrix_multiply
.. but I don't know what they do.

I have tried the transform_point one. Something like this:
(In the object's move method)
move(mousex,mousey)
  SM.transform_point(mousex,mousey) <-- they do change. Chaotically.
  this.x = mousex
  this.y = mousey
  (later, in the draw method - those x,y vars are used in a translate call.)

.. but - I get weird offsets and such.

I want the drag-object to move along under my mouse coords.

I'm shooting in the dark really. Can someone help this math-deficient 
amateur hacker?

I attached my test code - in case.


\d
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_matrixes_dragging.vala
Type: text/x-vala
Size: 12176 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20131106/eca89391/attachment.bin>


More information about the cairo mailing list