I'm new at psychtoolbox and trying to rotate/draw my framed square to a diamond/rhombus, but can't quite figure it out how it works. Here's my code:
AssertOpenGL;
screenNo = max(Screen('Screens'));
screenRes = [0 0 640 480];
Screen('Preference', 'SkipSyncTests', 2);
ListenChar(2);
[win, rect] = Screen('OpenWindow', screenNo, [0 0 0], screenRes);
[width, height]=Screen('WindowSize', win);
[x,y] = RectCenter(rect);
baseRect = [0 0 250 250];
centeredRect = CenterRectOnPointd(baseRect, x, y);
Screen('FrameRect', win, [255 255 255], centeredRect, 3);
Screen('Flip', win);
KbWait;
sca;
I tried changing my baseRect into [320 115 320 365], but it doesn't work. Not so sure how to specify the [left, top, right, bottom] coordinate if I want a diamond/rhombus.
Thanks for any help.
The FrameRect function will only construct upright rectangles. You could create a texture from the rectangle, then rotate that on display. Alternatively, you could specify the coordinates of each edge of the diamond, then display that using the 'FramePoly' function. For example:
AssertOpenGL;
screenNo = max(Screen('Screens'));
screenRes = [0 0 640 480];
Screen('Preference', 'SkipSyncTests', 2);
ListenChar(2);
[win, rect] = Screen('OpenWindow', screenNo, [0 0 0], screenRes);
[width, height]=Screen('WindowSize', win);
[x,y] = RectCenter(rect);
% compute poly coordinates
polyWidth = 250;
polyHeight = 250;
xCoord = [x, x - (polyWidth/2), x, x + (polyWidth/2)]';
yCoord = [y + (polyHeight /2), y, y - (polyHeight /2), y]';
polyCoords = [xCoord yCoord];
Screen('FramePoly', win, [255 255 255], polyCoords, 3);
Screen('Flip', win);
KbWait;
sca;