-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplitBarRect.m
25 lines (22 loc) · 959 Bytes
/
SplitBarRect.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
function [ BarRectOut ] = SplitBarRect( BarRectIn, NumBlocks, ScreenRect )
%SplitBarRect
% Split rectangulars in to sub rects so that we can draw square
% gratings. BarRectIn should by 4 by N (frames) matrix. BarRectOut is 4
% by N by Num matrix
BarRectOut = repmat(BarRectIn, 1,1,NumBlocks);
if (BarRectIn(3,1)-BarRectIn(1,1))<(BarRectIn(4,1)-BarRectIn(2,1)) % vertical bar
BlockLength = ScreenRect(4)/NumBlocks;
BarRectOut(4,:,1) = BarRectOut(2,:,1) + BlockLength;
for iblock = 2:NumBlocks
BarRectOut(2,:,iblock) = BarRectOut(4,:,iblock-1);
BarRectOut(4,:,iblock) = BarRectOut(2,:,iblock) + BlockLength;
end
else
BlockLength = ScreenRect(3)/NumBlocks;
BarRectOut(3,:,1) = BarRectOut(1,:,1) + BlockLength;
for iblock = 2:NumBlocks
BarRectOut(1,:,iblock) = BarRectOut(3,:,iblock-1);
BarRectOut(3,:,iblock) = BarRectOut(1,:,iblock) + BlockLength;
end
end
BarRectOut = round(BarRectOut);