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

Donn donn.ingle at gmail.com
Thu Nov 7 13:43:04 CET 2013


On 07/11/2013 14:14, ed44 wrote:
> Yes, there is.
Hi ed, glad to hear it.

> 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...
Okay - I misunderstood the var name "x_new" and I have now tried this
formula with my mousex in the place of x_new.

     x = (mx - mymatrix.x0)/mymatrix.xx;
     y = (my - mymatrix.y0)/mymatrix.yy;


The result is much the same as posted before: I get wild jumps between
values. For example:
mx my: 323,256|326,666 becomes x y: 18,2562|21,6656
mx my: 321,256|327,666 becomes x y: 53|56
mx my: 320,256|327,666 becomes x y: 17,2562|21,6656
mx my: 318,256|327,666 becomes x y: 51|56

So, x = [18,53,17,51] See the jumps?

> Also the values you get from "event.motion.x" and "event.motion.y"
> are integers.
I double-checked (on valadoc) and the event.motion seems to be a double.
(http://valadoc.org/#!api=gdk-3.0/Gdk.EventMotion)

Please let me know if that's a mistake!


> ============ 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'm not sure how that helps the problem of the numbers oscillating like
they do. Could it be a casting thing?

I won't re-attach my test code, but please ask if you want it.


Many thanks,
\d


More information about the cairo mailing list