Help rotating a rectangle (PsychToolbox)

7 views (last 30 days)
Steve
Steve on 5 Nov 2015
The program successfully draws a rectangle but I can't find any online resources that explain how to rotate it. Here is what I have so far:
%
function [ output_args ] = SubDetection( )
close all;
clear all;
PsychDefaultSetup(2);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
gray = white/2;
% Open an on screen window
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, gray);
% Get the size of the on screen window
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
% Display instructions
messageStr='Please indicate with the left and right arrow keys \n whether the stimulus \n is a square (<-) or a circle (->) \n\n Press any key to begin.';
WaitSecs(0.5);
Screen('TextSize', window, 30);
DrawFormattedText(window, messageStr, 'center', 'center', [1 1 1]);
Screen('Flip',window,0,0);
KbStrokeWait;
% Get the centre coordinate of the window
[xCenter, yCenter] = RectCenter(windowRect);
% size of fixation cross
fixCrossDimPix = 8;
xCoords = [-fixCrossDimPix fixCrossDimPix 0 0];
yCoords = [0 0 -fixCrossDimPix fixCrossDimPix];
allCoords = [xCoords; yCoords];
lineWidthPix = 2;
Screen('DrawLines', window, allCoords,...
lineWidthPix, white, [xCenter yCenter], 2);
Screen('Flip', window);
WaitSecs(1);
[xCenter, yCenter] = RectCenter(windowRect);
baseRect = [0 0 50 175];
centeredRect = CenterRectOnPointd(baseRect, xCenter, yCenter);
rectColor = [0 0 0];
% Draw the rectangle
Screen('FillRect', window, rectColor, centeredRect);
Screen('Flip', window);
WaitSecs(1);
KbStrokeWait;
sca;
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!