| Reference | Downloads | Github

Save mouse click in pixel when experiment is in degree

I made an experiment in the Builder that is completely coded in degree (Line Bisection).
Now I would like to save the mouse click also in pixel, to be able to compare the “real” distance of the clicks and not just in degree.
Is there a way to save the mouse click twice, once in degree (already working) and once in pixel?

Thanks in advance :slight_smile:

If you find the position in degrees for the edge of the screen (call it degxMax) then you could convert back to pixels using

mousexPositionInDegrees / degxMax * screenWidthInPixels / 2

You could also find degxMax using trigonometry, which I could work out if necessary since

mousexPositionInDegrees = tan(mousexPositionInPixels/distance to screen)


mousexPositionInPixels = tan-1(mousexPositionInDegrees) * distance to screenCM * screenWidthInPixels / screenWidthInCM

I can’t guarantee I’ve got this correct.

In the next release (2022.1.0) we’re adding some tools on the backend to make these conversions easier - you’ll be able to do this:

pos = layout.Position(mouse.getPos(), 'deg', win)

and then get these coordinates in any unit space using a ., like so:


We’re hoping to get this release out early in the new year

1 Like