I am dynamically changing the shape of two ShapeStim objects using the following code:
cwd = os.path.dirname(__file__) width, height = [1366, 768] win = visual.Window(size = (width, height), fullscr = True, pos = (0,0), units = "norm", color = [-1,-1,-1]) event.Mouse(visible = False) trialLength = 30 timer = core.Clock() text = visual.TextStim(win = win, text = '', height = 0.1, pos = (0,0), color="White") image = visual.ImageStim(win = win, pos = (0,0), size=(2,2), image=os.path.join(cwd + '/Pictures/pic1.jpg')) mask1 = visual.Rect(win=win, pos=(0.0,0), lineColor='Black', fillColor='Black') mask2 = visual.Rect(win=win, pos=(0.3,0), lineColor='Black', fillColor='Black') timer.reset() image.setAutoDraw(True) mask1.setAutoDraw(True) mask2.setAutoDraw(True) while timer.getTime() < trialLength: if 'escape' in event.getKeys(keyList=['escape']): core.quit() mask1.size = ((trialLength - timer.getTime())*.02,4) mask2.size = ((trialLength - timer.getTime())*.02,4) win.flip() mask1.setAutoDraw(False) mask2.setAutoDraw(False) image.setAutoDraw(False)
What I am doing is gradually shrinking the size of the vertical rectangles until the end of the trial length, where an under-layed the picture is completely revealed.
I wanted to know if there is a way to better do this so that the win.flip() command occurs outside the while loop, which I worry will affect the timing (i.e create more lagging)?
Thank you for the help.