MATLAB Programming/Psychtoolbox/expanding rectangle.m

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Back to MATLAB Programming/Psychtoolbox
% expanding_rectangle.m
%
% draws an expanding rectangle on the screen
%
% Revision History:
% RobKohr - April 7, 2005 - First draft

%This requires two scripts: ptb_ind_screen_setup.m and ptb_ind_flip.m

clear all;

%set the screen up. This should be used at the after clear all
ptb_ind_screen_setup;

shape_rect = window_rect/2;

tic
while( (shape_rect(3)< ...
        window_rect(3)) & ...
        (shape_rect(4)< ...
        window_rect(4))...
        )
    if(toc>10)
        break;
    end
    
    %expand the size of the shape
    shape_rect = shape_rect*1.01;
    
    %draw  shape offscreen
    Screen(window, 'FillRect', [255, 0, 0], shape_rect);
    
    %flip copys what you have drawn to the screen
    ptb_ind_flip;
end
clear screen;