📄 isefcall.m
字号:
function isefcall()
global XSIZE
global YSIZE
global MAINFIG
global FITHANDLES
global BEELD
BEELD = get(MAINFIG, 'userdata');
%cirkel;
%set(MAINFIG, 'userdata', BEELD);
%SIZE = max(XSIZE,YSIZE);
SIZE=32;
routine('new'); % clear lijst van punten
maxnrofpoints = 12;
error = 0;
direction = 0;
% scan een eerste horizontale lijn om te kunnen starten
[x y] = iseffil([1,YSIZE], 0, XSIZE,1);
addpoint(x,y);
yp = floor(YSIZE/8);
% scan een tweede horizontale lijn om verder te kunnen
[x y] = iseffil([1,YSIZE-yp], 0, XSIZE,1);
addpoint(x,y);
if ((get(FITHANDLES(1,12), 'value'))<2)
seterror('Something went wrong, i am very sorry.');
error = 1;
end
nrofpoints = get(FITHANDLES(1,12), 'value');
rotate = 0;
while (error==0)
%nrofpoints = get(FITHANDLES(1,12), 'value');
x2 = get(FITHANDLES(3,nrofpoints),'value');
y2 = get(FITHANDLES(4,nrofpoints),'value');
x1 = get(FITHANDLES(3,nrofpoints-1),'value');
y1 = get(FITHANDLES(4,nrofpoints-1),'value');
tangens=(x1-x2)/(y1-y2);
xstart=round(x2);
ystart=round(y2);
if (abs(tangens) < 0.5)
direction = 0;
elseif (tangens > 0.5) & (tangens < 2)
direction = 3;
elseif (abs(tangens) > 2)
direction = 2;
elseif (tangens < -0.5) & (tangens > -2)
direction = 1;
end
direction=mod(direction+rotate,4);
if direction==0
ystart=ystart-yp;
if inbox(xstart,ystart)
xstart=xstart-(SIZE/2); if xstart < 1 xstart = 1; end
else error = 1;
end
elseif direction==2
xstart=xstart-(sign(x1-x2)*yp);
if inbox(xstart,ystart)
ystart=ystart-(SIZE/2);
if ystart < 1
ystart = 1;
end
else error = 1;
end
elseif direction==1
xstart = xstart+yp;
ystart = ystart-yp;
if inbox(xstart,ystart)
xstart = xstart-SIZE/2;
ystart = ystart-SIZE/2;
if ystart<1
xstart=xstart-(ystart-1);
ystart=1;
end
if xstart<1
ystart=ystart-(xstart-1);
xstart=1;
end
else error = 1;
end
elseif direction==3
if sign(x1-x2)==0
teken=1;
else teken = sign(x1-x2);
end
xstart = xstart-(teken*yp); ystart = ystart-(teken*yp); if inbox(xstart,ystart)
xstart = xstart-SIZE/2;
ystart = ystart+SIZE/2;
if (xstart < 1)
ystart = ystart + (xstart-1);
xstart = 1;
end
if (ystart > YSIZE)
xstart = xstart + (ystart-YSIZE);
ystart = YSIZE;
end
else error = 1;
end
end
if (nrofpoints < maxnrofpoints) & (error == 0) & (abs(rotate) < 3)
[x y color] = iseffil([xstart,ystart], direction, SIZE,1);
if color == 0
rotate = 0;
addpoint(x,y);
nrofpoints=nrofpoints+1;
else rotate = rotate - color;
end
else
error = 1;
seterror(' Cannot detect more points. Maybe the next point will be out of the box.');
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -