[cairo] Coordinate from device to user space without a context
Donn
donn.ingle at gmail.com
Thu Nov 7 02:03:15 CET 2013
On 06/11/2013 21:25, Bryce W. Harrington wrote:
> But let's say your two coordinates aren't rotated or skewed, they're
> just straight multiples with an offset. The formula simplifies to
> this:
>
> x_new = xx * x + x0; y_new = yy * y + y0;
>
(slimmer file attached.)
I gave this one a go in my move(), where mx,my are mouse coords:
public void move(double mx, double my) {
double xnew = mymatrix.xx * mx + mymatrix.x0;
double ynew = mymatrix.yy * my + mymatrix.y0;
stdout.printf("mx my: %G|%G maps to xnew ynew: %G|%G\n",mx,my, xnew,
ynew);
x=xnew; y=ynew;
In my set_matrix method, after setting a new trans/scale/rot, I do:
[line 105] cr.identity_matrix();
[line 106] mymatrix = cr.get_matrix();
The printout shows if:
I remark line 105 out (no identity call) the numbers grow rapidly,
showing no relation to user space or mouse space.
If I put 106 back in, the numbers are out by about half my window
width. They also do not adhere to the initial matrix that was set in my
initmatrix call (line 255) which sets up a zero,zero in the middle.
So, I'm close. But ...
Thanks for your math insight - I'm monkey-see-monkey-type most of the
time.I have read about matrix math (linear?) and even had my bro in law
'splain it, but I'm like a stone in these waters!
> Once you understand the above, then you'll understand exactly what
> the cairo_matrix_transform_point() and cairo_matrix_invert()
> functions do.
Well.. I'll do my best, but that's a tall order. ;)
Thanks!
\d
-------------- next part --------------
A non-text attachment was scrubbed...
Name: matrix_maillist_debug.vala
Type: text/x-vala
Size: 10169 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20131107/0c8144ba/attachment-0001.bin>
More information about the cairo
mailing list