sca;
close all;
clear;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, black);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
ifi = Screen('GetFlipInterval', window);
[xCenter, yCenter] = RectCenter(windowRect);
dim = round(screenYpixels / 6);
baseRect = [0 0 dim dim];
red = [1 0 0];
blue = [0 0 1];
HideCursor;
SetMouse(xCenter, yCenter, window);
vbl = Screen('Flip', window);
waitframes = 1;
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
while ~KbCheck
[x, y, buttons] = GetMouse(window);
centeredRect = CenterRectOnPointd(baseRect, xCenter, yCenter);
inside = IsInRect(x, y, centeredRect);
if inside == 1
rectColor = red;
elseif inside == 0
rectColor = blue;
end
Screen('FillRect', window, rectColor, centeredRect);
Screen('DrawDots', window, [x y], 10, white, [], 2);
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
end
sca;