On Wed, Nov 5, 2008 at 11:47 AM, Leonard Ritter
<[EMAIL PROTECTED]>wrote:

> On Wed, Nov 5, 2008 at 9:05 AM, Saul Lethbridge <[EMAIL PROTECTED]
> > wrote:
>
>> Hi,
>>
>> Regarding your comments below on untransformed mouse coordinates - can you
>> give me an example on how you've calculated the transformation? I'm having
>> difficulty getting that to work in my app.
>>
>
> assumed that your app uses a group to scale and translate everything else,
> here is the code to translate world coordinates to local coordinates:
>
> px,py = group.get_position()
> sx,sy = group.get_scale()
> x = (event.x - px) / sx
> y = (event.y - py) / sy
>
> and back:
>
> px,py = group.get_position()
> sx,sy = group.get_scale()
> x = (local_x * sx) + px
> y = (local_y * sy) + py
>
> of course you have to work with floats for the calculations.
>

Reply via email to