home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / COLOR.DI$ / SPINMAP.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  977 b   |  40 lines

  1. function spinmap(time,inc)
  2. %SPINMAP Spin the colormap.
  3. %    SPINMAP cyclically rotates the color map for about 3 seconds.
  4. %    SPINMAP(T) rotates it for about T seconds.
  5. %    SPINMAP(inf) is an infinite loop, break with <ctrl-C>.
  6. %    SPINMAP(T,inc) uses the specified increment.  The default is
  7. %    inc = 2, so inc = 1 is a slower rotation, inc = 3 is faster,
  8. %    inc = -2 is the other direction, etc.
  9. %
  10. %    To avoid multiple redraws, set(gcf,'sharecolors','no').
  11. %
  12. %    See also COLORMAP, RGBPLOT.
  13.  
  14. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  15.  
  16. if nargin < 1, time = 3; end
  17. if nargin < 2, inc = 2; end
  18.  
  19. cm = colormap;
  20. M = cm;
  21.  
  22. sh = get(gcf,'sharecolors');
  23. set(gcf,'sharecolors','no')
  24. drawnow
  25.  
  26. % Generate the rotated index vector; allow for negative inc.
  27. m = size(M,1);
  28. k = rem((m:2*m-1)+inc,m) + 1;
  29.  
  30. % Use while loop because time might be inf.
  31. t = 0;
  32. while t < 27*time
  33.    M = M(k,:);
  34.    colormap(M)
  35.    t = t+1;
  36. end
  37.  
  38. colormap(cm)
  39. set(gcf,'sharecolors',sh)
  40.