sca;
close all;
clear;
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');
[x, y] = meshgrid(-120:1:120, -120:1:120);
[th, r] = cart2pol(x, y);
wheel = grey + inc .* cos(pi * th);
spiralTexture = Screen('MakeTexture', window, wheel);
yPos = yCenter;
xPos = linspace(screenXpixels * 0.2, screenXpixels * 0.8, 4);
[s1, s2] = size(x);
baseRect = [0 0 s1 s2];
dstRects = nan(4, 4);
for i = 1:4
dstRects(:, i) = CenterRectOnPointd(baseRect, xPos(i), yPos);
end
colorMod = [1 1 1; 1 0 0; 0 1 0; 0 0 1]';
Screen('DrawTextures', window, spiralTexture, [],...
dstRects, [], [], [], colorMod);
Screen('Flip', window);
imageArray = Screen('GetImage', window, [], [], 1, []);
imwrite(imageArray, [cd '/TransparentWindowDemo.jpeg'])
KbStrokeWait;
sca;