close all;
clear;
sca;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
grey = white / 2;
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey, [], 32, 2,...
[], [], kPsychNeed32BPCFloat);
ifi = Screen('GetFlipInterval', window);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
screenXpix = windowRect(3);
screenYpix = windowRect(4);
rcycles = 8;
tcycles = 24;
xylim = 2 * pi * rcycles;
[x, y] = meshgrid(-xylim: 2 * xylim / (screenYpix - 1): xylim,...
-xylim: 2 * xylim / (screenYpix - 1): xylim);
at = atan2(y, x);
checks = ((1 + sign(sin(at * tcycles) + eps)...
.* sign(sin(sqrt(x.^2 + y.^2)))) / 2) * (white - black) + black;
circle = x.^2 + y.^2 <= xylim^2;
checks = circle .* checks + grey * ~circle;
radialCheckerboardTexture(1) = Screen('MakeTexture', window, checks);
radialCheckerboardTexture(2) = Screen('MakeTexture', window, 1 - checks);
startAngle = 0;
arcAngle = 270;
arcRect = CenterRectOnPointd([0 0 screenYpix screenYpix],...
screenXpix / 2, screenYpix / 2);
checkFlipTimeSecs = 2;
checkFlipTimeFrames = round(checkFlipTimeSecs / ifi);
frameCounter = 0;
degPerSec = 45;
degPerFrame = degPerSec * ifi;
waitframes = 1;
textureCue = [1 2];
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
vbl = Screen('Flip', window);
while ~KbCheck
frameCounter = frameCounter + 1;
Screen('DrawTexture', window, radialCheckerboardTexture(textureCue(1)));
Screen('FillArc', window, grey, arcRect, startAngle, arcAngle)
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
if frameCounter == checkFlipTimeFrames
textureCue = fliplr(textureCue);
frameCounter = 0;
end
startAngle = startAngle + degPerFrame;
end
sca;