Mercurial > hg > ishara
changeset 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 547c48f3a008 |
children | |
files | graphics/colour/hsvx.m |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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