view arrows/vecedit.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
% vecedit - Graphical editor for real-valued vector
%
% vecedit ::
%    [[N]] ~'initial value of editable vector',
%    options {
%       fig :: handle/gcf ~'figure to use';
%    }
% -> arrow({},{[[N]]},vecedit_state) ~'arrow that generates vectors'.
%
% vecedit takes all options accepted by emousepos and plotter.
function o=vecedit(x0,varargin)
	N=length(x0); x0=x0(:);
	opts=options(varargin{:});
	o = emousepos(opts) * erate(loop(@edit,@(z)x0) * obs_with(plotter(opts)),{[2,1]}) * alatch(x0);

	function [f,g]=edit(m,f)
		i=round(m(1));
		if i>=1 && i<=N, f(i)=m(2); end
		g=f;
	end
end