close all;
clear;
sca;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
grey = white / 2;
inc = white - grey;
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
ifi = Screen('GetFlipInterval', window);
[xCenter, yCenter] = RectCenter(windowRect);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
theImageLocation = [PsychtoolboxRoot 'PsychDemos' filesep...
'AlphaImageDemo' filesep 'konijntjes1024x768.jpg'];
theImage = imread(theImageLocation);
[s1, s2, s3] = size(theImage);
if s1 > screenYpixels || s2 > screenYpixels
disp('ERROR! Image is too big to fit on the screen');
sca;
return;
end
imageTexture = Screen('MakeTexture', window, theImage);
amplitude = 0.5;
frequency = 0.2;
angFreq = 2 * pi * frequency;
startPhase = 0;
time = 0;
waitframes = 1;
vbl = Screen('Flip', window);
while ~KbCheck
thisContrast = amplitude * sin(angFreq * time + startPhase) + amplitude;
Screen('DrawTexture', window, imageTexture, [], [], 0, [], thisContrast);
time = time + ifi;
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
end
sca;