Re: Coordinate from device to user space without a context

ed44 <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On 11/07/2013 02:03 AM, Donn wrote:
> 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;
With that matrix, points are transformed from user space to device space 
( coords to pixels here).
You need the other way around.

Using the cairo matrix api you could do :
--get the matrix
--invert the matrix
--cairo_matrix_transform_point_with_that_matrix.

or , easier, use the other formulas from the previous answer.

Ed.

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.