Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

setting image location in sketchpad OSWeb

Hi,


I am trying to set the image location in sketch pad according to the width of the screen. In the regular version of OpenSesame I did this by setting the x value in the sketch pad according to vars.width , though this isn't working in the OSWeb version. Is this not working since in OSWeb sketchpad named elements are not supported? Is there any workaround this?


Thank you,

Galit

Comments

  • Hi @Galit,

    Named sketchpad elements indeed are not supported yet in osweb. It is weird that using vars.width doesn't work. This should contain the dimensions of the osweb Canvas and you should be able to use it to position elements on the display.

    Buy Me A Coffee

  • Thanks for the reply. Yes, it is weird that it doesn't work in OSWeb.

    Here is the script line I am using in the sketchpad element:

    draw image center=1 file="hammer.png" scale=1.5 show_if=always x="-[vars.width - 50]" y=0 z_index=0

    Is there something wrong here?

  • To clarify, when using the vars.width, the program doesn't crash or get stock, but the image isn't shown on the screen. This is true when setting X to different values [vars.width - X].

  • edited October 2020

    Without having tried it, I think the problem is not in using vars.width itself, but in the expression `[vars.width-50]`. First of all, the brackets should replace the vars part. So, [vars.width] is a bit of double. Then, I would think the arithmetics have to be done outside the brackets. So if anything, I would think that the statement should be "-[width]-50" . However, that doesn't seem to work. What I did now, that seemed to work is adding an inline_javascript to the trial_sequence, before the sketchpad (in its prepare phase) and create a new variable vars.new_x = vars.width-50. This variable can then be used in the field as is, so e.g. [new_x].

    Does that help?

    Eduard

    Buy Me A Coffee

  • Thanks for your reply.

    It seems to work, though for some reason, it looks like the entire screen is not fully used. That is when I define a new variable, new_x, I need to define it very far from the edge of the screen (i.e. vars.width-550) in order to see the visual image, other wise it is cut, or not visible at all. Is there something in the settings I need to change for the experiment to use the entire screen?


    Thank you,

    Galit

  • hi Galit,

    The origin of the coordinate system (0,0) is the middle of the screen. So if your screen is 1000 px wide, the corresponding left edge would have an x coordinate of -500 and the right edge +500. That's why you have to subtract such a large number (at least half of the width), to see something appear on the screen.

    Hope this helps,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,


    According to what you write, I am supposed to see the image in the entire screen, but in principle, I can't see the image in the entire screen. Attached are two screen shots showing, one showing the entire visual image (width-550), and one in which the visual image cut off (width - 500), though as you can see the screen is bigger.


    Thank you,

    Galit



  • Adding, that in the regular version of OpenSesame, not OSweb, the experiment runs in full screen, and the visual image is shown on the side of the screen (width-100).


    Thank you,

    Galit

  • Hi Galit, your experiment has specific dimension (you specify that in the general properties tab). If you run your experiment full screen and that size does not match the screen dimension on which you present it, the rest of the screen is filled with black. Importantly that part is not actually useable by Opensesame. Opensesame can only draw on the area that you specify to be width and height. That's why you get that cut off stimulus. If you increase the stimulus dimension that image should appear entirely.

    hope this clears things up.

    Eduard

    Btw. what I am saying here only applies if you have checked the `uniform coordinates` field on the general properties tab. If you have unchecked it, that (0,0) is not in the center of the screen, but in the top left corner, and the center would indeed be marked with (0.5*width,0.5*height)

    Buy Me A Coffee

  • Thank you

Sign In or Register to comment.