I need to create a uniform-colored circle that cycles through each of the 256 gray levels when a keyboard button is hit. Here is code the so far:
#create a window mywin = visual.Window([800,600], monitor="testMonitor", color = 'black', units="deg") #create the stimulus stim = visual.GratingStim(win=mywin, mask="circle", size=5, pos=[0,0], sf=0) stim.colorSpace = 'rgb255' stim.color = (0, 0, 0) #draw the stimuli and update the window for frameN in range(256): stim.setColor(1.0, '+') stim.draw() mywin.update() event.clearEvents(eventType='keyboard')
My trouble is writing the for loop and telling PsychoPy to change to the next gray level at the stroke of the button; I was hoping “stim.setColor(1.0, ‘+’)” would add 1 gray level to each of the (0, 0, 0) values, but it does not. The “event.clearEvents” code for changing the level of the gray is hopefully on the right track.
I am a beginner in coding and psychopy, and will really appreciate your help.