普通会员
注册日期: 2007-08-07
帖子: 64
声望力: 20
|
回复: [求助] Matlab产生画板
我贴个matlab画板程序
function huaban
figure
backcolor=get(gcf,'Color');
uicontrol(gcf,'style','text','units','normalized','pos',[0.22 0.9 0.56 0.08],...
'string','Matlab小画板','fontsize',14,'fontweight','bold',...
'fontunits','normalized','Hor','center','ForegroundColor',[0,0,0],...
'bac',backcolor)
uicontrol(gcf,'style','push','units','normalized','pos',[0.8 0.02 0.127 0.08],'string','清 除',...
'fontsize',12,'fontweight','bold','fontunits','normalized','callback','cla;')
axes('Position',[0.12 0.18 0.8 0.7],'Box','on','ButtonDownFcn',{@mouse_xiezh 'start'})
%%-------------------------------------------------------------------------
%子函数
%%-------------------------------------------------------------------------
function mouse_xiezh(hObject, eventdata, action)
switch action
case 'start'
point=get(gca,'CurrentPoint');
line(point(1,1),point(1,2),'clipping','on','erasemode','background','marker','.');
set(gcbf,'WindowButtonMotionFcn',{@mouse_xiezh 'move'});
set(gcbf,'WindowButtonUpFcn',{@mouse_xiezh 'stop'});
case 'move'
point=get(gca,'CurrentPoint');
line(point(1,1),point(1,2),'clipping','on','erasemode','background','marker','.');
case 'stop'
set(gcbf,'WindowButtonMotionFcn','');
set(gcbf,'WindowButtonUpFcn','');
end
|