view 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
line wrap: on
line source
function f=pauser(varargin)
% pauser - Return function to pause or not depending on options
%
% pauser :: options {
%    pause :: natural/0 ~'0 for no pause, 1 pause, >10 for ms pause';
%    drawnow :: {0,1}/1 ~'call drawnow to flush graphics'
% } -> (void => void) ~'function to pause or not'.
%
% pauser(opts) returns a function that does exactly what optpause(opts)
% does.

	opt=options(varargin{:});
	ps=getparam(opt,'pause',0);
	dn=getparam(opt,'drawnow',1);
	if ps, 
		if ps<10, f=@pause;
		else wait=ps/1000; f=@()pause(wait); 
		end 
	elseif dn, f=@drawnow;
	else f=@nop;
	end