Howdy, Stranger!

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

Supported by

[open] is it possible to fade in a image, like really slowly?

edited December 2014 in OpenSesame

i am trying to show some images in my experiment by fading them in, so you cant recognize the subject from the beginning but during about 4 seconds the image should be shown clearly.
does anybody know how to do this?
thanks again!

Comments

  • edited December 2014

    Hi MasterThesis,

    I know a trick, but it's not really an elegant one as it only works in the psychopy backend, and therefore you can't use the legacy or expyriment backend anymore after you implemented it like this. Nevertheless, here is how you can easily change the opacity of stimuli using a bit of psychopy code in your inline_script items:

    #  Create a canvas and draw a circle on it
    canvas = self.offline_canvas()
    canvas.circle(100, 100, 50, fill=True, color='red')
    
    # Get a reference to this circle
    # It is the last drawn item in psychopy stim_list
    circle_stim = canvas.stim_list[-1]
    # Set the circle_stim opacity to 50%
    circle_stim.opacity = 0.5
    
    ## Preferably put the code below in the run phase
    
    # Show the canvas
    canvas.show()
    # Sleep for 5 seconds to keep the circle onscreen that long
    self.sleep(5000)
    

    I've been planning to implement this opacity parameter in the normal canvas functions of Opensesame (so it works with all backends and you don't need to work with backend specific code like I'm doing in this example), but haven't found the time for it yet. In the future it should be easier to change opacity of stimuli directly with OpenSesame canvas statements.

    Buy Me A Coffee

  • edited 7:08PM

    hi, thanks, but i guess i forgot something, because all i got is an red circle on a canvas now. but i wanted to have my used images to fade in slowly, not the red circle :) how do i do that?

  • edited December 2014

    You do it just the way, which Daniel described.
    Note the line:

    circle_stim = canvas.stim_list[-1]
    

    assigns the last drawn element to the variable circle_stim. So just make sure to draw your image last and you will have the same effect for it as you have right now for the circle. Check the documentation to learn how to draw images.

    Good luck,

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.