psychopy.org | Reference | Downloads | Github

Issue overlaying shape over image

Hello,

I’m trying to overlay a series of vertical and horizontal bars (which erode over time), over an image, but have recently run into an issue. I was initially only displaying the eroding vertical bars, which was fine; however, when I display the eroding horizontal bars, their erosion appears jagged and uneven across those bars. The bars are stored as a visual.ElementArrayStim object. I may be wrong, but I’m wondering if the jagged horizontal bar display is due to drawing the image object prior to the bars and win.flip()? I tried image.setAutoDraw(True), but that seems to prevent me from being able to overlay the bars. This is a rough sketch of how I’m currently display things:

image.draw()
bars.draw()
win.flip()

Is there a way to resolve this issue, or am I thinking through the problem incorrectly?

Thanks for the help!

Dan

The layered drawing code you gave above is exactly the right approach. It can be worth avoiding auto draw at times, so you can be absolutely sure of the drawing order.

It might be best if you post an image showing the problem and also what the stimuli look like when drawn correctly.

I was actually able to resolve my issue by not using the visual.ElementArrayStim class, but used a for loop to change the height and width of the bars.

image.draw()
barSizes = [...]
for i in barSizes:
   bar.width = barSizes[0]
   bar.height = barSizes[1]
   bar.draw()
win.flip()

The idea came from the last comment of this thread.