Homework 8: Due Midnight on November 24th.
Funky Screen
Entertain us with an animated graphical display using the PsychToolbox 'Screen' function. The requirements are very flexible - just demonstrate your ability to use the various features of 'Screen', which can include putting up images, text, geometric shapes and lines.
An example of a previous student's 'Funky Screen' follows below (taken from the course Lessons)
% This is my Funky li'l m_file
written to demonstrate psychtoolbox
%
% Written by Jon D. Howe
4/16/2007
clear all
% Initialize variables
screenNum=0;
flipSpd=25; % flip every 25 frames
[wPtr,rect]=Screen('OpenWindow',screenNum, 0, []);
monitorFlipInterval=Screen('GetFlipInterval',wPtr);
black=BlackIndex(wPtr);
white=WhiteIndex(wPtr);
HideCursor;
% blank screen and wait a second
Screen('FillRect',wPtr,black);
Screen('Flip',wPtr);
tic
while toc<.2
end
% Flip and collect th e time of the flip in vbl
vbl=Screen('Flip', wPtr);
% Draw Background
Screen('FillRect', wPtr, [100 255 255]);
Screen('FillRect', wPtr, [0 255 0], [0 2*rect(4)/3 rect(3) rect(4)])
% Draw house
Screen('FillRect', wPtr, [0 0 255], [420 300 680 600]);
Screen('FillPoly', wPtr, [100 0 0], [420 300; 540 200; 680 300]);
% Draw roof
Screen('DrawLine', wPtr, [50 50 50], 410, 310, 540, 200, 5);
Screen('DrawLine', wPtr, [50 50 50], 690, 310, 540, 200, 5);
% Draw doors and windows
% door
Screen('FillRect', wPtr, [200 200 0], [520 450 600 600]);
% window
Screen('FillRect', wPtr, [175 200 256], [440 380 500 440]);
Screen('FrameRect', wPtr, [0 0 0], [440 380 500 440], 3);
Screen('DrawLine', wPtr, [0 0 0], 470, 380, 470, 440, 3);
Screen('DrawLine', wPtr, [0 0 0], 440, 410, 500, 410, 3);
% gable window
Screen('FillArc', wPtr, [175 200 256], [520, 260, 600, 320],270,180);
Screen('FrameArc', wPtr, [0 0 0], [520 260 600 320],270,180,3);
% Draw tree
Screen('FillRect', wPtr, [100 100 0], [200 400 230 700]);
Screen('FillOval', wPtr, [0 150 0], [50 250 370 550]);
% Draw sun
Screen('FillOval', wPtr, [256 256 0], [760 20 920 180]);
Screen('DrawLine', wPtr, [0 0 0], 850, 75, 870, 75, 2);
Screen('FrameOval', wPtr, [0 0 0], [800 65 820 85], 2);
Screen('FrameArc', wPtr, [0 0 0], [800 85 870 160], 90, 180, 2);
% Draw name
Screen('TextSize', wPtr, 72);
Screen('DrawText', wPtr, 'Funky Jon''s House', 200, 100, [256 256
256]);
vbl=Screen('Flip', wPtr, vbl+(flipSpd*monitorFlipInterval), 2);
tic;
while toc<3
end
Screen('CloseAll');
ShowCursor;