function colors = Get_Colors( numColors, type)
%function colors = Get_Colors( numColors, type)
%
%Determines colors matching the specified type and number of colors needed.
%
%
%INPUTS
%
%numColors                  Number of colors
%type                       String describing type of colormap and spectrum rule
%                           Possible values
%                               'seq' for linspecer in sequential mode
%                               'seq+' for modded linspecer in sequential mode
%                               'qual' linspecer in qualitative mode (N < 12)
%                               'dist' for Distinguishable_Colors.m background
%                                   except for white, black, and yellow
%                               'jet' for interpolating across the 'jet' cmap
%
%
%OUTPUTS
%
%colors                     N x 3 matrix of normalized RGB values.
%
%
%NOTE
%
%For 'Seq', 'Seq+', and 'Jet' modes, the colors are aligned with a spectrum such
%that the first color is red.
%
%
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%X Author:          Sky Cheung                                                X
%X Date Created:    15 Jan 2015                                               X
%X Last Modified:   02 Sep 2015                                               X
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%

%Input Parsing
p = inputParser;
%Possible X Data
expectedType = {'seq','seq+','qual','dist','jet'};

%Parsing Conditions for Required Arguments
addRequired(p, 'numColors', @(x) validateattributes( x, ...
    {'numeric'}, {'nonempty','scalar'} ) );
addRequired(p, 'type', @(x) any( validatestring( x, ...
    expectedType)) );

%Parsing Inputs
parse(p, numColors, type);

%Getting proper inputs
numColors = p.Results.numColors;
type = p.Results.type;

%Delete Stucture
clear p;

%Calculate colors
switch lower(type)
    case 'seq'
        colors = flipud( linspecer( numColors, 'sequential') );
    case 'qual'
        colors = linspecer( numColors, 'qualitative');
    case 'dist'
        colors = Distinguishable_Colors( numColors, {'w','k','y'});
    case 'seq+'
        %Define modded linspecer (less yellow) colormap (64x3)
        linspecer_mod =  [...
                0.619607865810394, 0.00392156885936856, 0.258823543787003;
                0.652880132198334, 0.0412740670144558, 0.265875905752182;
                0.686152458190918, 0.0786265656352043, 0.272928267717361;
                0.719424724578857, 0.115979060530663, 0.279980629682541;
                0.752697050571442, 0.153331562876701, 0.287033021450043;
                0.785969316959381, 0.190684065222740, 0.294085383415222;
                0.819241642951965, 0.228036552667618, 0.301137745380402;
                0.852513909339905, 0.265389055013657, 0.308190107345581;
                0.872166335582733, 0.293868035078049, 0.299340933561325;
                0.891818702220917, 0.322347044944763, 0.290491789579392;
                0.911471128463745, 0.350826025009155, 0.281642615795136;
                0.931123495101929, 0.379305034875870, 0.272793471813202;
                0.950775921344757, 0.407784014940262, 0.263944298028946;
                0.955181896686554, 0.425804436206818, 0.266038328409195;
                0.959587931632996, 0.443824887275696, 0.268132328987122;
                0.963993906974793, 0.461845308542252, 0.270226359367371;
                0.968399882316589, 0.479865729808807, 0.272320389747620;
                0.969309747219086, 0.485077857971191, 0.274358630180359;
                0.970219552516937, 0.490289986133575, 0.276396870613098;
                0.971129417419434, 0.495502144098282, 0.278435111045837;
                0.972039222717285, 0.500714302062988, 0.280473351478577;
                0.972949087619782, 0.505926430225372, 0.282511621713638;
                0.973858952522278, 0.511138558387756, 0.284549862146378;
                0.974768757820129, 0.516350686550140, 0.286588102579117;
                0.975678622722626, 0.521562814712524, 0.288626343011856;
                0.948359608650208, 0.530060529708862, 0.240521952509880;
                0.921040654182434, 0.538558244705200, 0.192417562007904;
                0.893721699714661, 0.547055959701538, 0.144313171505928;
                0.866402685642242, 0.555553615093231, 0.0962087810039520;
                0.839083671569824, 0.564051330089569, 0.0481043905019760;
                0.811764717102051, 0.572549045085907, 0;
                0.925490200519562, 0.745098054409027, 0.160784319043159;
                0.678431391716003, 0.858823537826538, 0.235294118523598;
                0.662549316883087, 0.852863013744354, 0.257123082876205;
                0.646667242050171, 0.846902430057526, 0.278952032327652;
                0.630785167217255, 0.840941905975342, 0.300780981779099;
                0.614903032779694, 0.834981381893158, 0.322609931230545;
                0.599020957946777, 0.829020798206329, 0.344438880681992;
                0.583138883113861, 0.823060274124146, 0.366267859935761;
                0.567256808280945, 0.817099690437317, 0.388096809387207;
                0.551374733448029, 0.811139166355133, 0.409925758838654;
                0.535492658615112, 0.805178642272949, 0.431754708290100;
                0.519610583782196, 0.799218058586121, 0.453583657741547;
                0.503728508949280, 0.793257534503937, 0.475412636995316;
                0.487846404314041, 0.787297010421753, 0.497241586446762;
                0.471964329481125, 0.781336426734924, 0.519070506095886;
                0.456082224845886, 0.775375902652741, 0.540899515151978;
                0.440200150012970, 0.769415318965912, 0.562728464603424;
                0.424318075180054, 0.763454794883728, 0.584557414054871;
                0.408436000347137, 0.757494270801544, 0.606386363506317;
                0.392553895711899, 0.751533687114716, 0.628215312957764;
                0.376671820878983, 0.745573163032532, 0.650044262409210;
                0.334348231554031, 0.714649140834808, 0.663251340389252;
                0.293138742446899, 0.676945567131043, 0.684087336063385;
                0.251929253339767, 0.639241933822632, 0.704923331737518;
                0.220245316624641, 0.598834753036499, 0.724715948104858;
                0.200519397854805, 0.559342324733734, 0.738031446933746;
                0.196435824036598, 0.522600889205933, 0.740923643112183;
                0.202895477414131, 0.486889302730560, 0.736469209194183;
                0.217748835682869, 0.451275378465652, 0.726566374301910;
                0.241372317075729, 0.415759444236755, 0.711356282234192;
                0.274142324924469, 0.380341947078705, 0.690980136394501;
                0.316435217857361, 0.345023304224014, 0.665579020977020;
                0.368627458810806, 0.309803932905197, 0.635294139385223; ...
            ] ;
        %Interpolate
        xfind = linspace(0,1,numColors) * length(linspecer_mod);
        xfind(1) = 1;
        colors = interp1( ...
            1:length(linspecer_mod), ...
            linspecer_mod, xfind, 'linear');
    case 'jet'
        %Get jet colormap
        colorsJet = jet(256);
        %interpolate
        xfind = linspace(0,1,numColors) * length(colorsJet);
        xfind(1) = 1;
        colors = interp1( ...
            1:length(colorsJet), ...
            colorsJet, xfind, 'linear');
end %End of switch
        

end %End of Get_Colors.m
