home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / image / colormap.m < prev    next >
Text File  |  1999-12-24  |  2KB  |  66 lines

  1. ## Copyright (C) 1996 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## -*- texinfo -*-
  21. ## @deftypefn {Function File} {} colormap (@var{map})
  22. ## @deftypefnx {Function File} {} colormap ("default")
  23. ## Set the current colormap.
  24. ## 
  25. ## @code{colormap (@var{map})} sets the current colormap to @var{map}.  The
  26. ## color map should be an @var{n} row by 3 column matrix.  The columns
  27. ## contain red, green, and blue intensities respectively.  All entries
  28. ## should be between 0 and 1 inclusive.  The new colormap is returned.
  29. ## 
  30. ## @code{colormap ("default")} restores the default colormap (a gray scale
  31. ## colormap with 64 entries).  The default colormap is returned.
  32. ## 
  33. ## With no arguments, @code{colormap} returns the current color map.
  34. ## @end deftypefn
  35.  
  36. ## Author: Tony Richardson <amr@mpl.ucsd.edu>
  37. ## Created: July 1994
  38. ## Adapted-By: jwe
  39.  
  40. function cmap = colormap (map)
  41.  
  42.   global __current_color_map__ = gray ();
  43.  
  44.   if (nargin > 1)
  45.     usage ("colormap (map)");
  46.   endif
  47.  
  48.   if (nargin == 1)
  49.     if (isstr (map))
  50.       if (strcmp (map, "default"))
  51.         __current_color_map__ = gray ();
  52.       else
  53.         error ("invalid argument");
  54.       endif
  55.     else
  56.       ## Set the new color map
  57.       __current_color_map__ = map;
  58.     endif
  59.   endif
  60.  
  61.   ## Return current color map.
  62.  
  63.   cmap = __current_color_map__;
  64.  
  65. endfunction
  66.