# HG changeset patch # User samer # Date 1444555242 -3600 # Node ID eff6bddf82e300da706f109c889e12a8a6996fd8 # Parent 547c48f3a00837c069d22aeda1e9bd24c8933e67 Finally implemented perceptual brightness thing. diff -r 547c48f3a008 -r eff6bddf82e3 graphics/colour/hsvx.m --- a/graphics/colour/hsvx.m Sat Oct 10 15:20:18 2015 +0100 +++ b/graphics/colour/hsvx.m Sun Oct 11 10:20:42 2015 +0100 @@ -8,7 +8,7 @@ % 0--1 ~'saturation', % 0--1 ~'value' % options { -% brightness :: bool/0 ~'try to get even perceptual brightness' +% brightness :: real/0 ~'try to get even perceptual brightness: 0 not, 1 full' % } % -> [[N,3]]. @@ -17,8 +17,14 @@ if nargin<2, H0=0; end if nargin<3, S=1; end if nargin<4, V=1; end + opts=options('brightness',0,varargin{:}); H=linspace(H0,H0+1,N+1); M=hsv2rgb([mod(H(1:end-1),1)',repmat([S,V],N,1)]); + if opts.brightness >0 + L=luminocity(M).^opts.brightness; + M=M./repmat(L,1,3); + M=V*M./max(max(M)); + end end