Howdy, Stranger!

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

Supported by

[solved] Question on how to make a sketchpad object partly transparent

edited January 2014 in OpenSesame

When you have two different sketchpad objects, is there any way to make the background transparent, so that it shows what is in the old object as well as the new object? If not, what could I do if I want to present something new on top of an older display?

Comments

  • edited January 2014

    Hi Abeyko,

    Not really, at least not without inline script. If you want to present a background sketchpad, followed by a separate background+object sketchpad, you would need to add the background to both sketchpads.

    If drawing the background twice is inconvenient, you could consider drawing the object on top of the background with a bit of inline_script.

    First you add the following code to the prepare phase of an inline script. This inline script comes after the sketchpad (background_sketchpad) that contains the background. So the background can be drawn normally, without inline_script. The code below draws a simple fixation dot on top of the background, but you can extend it to fit your needs.

    # Construct a new canvas and make it global so it's also
    # available in the run phase of the script
    from openexp.canvas import canvas
    global my_canvas
    my_canvas = canvas(exp)
    
    # Copy the canvas from an item called 'background_sketchpad'
    my_canvas.copy(exp.items["background_sketchpad"].canvas)
    
    # Draw your own stuff on top of it!
    # See: http://osdoc.cogsci.nl/python-inline-code/canvas-functions
    my_canvas.fixdot()</pre>
    
    Next, in the *run* phase of the same script, you show the previously prepared canvas. (The reason for doing the canvas construction separately in the prepare phase is to prevent delays.)
    
    <pre># Show the previously prepared canvas
    global my_canvas
    my_canvas.show()
    

    Hope this helps!

    Cheers,
    Sebastiaan

Sign In or Register to comment.