-
Notifications
You must be signed in to change notification settings - Fork 0
/
showText.m
63 lines (54 loc) · 1.47 KB
/
showText.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function showText( str, xoffset, yoffset )
%
% Show text using dXtext method, have subject press space bar to proceed.
% Standardized to display text such that letters occupy 0.7 degrees in the
% visual field.
%
% str = n x 1 cell containing string to be shown. Each row should contain
% one line of text.
%
% Eliezer Kanal, 10/19/10
if nargin == 1
xoffset = 0;
yoffset = 0;
end
if nargin == 2
yoffset = 0;
end
[wn_, sr_, ppd_, fr_] = rGraphicsGetScreenAttributes;
font_degrees = 0.7;
fontsize = floor(font_degrees * ppd_);
if ~iscell(str)
str = {str};
end
for i = 1:length(str)
textwidth = fontsize * length(str{i})/ppd_;
x_pos{i} = -0.3 * textwidth + xoffset;
end
% Equally distribute lines in middle of screen
y_pos = font_degrees * (length(str):-1:1) - (floor(length(str)/2)) - yoffset;
y_pos = num2cell(y_pos);
if length(str) == 1
if iscell(str)
str = cell2mat(str);
end
x_pos = cell2mat(x_pos);
y_pos = cell2mat(y_pos);
end
indices = rAdd( ...
'dXtext', length(str), ...
'visible', true, ...
'x', x_pos, ...
'y', y_pos, ...
'size', fontsize, ...
'font', 'Courier', ...
'bold', true, ...
'color', [1 1 1]*255, ...
'string', str);
spacekey = 44; % Only accept a space as the command to quit:
[ keySecs, myKeyCode ] = rGraphicsDrawSelectiveBreakMulti(inf,[],spacekey);
while KbCheckMulti
WaitSecs(0.002);
end
rSet('dXtext',indices,'visible',false);
rGraphicsDraw;