[solved] Text/Image position independent of resolution?
Hey!
I'm trying to set up an experimental paradigm on OpenSesame that is going to be used on multiple different systems. Since display resolutions might differ, I'm looking for a way to define stimulus positions based on percentage of the display rather than pixels. Right now I'm thinking about using an inline script to calculate the positions. I was wondering, however, if there is an easier way to change coordinates in opensesame.
Thanks in advance,
Jannis
Comments
Hi Jannis.
The inline_script option is the easiest way to go, as OpenSesame does not support other coordinate units than pixels, and arithmetic operations in sketchpad's aren't supported. This doesn't mean that it has to be difficult to find a solution, though!
Let's say you define the x and y coordinate of a stimulus in a loop item, as a percentage of the display size. Let's call the variables
xposandypos. To recalculate this to pixels based on the display resolution, place the following code in the Prepare phase of an inline_script at the start of the trial sequence:Now in a sketchpad, you can use
[xpos]and[xpos]to define the stimulus coordinates.Good luck!
Hey Edwin,
thanks for your help, works perfectly!
cheers
Hi there Jannis,
I'm trying to use the same inline script to get my images to fit my screen for an MRI experiment since some images are a bit on the large side. However I keep getting an error relating to my int. value I think. Any advice?
EDIT: More specifically, is there a way to scale in image to match the screen resolution/size
Thank you!
Hi,
The error that you are posting is related to some type conflict. As it seems you are trying to convert something to an integer (maybe even implicitly), which cannot be an integer. To say for sure, I would have to see the piece of code that produced this error.
var.widthandvar.heightrepresent the dimensions of the screen. If you normalize your images based on these to values, you will get a scaling factor, that you have to apply to your images, so that your images will fit the screen. Something like that:Does this help?
Eduard
Hi Eduard,
The images I have vary in dimension, some are 22501250, while others maintain a 800600 dimension. I opted for manually editing the images and scaling them with a locked aspect ration. Not the most elegant or efficient solution, but Occams razor.
Thanks for the quick reply though. (y)