求助画图程序
%要求在当前坐标轴下,用鼠标拖动划线。按鼠标左键出现+,之后拖动鼠标,松开点即为结束点,可多次划线。问题是划线的起点是原点,不能多次划线。源程序:<BR>function ex_draw(arg)<BR>global DRAW_HL<BR>if nargin==0<BR> arg='ex_line'<BR>end<BR>if isstr(arg)<BR> clear all<BR> Hf=gcf;<BR> set(Hf,'pointer','corssh','backingstore','off',...<BR> 'windowbuttondownfcn','ex_draw(1)');<BR> figure(Hf);<BR>elseif arg==1<BR> fp=get(gca,'currentpoint');<BR> set(gca,'userdata',fp(1,1:2));<BR> set(gcf,'windowbuttonmotionfcn','ex_draw(2)',...<BR> 'windowbuttonupfcn','ex_draw(3)')<BR>elseif arg==2<BR> cp=get(gca,'currentpoint');cp=cp(1,1:2);<BR> fp=get(gca,'userdata');<BR> H1=line('xdata',,'ydata',...<BR> ,'erasemode','xor','color',...<BR> 'r','linestyle','-','clipping','off');<BR> if ~isempty(DRAW_HL)<BR> delete(DRAW_HL)<BR> end<BR> DRAW_H1=H1;<BR>elseif arg==3<BR> set(gcf,'pointer','arrow',...<BR> 'backingstore','on',...<BR> 'windowbuttondownfcn','',...<BR> 'windowbuttonmotionfcn','',...<BR> 'windowbuttonupfcn','')<BR>set(gca,'userdata',[]);<BR>set(DRAW_HL,'erasemode','normal')<BR>key=waitforbuttonpress;<BR>if key<BR> gtext('finish');<BR> return;<BR>esle<BR> ex_draw;<BR>end<BR>end
页:
[1]