[open] Question on how to make a sketchpad object partly transparent
  • ABEYKOABEYKO
    150 karma points

    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?

  • sebastiaansebastiaan
    12196 karma points

    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()

    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.)

    # Show the previously prepared canvas
    global my_canvas
    my_canvas.show()

    Hope this helps!

    Cheers, Sebastiaan

    ---
    Sebastiaan Mathôt - http://www.cogsci.nl/smathot
    Have you received the help you were looking for? Show your appreciation through the Social box on the left side of the page.
Please sign in to add a comment
Copyright 2011-2013 Sebastiaan Mathôt // Photos originally from Lucnix and WikiMedia // Powerered by Vanilla

In this Discussion

Social

J.-François Gariépy says: OpenSesame: An open-source, graphical experiment builder for the social sciences. http://t.co/f4YCVbcA #social #sciences #technology

Latest on cogsci.nl

The Smartphone Revolution in psychological science: OpenSesame mobile // NewsSetting up Kubuntu 13.04 for research // TutorialThe black swan // OpinionMore