Drifting plaid demo

The following code also checks for a keypress. The timing method simply uses a Clock object with the .getTime() call. This is very easy to code, but not quite as accurate as using the frame tick.

from psychopy import visual, core, event

#create a window to draw in
myWin = visual.Window((600,600),allowGUI=False)

#INITIALISE SOME STIMULI
grating1 = visual.PatchStim(myWin,mask="gauss",
                        opacity=1.0, sf=(4,0), ori = 45)
grating2 = visual.PatchStim(myWin,mask="gauss",
                        opacity=0.5, sf=(4,0), ori= 135)
message = visual.TextStim(myWin,rgb=1.0, pos=(-0.95, -0.90),alignHoriz='left',
            text='q to quit...')

t = 0
frameDuration=1.0/60
while t<20:#quits after 20 secs 
        t=t+frameDuration

        grating1.setPhase(2*t)  #drift at 2Hz
        grating1.draw()  #redraw it

        grating2.setPhase(t)    #drift at 1Hz
        grating2.draw()  #redraw it

        message.draw()
        myWin.flip()          #update the screen

        #handle key presses each frame
        for keys in event.getKeys():
                if keys in ['escape','q']:
                        core.quit()
 
Valid XHTML 1.0! Valid CSS!