[cairo] Coordinate from device to user space without a context
ed44 at xs4all.nl
Thu Nov 7 14:48:40 CET 2013
On 11/07/2013 01:43 PM, Donn wrote:
> 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
> 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?
Yes , i see.
But if you use the above formula and the matrix values are constant
there should not be any jumps.
So i think your matrix values are changing from one move-event to the other.
You should check that.
>> 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.
> Please let me know if that's a mistake!
No, not a mistake.
I simply don't know where the fractional part comes from then.
(i'm used to X11 events where x,y are ints)
>> ============ 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,
More information about the cairo