Okay, no we are going to learn to write some text in a PSYCHTOOLBOX window.
Open a new script. Use all the standard commands.
clc;
clear all;
close all;
rng('shuffle');
Screen('Preference', 'SkipSyncTests', 1);
[window, window_size] = Screen('OpenWindow', 0, [0 0 0], [],32,2);
Now, to draw some text there are few options, let's start with:
Screen(window,'TextFont','Arial');
Screen(window,'TextSize',40);
DrawFormattedText(window, ['Some Text'],'center', 'center', [255 0 0],[],[],[],2);
This will draw the text 'Some Text' in the middle of the screen with a colour of [255 0 0]. You will see that we have specified a text font and a text size. You only need to do this once unless you would like to change the text font and size. MATLAB will remember the set values for all subsequent text drawing commands unless you change them again.
Screen('Flip',window);
WaitSecs(3);
Screen('CloseAll');
My code for this is here if you need it: my_experiment3.m
Now, some activities to learn some more.
1. Try changing the text font and text size and text colour. I will leave this to you to figure out.
2. Replace the text font and text size and text colour with variables. Again, hopefully by now you can do this.
3. Draw the text in a specified location. Hint:
DrawFormattedText(window, ['Some Text'],100,100, [255 0 0],[],[],[],2);
Now, play some more then move onto the next tutorial.
Open a new script. Use all the standard commands.
clc;
clear all;
close all;
rng('shuffle');
Screen('Preference', 'SkipSyncTests', 1);
[window, window_size] = Screen('OpenWindow', 0, [0 0 0], [],32,2);
Now, to draw some text there are few options, let's start with:
Screen(window,'TextFont','Arial');
Screen(window,'TextSize',40);
DrawFormattedText(window, ['Some Text'],'center', 'center', [255 0 0],[],[],[],2);
This will draw the text 'Some Text' in the middle of the screen with a colour of [255 0 0]. You will see that we have specified a text font and a text size. You only need to do this once unless you would like to change the text font and size. MATLAB will remember the set values for all subsequent text drawing commands unless you change them again.
Screen('Flip',window);
WaitSecs(3);
Screen('CloseAll');
My code for this is here if you need it: my_experiment3.m
Now, some activities to learn some more.
1. Try changing the text font and text size and text colour. I will leave this to you to figure out.
2. Replace the text font and text size and text colour with variables. Again, hopefully by now you can do this.
3. Draw the text in a specified location. Hint:
DrawFormattedText(window, ['Some Text'],100,100, [255 0 0],[],[],[],2);
Now, play some more then move onto the next tutorial.