/usr/share/psychtoolbox-3/PsychTests/TestTextBounds.m is in psychtoolbox-3-common 3.0.12.20160126.dfsg1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | % TestTextBounds - Test function of the TextBounds() function.
% History:
% 16-Dec-2015 dgp Written.
x=50;
y=98;
textSize = 48;
string = 'Click to quit';
w=Screen('OpenWindow',0,255);
woff=Screen('OpenOffscreenWindow',w,[],[0 0 2*textSize*length(string) 2*textSize]);
Screen(woff,'TextFont','Arial');
Screen(woff,'TextSize',textSize);
for yPositionIsBaseline=0:1
textSize=48;
if yPositionIsBaseline
string='Origin at baseline. ';
else
string='Origin at upper left.';
end
t=GetSecs;
bounds=TextBounds(woff,string,yPositionIsBaseline);
fprintf('TextBounds took %.3f seconds.\n',GetSecs-t);
Screen(w,'TextFont','Arial');
Screen(w,'TextSize',textSize);
[newX,newY]=Screen('DrawText',w,string,x,y,0,255,yPositionIsBaseline);
Screen('FrameRect',w,0,InsetRect(OffsetRect(bounds,x,y),-1,-1));
x=newX;
y=newY;
end
Screen('Close',woff);
DrawFormattedText(w, 'Click to quit', 'center', 'center');
Screen('Flip',w);
GetClicks;
Screen('Close',w);
|