How to limit the movement of a rectangle?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
BoSeon Kang
am 14 Nov. 2019
Kommentiert: BoSeon Kang
am 15 Nov. 2019
I use RectangleMovingEvent.
But I want to move the rectangle only vertically.
So I changed the values of PreviousPosition and CurrentPosition, but they are the same.
How do I limit the movement of the rectangle ??
roi = drawrectangle('Position',p ,'Color',[1 0 0]);
addlistener(roi, 'MovingROI', @(a, b)roi_moved(a, b, handles));
function roi_moved(hObject, eventdata, handles)
p = hObject.Position;
0 Kommentare
Akzeptierte Antwort
Stijn Haenen
am 14 Nov. 2019
maybe this will work:
roi = drawrectangle('Position',p ,'Color',[1 0 0]);
t=0;
while t<1
pause(0.15);pos=get(roi,'position');
set(roi,'position',[p(1) pos(2) p(3) p(4)])
t=t+0.01;
end
1 Kommentar
Weitere Antworten (1)
Stijn Haenen
am 14 Nov. 2019
Maybe you can use the function:
get(roi,'position')
But i'm not sure what you want.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!