home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 3.ddi / DEMOS.DI$ / COLORMEN.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.9 KB  |  40 lines

  1. %COLORMENU Add a color map menu to the current figure.
  2. %    Each of the menu choices operates on the colormap:
  3. %    HOT, PINK, COOL, BONE, JET, COPPER, FLAG and PRISM are names of
  4. %    functions which generate color maps.
  5. %    RAND is a random color map.
  6. %    BRIGHTEN increases the brightness.
  7. %    DARKEN decreases the brightness.
  8. %    FLIPUD inverts the order of the colormap entries.
  9. %    FLIPLR interchanges the red and blue components.
  10. %    PERMUTE cyclic permuations: red -> blue, blue -> green, green -> red. 
  11. %    SPIN spins the colormap, which is a rapid sequence of FLIPUD's.
  12. %    REMEMBER pushes a copy of the current color map onto a stack.
  13. %    RESTORE pops a map from the stack (initially, the stack contains the
  14. %       map in use when COLORMENU was invoked.)
  15.  
  16.  
  17. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  18.  
  19. stackofmaps = colormap;
  20. lengthofmap = size(stackofmaps,1);
  21. maps = str2mat('hsv','hot','pink','cool','bone','jet','copper','flag','prism');
  22. colormenuh = uimenu(gcf,'label','colormaps');
  23. for k = 1:size(maps,1);
  24.    uimenu(colormenuh,'label',maps(k,:),'callback',['colormap(' maps(k,:) ');']);
  25. end
  26. uimenu(colormenuh,'label','rand', 'callback','colormap(rand(lengthofmap,3))');
  27. uimenu(colormenuh,'label','brighten','callback','brighten(.25)');
  28. uimenu(colormenuh,'label','darken','callback','brighten(-.25)');
  29. uimenu(colormenuh,'label','flipud','callback','colormap(flipud(colormap))');
  30. uimenu(colormenuh,'label','fliplr','callback','colormap(fliplr(colormap))');
  31. uimenu(colormenuh,'label','permute', ...
  32.    'callback','c = colormap; colormap(c(:,[2 3 1]))');
  33. uimenu(colormenuh,'label','spin','callback','spinmap');
  34. uimenu(colormenuh,'label','help','callback','help colormenu');
  35. uimenu(colormenuh,'label','remember', ...
  36.    'callback','stackofmaps = [colormap; stackofmaps];');
  37. uimenu(colormenuh,'label','restore', ...
  38.    'callback',['colormap(stackofmaps(1:lengthofmap,:));' ...
  39.    'if size(stackofmaps,1)>lengthofmap,stackofmaps(1:lengthofmap,:)=[]; end']);
  40.