#======================================================================= # Rainbow scale color map (going from violet to red, 390-680 nm, in # going from color index 16 to 239). # # This routine requires the module wavelen2rgb which converts # visible wavelength in nm to RGB triples. The code can be found # here: http://www.johnny-lin.com/py_code/wavelen2rgb.py. # # Copyright (c) 2003 by Johnny Lin. For licensing, distribution # conditions, contact information, and additional documentation see # the URL http://www.johnny-lin.com/pylib.html#license. #======================================================================= #- Import modules and open VCS canvas: import vcs from wavelen2rgb import wavelen2rgb v = vcs.init() #- Copy the default color map to create my own color map "my_cmap": my_cmap = v.createcolormap('my_cmap', 'default') #- Make a list of evenly spaced wavelengths from 390-680 nm: wavelengths = vcs.mkevenlevels(390,680,240-16-1) #- Compute RGB values and fill the my_cmap.index dictionary for # color indices 16 to 239: for i in range(16,240): my_cmap.index[i] = wavelen2rgb(wavelengths[i-16]) #- Set my color map to the active color map: v.setcolormap('my_cmap') #====== end of file ======