/usr/share/psychtoolbox-3/PsychRects/AlignRect.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
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 37 38 39 40 41 42 43 44 45 46 47 48 | function rect=AlignRect(rect,fixedRect,side1,side2)
% rect=AlignRect(rect,fixedRect,side1,[side2])
%
% Moves rect to align its center/top/bottom/left/right with the
% corresponding edge(s)/point of fixedRect. Does "side1" and then "side2".
% The legal values for side1 and side2 are 'center', 'left', 'right',
% 'top', and 'bottom'.
% r=AlignRect(r,screenRect,'center','top');
% For backward compatibility, also accepts 1,2,3,4,5. You may use the
% pre-defined constants RectLeft,RectRight,RectTop,RectBottom, but there is
% no named constant for centering.
% Also see PsychRects.
% Denis Pelli 5/27/96, 7/10/96, 8/5/96, 11/8/06
if nargin<3
error('Usage: rect=AlignRect(rect,fixedRect,side1,[side2])');
end
if size(rect,2)~=4 || size(fixedRect,2)~=4
error('Wrong size rect arguments. Usage: rect=AlignRect(rect,fixedRect,side1,[side2])');
end
side{1}=side1;
if nargin>3
side{2}=side2;
end
for i=1:length(side)
if isnumeric(side{i})
if ~ismember(side{i},1:5)
error('Illegal side1 or side2 value.');
end
elseif ischar(side{i})
[ok,n]=ismember(side{i},{'left','top','right','bottom','center'});
if ~ok
error('Illegal side1 or side2 value.');
end
side{i}=n;
else
error('Illegal side1 or side2 value.');
end
switch side{i}
case 5
rect=CenterRect(rect,fixedRect);
case {RectLeft,RectRight},
rect=OffsetRect(rect,fixedRect(side{i})-rect(side{i}),0);
case {RectTop,RectBottom},
rect=OffsetRect(rect,0,fixedRect(side{i})-rect(side{i}));
end
end
|