이 제출물을 팔로우합니다
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다
Draws rectangle which can be dragged or resized by mouse pointer
D = draggableRectangle (parent_axes,xrange,yrange,...);
input
parent_axes : axes object : axes for drawing rectangle
xrange : 1 x 2 numeric : [xmin xmax]
yrange : 1 x 2 numeric : [ymin ymax]
name-value pairs
xdirlock : logical scalar : lock x direction drag
ydirlock : logical scalar : lock y direction drag
buttonDownFcn : function handle : callback executed upon mouse click
buttonDragFcn : function handle : callback executed upon mouse drag movement
buttonUpFcn : function handle : callback executed upon mouse release
additional name-value pair argument for 'patch' can be followed after these arguments (see:https://www.mathworks.com/help/matlab/ref/matlab.graphics.primitive.patch-properties.html)
properties
xrange : 1 x 2 numeric : current x range of rectangle
yrange : 1 x 2 numeric : current y range of rectangle
xdirlock : logical scalar : if true, locks x dir dragging
ydirlock : logical scalar : if true, locks y dir dragging
bezel : numeric positive scalar : determines width of edge dragging region
isdragging : logical scalar (read only) : true if object under dragging
buttonDownFcn(hObject,eventdata) : function handle : function executed when mouse is clicked on this object
buttonDragFcn(hObject,eventdata) : function handle : function executed when mouse is moved during drag
buttonUpFcn(hObject,eventdata) : function handle : function executed when drag is finished
Additional properties for 'patch' are available.
Standard get & set functions are available.
methods
D.drag_start([movingx,movingy]);
example
% draw axis
axis([0 40 0 60]);
% draw rectangle
D = draggableRectangle([10 30],[20 40],'facecolor','r');
% force start dragging
D.drag_start([-1,0]) % move left edge
% wait until dragging is done
while D.isdragging
pause(0.05)
end
% Here, we change rectangle's properties (same properties as 'patch')
D.FaceColor = 'y';
set(D,'EdgeColor','none');
% force start dragging
D.drag_start([1,1]) % move top right vertex
% wait until dragging is done
while D.isdragging
pause(0.05)
end
% Here, we define user callback
% force start dragging
D.drag_start([0,0]) % move position
% set mouse release callback
D.buttonUpFcn = @(h,~) fprintf('moved position : [%.2f %.2f %.2f %.2f]\n',h.xrange,h.yrange);
인용 양식
Hyeokjin Jho (2026). draggableRectangle (https://kr.mathworks.com/matlabcentral/fileexchange/84370-draggablerectangle), MATLAB Central File Exchange. 검색 날짜: .
