close all;
clear;
PsychDefaultSetup(2);
Screen('Preference', 'SkipSyncTests', 2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
blue = [0 0 white];
red = [white 0 0];
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, black,...
[], [], [], [], [], kPsychNeedRetinaResolution);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
[xCenter, yCenter] = RectCenter(windowRect);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
textSize = 260;
Screen('TextSize', window, textSize);
HideCursor;
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
ifi = Screen('GetFlipInterval', window);
waitframes = 1;
theAlphaBet = 'a':'z';
numLetters = length(theAlphaBet);
dim = 2;
pixScale = 300;
[x, y] = meshgrid(-dim:dim + 1, -dim:dim + 1);
x = reshape((x .* pixScale + yCenter), 1, numel(x));
y = reshape((y .* pixScale + yCenter), 1, numel(y));
lineWidth = 4;
oddLetters = {'a', 'c', 'e', 'm', 'n', 'o',...
'r', 's', 'u', 'v', 'w', 'x', 'z'};
for i = 1:numLetters
thisLetter = theAlphaBet(i);
isOdd = sum(strcmp(thisLetter, oddLetters));
[nx, ny, textBounds] = DrawFormattedText(window, thisLetter, y(i), x(i), white);
Screen('FrameRect', window, blue, textBounds, lineWidth);
if isOdd == 1
corrValue = ny - textBounds(4);
Screen('FrameRect', window, red, textBounds + [0 corrValue 0 corrValue], lineWidth);
end
Screen('DrawDots', window, [y(i) x(i)], 25, blue, [], 2);
Screen('DrawDots', window, [nx ny], 25, blue, [], 0);
end
Screen('Flip', window);
KbStrokeWait(-1)
sca;