sca;
close all;
clear;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, white);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
ifi = Screen('GetFlipInterval', window);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
[xCenter, yCenter] = RectCenter(windowRect);
gridSqSize = 100;
gapSize = 20;
stepSize = gridSqSize + gapSize;
numLines = floor(screenYpixels / stepSize) - 2;
if rem(numLines, 2) ~= 0
numLines = numLines + 1;
end
halfNumLines = numLines / 2;
[xpos, ypos] = meshgrid(-halfNumLines:halfNumLines, -halfNumLines:halfNumLines);
xpos = xpos .* stepSize + xCenter;
ypos = ypos .* stepSize + yCenter;
[s1, s2] = size(ypos);
numSquares = numel(ypos);
allRects = nan(numSquares, 4);
ticker = 0;
for i = 1:s1
for ii = 1:s2
ticker = ticker + 1;
allRects(ticker, :) = CenterRectOnPointd([0 0 gridSqSize gridSqSize],...
xpos(i, ii), ypos(i, ii));
end
end
Screen('FillRect', window, black, allRects');
Screen('Flip', window);
KbStrokeWait;
sca;