annotate general/algo/pauser.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents beb8a3f4a345
children
rev   line source
samer@4 1 function f=pauser(varargin)
samer@4 2 % pauser - Return function to pause or not depending on options
samer@4 3 %
samer@4 4 % pauser :: options {
samer@4 5 % pause :: natural/0 ~'0 for no pause, 1 pause, >10 for ms pause';
samer@4 6 % drawnow :: {0,1}/1 ~'call drawnow to flush graphics'
samer@4 7 % } -> (void => void) ~'function to pause or not'.
samer@4 8 %
samer@4 9 % pauser(opts) returns a function that does exactly what optpause(opts)
samer@4 10 % does.
samer@4 11
samer@37 12 opt=options(varargin{:});
samer@4 13 ps=getparam(opt,'pause',0);
samer@4 14 dn=getparam(opt,'drawnow',1);
samer@4 15 if ps,
samer@4 16 if ps<10, f=@pause;
samer@4 17 else wait=ps/1000; f=@()pause(wait);
samer@4 18 end
samer@4 19 elseif dn, f=@drawnow;
samer@4 20 else f=@nop;
samer@4 21 end