## Copyright (C) 2013 Adam H Aitkenhead ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{mapnew}] =} rgbmap (@var{tol}, @var{rlim}, @var{glim}, @var{blim}) ## Generate an rgb colormap. ## ## @var{tol} is the maximum step size in the RGB color values. @var{rlim}, @var{glim} and @var{blim} ## define the minimum and maximum of the range of values in each of the RGB color channels. ## ## @seealso{rgb2ind} ## @end deftypefn ## Author: Adam H Aitkenhead ## Created: May 2013 function [mapnew] = rgbmap (tol,rlim,glim,blim) if tol>1 error ("rgbmap: tol must be <= 1") end steprgb = [round( diff (rlim)/tol), round( diff (blim)/tol), round( diff (blim)/tol)]; r = rlim(1):diff (rlim)/steprgb(1):rlim(2); g = glim(1):diff (glim)/steprgb(2):glim(2); b = blim(1):diff (blim)/steprgb(3):blim(2); mapnew = zeros (prod (steprgb),3); loopi = 0; for loopr = 1:numel (r) for loopg = 1:numel (g) for loopb = 1:numel (b) loopi = loopi + 1; mapnew(loopi,:) = [r(loopr),g(loopg),b(loopb)]; end end end endfunction