Drawing multiple objects is easy. All you need to do is list everything you want to draw before you "flip".
Open a new script. We will start by using our standard start of script commands:
clc;
clear all;
close all;
rng('shuffle');
Screen('Preference', 'SkipSyncTests', 1);
[window, window_size] = Screen('OpenWindow', 0, [0 0 0], [],32,2);
% lets figure out the coordinates of the middle of the screen
x_mid = window_size(3)/2;
y_mid = window_size(4)/2;
% Now, lets draw some stuff
Screen('FillOval', window , [255 0 0], [x_mid-200 y_mid-200 x_mid+200 y_mid+200]);
Screen('FillRect', window , [0 255 0], [x_mid-75 y_mid-75 x_mid+75 y_mid+75]);
% and flip it to the screen
Screen('Flip',window);
% and wait for a bit
WaitSecs(3);
% and close it all down
Screen('CloseAll');
If you run that bit of code (which is also HERE) you should see a green square inside a red circle.
Activity
Try playing around and drawing a bunch of stuff!
Drawing Incremental Objects
So, sometimes you may want to draw one item then another. There are a couple of ways to do this. One is to just use multiple flip commands in a row. The other is to slightly tweak the flip command. If you use
Screen('Flip',window,0,1);
The extra bits do stuff. The 0 is effectively when to draw - 0 makes it as fast as possible. The 1 however allows incremental drawing of stimuli as it tells Screen to now erase previously drawn stimuli.
HERE is an example that tweaks our original code to draw things incrementally.
HERE is a more complex example that draws 20 circles randomly around the screen in different colours.
Move onto the next tutorial!
Open a new script. We will start by using our standard start of script commands:
clc;
clear all;
close all;
rng('shuffle');
Screen('Preference', 'SkipSyncTests', 1);
[window, window_size] = Screen('OpenWindow', 0, [0 0 0], [],32,2);
% lets figure out the coordinates of the middle of the screen
x_mid = window_size(3)/2;
y_mid = window_size(4)/2;
% Now, lets draw some stuff
Screen('FillOval', window , [255 0 0], [x_mid-200 y_mid-200 x_mid+200 y_mid+200]);
Screen('FillRect', window , [0 255 0], [x_mid-75 y_mid-75 x_mid+75 y_mid+75]);
% and flip it to the screen
Screen('Flip',window);
% and wait for a bit
WaitSecs(3);
% and close it all down
Screen('CloseAll');
If you run that bit of code (which is also HERE) you should see a green square inside a red circle.
Activity
Try playing around and drawing a bunch of stuff!
Drawing Incremental Objects
So, sometimes you may want to draw one item then another. There are a couple of ways to do this. One is to just use multiple flip commands in a row. The other is to slightly tweak the flip command. If you use
Screen('Flip',window,0,1);
The extra bits do stuff. The 0 is effectively when to draw - 0 makes it as fast as possible. The 1 however allows incremental drawing of stimuli as it tells Screen to now erase previously drawn stimuli.
HERE is an example that tweaks our original code to draw things incrementally.
HERE is a more complex example that draws 20 circles randomly around the screen in different colours.
Move onto the next tutorial!