Mercurial > hg > ishara
view arrows/@emousepos/construct.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 672052bd81f8 |
children |
line wrap: on
line source
function u=construct(s,sizes_in) fg=fig(s); figure(fg); ax=gca; current_pos={}; %[nan;nan]; btnisup=1; if ~isempty(s.opts.xlim), xlim(s.opts.xlim); end if ~isempty(s.opts.ylim), xlim(s.opts.ylim); end if isfield(s.opts,'ylabel'), ylabel(s.opts.ylabel); end if isfield(s.opts,'xlabel'), xlabel(s.opts.xlabel); end if isfield(s.opts,'box'), box(s.opts.box); end u=mkunit(s); u.process=@proc; u.sizes_out = {[2,1]}; u.dispose = @dispose; u.starting = @starting; u.stopping = @stopping; function starting set(ax,'ButtonDownFcn',@btndown); set(fg,'WindowButtonMotionFcn',[]); end function stopping set(ax,'ButtonDownFcn',[]); set(fg,'WindowButtonMotionFcn',[]); end function x=proc, x=current_pos; if btnisup, current_pos={}; end % [nan;nan]; end end function btndown(a,b), set(fg,'WindowButtonMotionFcn',@move,'WindowButtonUpFcn',@btnup); btnisup=0; move(a,b); end function btnup(a,b), set(fg,'WindowButtonMotionFcn',[]); btnisup=1; end function move(a,b), cp=get(ax,'CurrentPoint'); current_pos={cp(1,1:2)'}; end function dispose set(ax,'ButtonDownFcn',[]); set(fg,'WindowButtonMotionFcn',[]); end end