/usr/share/psychtoolbox-3/PsychDemos/ECVP2013/HelloAnimationDemo.m is in psychtoolbox-3-common 3.0.11.20140816.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | % HelloAnimationDemo -- Show a simple sinusoidal movement animation.
% Derived from code written by Peter Scarfe.
PsychDefaultSetup(2);
% Get the screen numbers
screens = Screen('Screens');
% Draw to the external screen if avaliable
screenNumber = max(screens);
% Define black and white
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
% Open an on screen window
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, black);
% Get the size of the on screen window
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
% Query the frame duration
ifi = Screen('GetFlipInterval', window);
% Get the centre coordinate of the window
[xCenter, yCenter] = RectCenter(windowRect);
% Make a base Rect of 200 by 200 pixels
baseRect = [0 0 200 200];
% Set the color of the rect to red
rectColor = [1 0 0];
% Our square will oscilate with a sine wave function to the left and right
% of the screen. These are the parameters for the sine wave
% See: http://en.wikipedia.org/wiki/Sine_wave
amplitude = screenXpixels * 0.25;
frequency = 0.2;
angFreq = 2 * pi * frequency;
startPhase = 0;
time = 0;
% Sync us and get a time stamp
vbl = Screen('Flip', window);
waitframes = 1;
% Maximum priority level
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
KbReleaseWait;
% Loop the animation until a key is pressed
while ~KbCheck
% Position of the square on this frame
xpos = amplitude * sin(angFreq * time + startPhase);
% Add this position to the screen center coordinate. This is the point
% we want our square to oscillate around
squareXpos = xCenter + xpos;
% Center the rectangle on the centre of the screen
centeredRect = CenterRectOnPointd(baseRect, squareXpos, yCenter);
% Draw the rect to the screen
Screen('FillRect', window, rectColor, centeredRect);
% Flip to the screen
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
% Increment the time
time = time + ifi;
end
% Clear the screen
sca;
|