sca;
close all;
clearvars;

mode = 1440;
size = 100;
amplitude = 0.2;
frequency = 2.0;
bg = [0 0 0];

PsychDefaultSetup(2);
InitializeMatlabOpenGL();                       % must do this
screenNumber = max(Screen('Screens'));
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, bg);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
ifi = 1.0/mode;									% actual frame duration in seconds
[xCenter, yCenter] = RectCenter(windowRect);
Priority(MaxPriority(window));

W = ManagedWindow(window, bg, mode);            % initialize class; because autodlpmode is true, will set the
												% projector mode using the (externally installed) dlpmode.exe program
												% don't forget to set the dlpmode_path, dlp_mode_180_pars and dlp_mode_1440_pars
												% class properties in the ManagedWindow.m file to appropriate values

baseRect = [0 0 size size];
time = 0;
while ~KbCheck
    x = xCenter + amplitude*screenXpixels*sin(2*pi*frequency*time);
    y = yCenter + amplitude*screenXpixels*cos(2*pi*frequency*time);
    rect = CenterRectOnPointd(baseRect, x, y);
    Screen('FillArc', window, W.color, rect, 0, 360);	% always use W.color for drawing
														% (changes automatically from frame to frame)
    W.flip();									% do this instead of something like Screen('Flip', window, 0)
    time = time + ifi;
end

W.cleanup();                                    % will put the DLP4710 back into normal mode
sca;
