Skip to content

Instantly share code, notes, and snippets.

@psadil
Last active January 25, 2017 15:38
Show Gist options
  • Save psadil/7265d02c602fa10648e7db8d9c0a157e to your computer and use it in GitHub Desktop.
Save psadil/7265d02c602fa10648e7db8d9c0a157e to your computer and use it in GitHub Desktop.
function exit_stat = DrawLeftArrowToOffScreenDemo()
exit_stat = 0;
PsychDefaultSetup(2); % assert OpenGL install, unify keys, fix color range
screenNumber = max(Screen('Screens')); % Choose a monitor to display on
[window, winRect] = Screen('OpenWindow', screenNumber, ...
(2/3)*WhiteIndex(screenNumber));
arrowTexture = makeLeftArrowTex(screenNumber, winRect(3)/2, winRect(4)/2, winRect(3)/2 - 100, winRect(4)/2);
Screen('DrawTexture', window, arrowTexture);
Screen('DrawingFinished', window);
Screen('Flip', window);
WaitSecs(2);
sca;
end
function arrowTexture = makeLeftArrowTex(screenNumber, fromH, fromV, toH, toV)
% make texture of leftward pointing arrow
% open window to which arrow will be drawn. This 'offscreen window'
% can be treated just like a typical texture
arrowTexture = Screen('OpenOffScreenWindow', screenNumber, ...
(2/3)*WhiteIndex(screenNumber));
% draw arrow
Screen('DrawLine', arrowTexture, [],...
fromH, fromV, ...
toH, toV);
Screen('DrawLine', arrowTexture, [], ...
toH + 10, toV - 10, ...
toH, toV);
Screen('DrawLine', arrowTexture, [], ...
toH + 10, toV + 10, ...
toH, toV);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment