0001 function m = Bright(n,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 hgamma = 1;
0029 type = 'linear';
0030 stops = [];
0031 linearStops = [2/3 0];
0032 circularStops = [0 1];
0033
0034
0035 if nargin < 1,
0036 n = 100;
0037 elseif ischar(n),
0038 varargin = {n,varargin{:}};
0039 n = 100;
0040 elseif ~isdscalar(n,'>=0'),
0041 error('Incorrect value for ''n'' (type ''help <a href="matlab:help Bright">Bright</a>'' for details).');
0042 end
0043
0044
0045 if mod(length(varargin),2) ~= 0,
0046 error('Incorrect number of parameters (type ''help <a href="matlab:help Bright">Bright</a>'' for details).');
0047 end
0048
0049
0050 for i = 1:2:length(varargin),
0051 if ~ischar(varargin{i}),
0052 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help Bright">Bright</a>'' for details).']);
0053 end
0054 switch(lower(varargin{i})),
0055 case 'hgamma',
0056 hgamma = varargin{i+1};
0057 if ~isdscalar(hgamma,'>=0'),
0058 error('Incorrect value for property ''hgamma'' (type ''help <a href="matlab:help Bright">Bright</a>'' for details).');
0059 end
0060 case 'stops',
0061 stops = varargin{i+1};
0062 if ~isdvector(stops,'>=0','<=1') || length(stops) < 2,
0063 error('Incorrect value for property ''stops'' (type ''help <a href="matlab:help Bright">Bright</a>'' for details).');
0064 end
0065 case 'type',
0066 type = lower(varargin{i+1});
0067 if ~isastring(type,'linear','circular'),
0068 error('Incorrect value for property ''type'' (type ''help <a href="matlab:help Bright">Bright</a>'' for details).');
0069 end
0070 otherwise,
0071 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help Bright">Bright</a>'' for details).']);
0072 end
0073 end
0074
0075
0076 if isempty(stops),
0077 if strcmp(type,'circular'),
0078 stops = circularStops;
0079 else
0080 stops = linearStops;
0081 end
0082 end
0083 if strcmp(type,'circular') && stops(1) ~= stops(end) && abs(stops(1)-stops(end)) ~= 1,
0084 stops(end+1) = stops(1);
0085 end
0086
0087
0088 nBands = length(stops)-1;
0089
0090
0091 hsv = [];
0092 nn = round(n/nBands);
0093 for i = 1:nBands,
0094 hsv = [hsv ; linspace(0,1,nn)'.^(1/hgamma)*(stops(i+1)-stops(i))+stops(i)];
0095 end
0096 n = length(hsv);
0097
0098
0099 hsv(:,2) = 1;
0100 hsv(:,3) = 1;
0101 m = hsv2rgb(hsv);
0102