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

ed44 ed44 at xs4all.nl
Thu Nov 7 13:14:56 CET 2013


On 11/07/2013 09:29 AM, Donn wrote:
> Follow up summary.
>
> So far it seems to me, from my recent experience, that ..
>
> cr.device_to_user(x,y); //where cr is a Cairo.Context
>
> .. actually works, and that there is no equivalent way to do this in 
> situations where you have no context.

Yes, there is.

=======

If you need to go the other way round, just do the basic algebra:

  x = (x_new - x0)/xx
  y = (y_new - y0)/yy
==========

I think you need to read the answer from Bryce more carefully, it's there...

Also the values you get from "event.motion.x" and "event.motion.y" are 
integers.

============
BEFORE mx my: 201,665 | 252,93
AFTER mx my: 1,6646 | 2,93018
DRAGGING 3
============

...so the "BEFORE" values should be whole numbers here.


>
> I have tried the suggested manual formulas, as well as the "invert 
> then transform_point" approach. (Thx, btw.) Neither have done what the 
> cr.device_to_user does. (And I'm likely the reason for any bugs.)
>
> "How can I take a pair of coordinates in device space into user space 
> (by way of a pre-saved matrix) in some handler that has no access to 
> the Cairo Context?"
>
> Is my wording of the problem clear? I'm not sure because math. :)
>
> \d



More information about the cairo mailing list