[open] "Animated" distractor
I am coding an experiment which requires a distractor stimuli in some of the trial conditions. The distractor is supposed to be an X, that scrolls diagonally a bit off to the side of the main stimuli in the center. I have written the following inline script, in which I have attempted to create a for loop, where each subsequent "frame" of the canvas would offset the x and y coordinates of the distractor by 30 pixels, creating a short 5-frame "animation". The first appearance of the stimuli in each trial is drawn from a range of random offsets, but all subsequent iterations should follow in the above 30-pixel pattern. But alas, they all appear at random. Does anyone see what I am missing?
Here's the code:
from openexp.canvas import canvas import random c1 = self.copy_sketchpad("stimuli") # copy stimuli sketchpad start=[-250, -150, -100, 100, 250, 500] # starting offset range for x and y x = random.choice(start) + c1.xcenter() # random choice from offset range added to canvas center y = random.choice(start) + c1.ycenter() # random choice from offset range added to canvas center p_step = 30 # pixel steps t_step = 500 # time steps for time in range(0, 1500, t_step): # for loop to display animated distractor "X" c1.clear() c1.text('X', x = x + p_step, y = y + p_step) c1.show() self.sleep(100)