annotate graphics/animseq.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 82075c94eed1
children
rev   line source
samer@47 1 function varargout=animdata(upd,X,varargin)
samer@47 2 % animdata - use arbitrary function to animate data sequence
samer@47 3 %
samer@47 4 % animdata ::
samer@47 5 % A->unit ~'function to update animation',
samer@47 6 % seq A ~'data sequence to plot',
samer@47 7 % options {
samer@47 8 % pre :: action / @nop ~'called before each plot';
samer@47 9 % post :: action / @nop ~'called after eacn plot';
samer@47 10 % defer :: bool / 0 ~'if 1, just return state transformer function';
samer@47 11 % fps :: nonneg / 0 ~'if positive, used timed iterator at this rate'
samer@47 12 % }
samer@47 13 % -> (A->A,handle) ~'action to iterate',
samer@47 14 % A ~'initial state'.
samer@47 15
samer@47 16
samer@47 17
samer@47 18 opts=prefs('fps',0,'pre',@nop,'post',@nop,'defer',0,varargin{:});
samer@47 19
samer@47 20 if opts.defer,
samer@47 21 stfn=@plotnext_h;
samer@47 22 elseif opts.fps>0
samer@47 23 stfn=@plotnext;
samer@47 24 API=iterate_timed(stfn,X,1/opts.fps,opts);
samer@47 25 if nargout==1, varargout{1}=API; end
samer@47 26 else
samer@47 27 stfn=@plotnext;
samer@47 28 iterate(stfn,X,opts);
samer@47 29 if nargout==1, varargout{1}={stfn,X}; else varargout={stfn,X}; end
samer@47 30 end
samer@47 31
samer@47 32
samer@47 33 function S=plotnext(S), upd(head(S)); S=next(S); end
samer@47 34 function [S,h]=plotnext_h(S),
samer@47 35 upd(head(S)); S=next(S);
samer@47 36 if nargout>1, h=get(gca,'title'); end
samer@47 37 end
samer@47 38 end
samer@47 39
samer@47 40