Ignore:
Timestamp:
07/07/06 11:57:27 (18 years ago)
Author:
navarro
Message:

english and nicer header (1)

Location:
trunk/SRC/Colors
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Colors/getcolor.pro

    r132 r133  
    11;+ 
    2 ; NAME: 
    3 ;       GETCOLOR 
    4 ; 
    5 ; PURPOSE: 
    6 ;       The original purpose of this function was to enable the 
    7 ;       user to specify one of the 16 colors supported by the 
    8 ;       McIDAS color map by name. Over time, however, the function 
    9 ;       has become a general purpose function for handling and 
    10 ;       supporting drawing colors in a device-independent way. 
    11 ;       In particular, I have been looking for ways to write color 
    12 ;       handling code that will work transparently on both 8-bit and 
    13 ;       24-bit machines. On 24-bit machines, the code should work the 
    14 ;       same where color decomposition is turned on or off. 
     2; 
     3; @file_comments  
     4; The original purpose of this function was to enable the 
     5; user to specify one of the 16 colors supported by the 
     6; McIDAS color map by name. Over time, however, the function 
     7; has become a general purpose function for handling and 
     8; supporting drawing colors in a device-independent way. 
     9; In particular, I have been looking for ways to write color 
     10; handling code that will work transparently on both 8-bit and 
     11; 24-bit machines. On 24-bit machines, the code should work the 
     12; same where color decomposition is turned on or off. 
    1513; 
    1614;       (The 16 supported colors in GETCOLOR come from the McIDAS color 
    1715;       table offered on the IDL newsgroup by Liam Gumley.) 
    1816; 
    19 ; CATEGORY: 
    20 ;       Graphics, Color Specification. 
    21 ; 
    22 ; CALLING SEQUENCE: 
    23 ;       result = GETCOLOR(color) 
    24 ; 
    25 ; OPTIONAL INPUT PARAMETERS: 
    26 ;       COLOR: A string with the "name" of the color. Valid names are: 
     17; @categories Graphics, Color Specification. 
     18; 
     19; @param thisColor {in}{optional} A string with the "name" of the color. Valid names are: 
    2720;           black 
    2821;           magenta 
     
    5346;           IDL 5.2 or higher. 
    5447; 
    55 ;       INDEX: The color table index where the specified color should be loaded. 
     48; @param index {in}{optional} The color table index where the specified color should be loaded. 
    5649;           If this parameter is passed, then the return value of the function is the 
    5750;           index number and not the color triple. (If color decomposition is turned 
     
    6962;           TVLCT, colors, 100 
    7063; 
    71 ; 
    72 ; INPUT KEYWORD PARAMETERS: 
    73 ; 
    74 ;       NAMES: If this keyword is set, the return value of the function is 
     64; @keyword NAMES If this keyword is set, the return value of the function is 
    7565;              a 16-element string array containing the names of the colors. 
    7666;              These names would be appropriate, for example, in building 
     
    8070;                 listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 
    8171; 
    82 ;       LOAD:  If this keyword is set, all 16 colors are automatically loaded 
     72; @keyword LOAD  If this keyword is set, all 16 colors are automatically loaded 
    8373;              starting at the color index specified by the START keyword. 
    8474;              Note that setting this keyword means that the return value of the 
     
    9282;              byte array or a long integer value. 
    9383; 
    94 ;       START: The starting color index number if the LOAD keyword is set. This keyword 
     84; @keyword START The starting color index number if the LOAD keyword is set. This keyword 
    9585;              value is ignored unless the LOAD keyword is also set. The keyword is also 
    9686;              ignored if the TRUE keyword is set or if color decomposition in on in 
     
    9888;              !D.TABLE_SIZE - 17. 
    9989; 
    100 ;       TRUE:  If this keyword is set, the specified color triple is returned 
     90; @keyword TRUE  If this keyword is set, the specified color triple is returned 
    10191;              as a 24-bit integer equivalent. The lowest 8 bits correspond to 
    10292;              the red value; the middle 8 bits to the green value; and the 
     
    10595;              were set. 
    10696; 
    107 ; COMMON BLOCKS: 
    108 ;       None. 
    109 ; 
    110 ; SIDE EFFECTS: 
    111 ;       None. 
    112 ; 
    113 ; RESTRICTIONS: 
    114 ;       The TRUE keyword causes the START keyword to be ignored. 
     97; @restrictions The TRUE keyword causes the START keyword to be ignored. 
    11598;       The NAMES keyword causes the COLOR, INDEX, START, and TRUE parameters to be ignored. 
    11699;       The COLOR parameter is ignored if the LOAD keyword is used. 
     
    119102;       returned if color decomposition is ON. 
    120103; 
    121 ; EXAMPLE: 
    122 ;       To load a yellow color in color index 100 and plot in yellow, type: 
    123 ; 
    124 ;          yellow = GETCOLOR('yellow', 100) 
    125 ;          PLOT, data, COLOR=yellow 
     104;  
     105; @examples To load a yellow color in color index 100 and plot in yellow, type: 
     106; 
     107;          IDL> yellow = GETCOLOR('yellow', 100) 
     108;          IDL> PLOT, data, COLOR=yellow 
    126109; 
    127110;       or, 
    128111; 
    129 ;          PLOT, data, COLOR=GETCOLOR('yellow', 100) 
     112;          IDL> PLOT, data, COLOR=GETCOLOR('yellow', 100) 
    130113; 
    131114;       To do the same thing on a 24-bit color system with decomposed color on, type: 
    132115; 
    133 ;          PLOT, data, COLOR=GETCOLOR('yellow', /TRUE) 
     116;          IDL> PLOT, data, COLOR=GETCOLOR('yellow', /TRUE) 
    134117; 
    135118;       or in IDL 5.2 and higher, 
    136119; 
    137 ;          DEVICE, Decomposed=1 
    138 ;          PLOT, data, COLOR=GETCOLOR('yellow') 
     120;          IDL> DEVICE, Decomposed=1 
     121;          IDL> PLOT, data, COLOR=GETCOLOR('yellow') 
    139122; 
    140123;       To load all 16 colors into the current color table, starting at 
    141124;       color index 200, type: 
    142125; 
    143 ;          TVLCT, GETCOLOR(), 200 
     126;          IDL> TVLCT, GETCOLOR(), 200 
    144127; 
    145128;       To add the color names to a list widget: 
    146129; 
    147 ;           listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 
     130;           IDL> listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 
    148131; 
    149132;       To load all 16 colors and have the color indices returned in a structure: 
    150133; 
    151 ;           DEVICE, Decomposed=0 
    152 ;           colors = GetColor(/Load, Start=1) 
    153 ;           HELP, colors, /Structure 
     134;           IDL> DEVICE, Decomposed=0 
     135;           IDL> colors = GetColor(/Load, Start=1) 
     136;           IDL> HELP, colors, /Structure 
    154137;           PLOT, data, COLOR=colors.yellow 
    155138; 
    156139;       To get the direct color values as 24-bit integers in color structure fields: 
    157140; 
    158 ;           DEVICE, Decomposed=1 
    159 ;           colors = GetColor(/Load) 
    160 ;           PLOT, data, COLOR=colors.yellow 
     141;           IDL> DEVICE, Decomposed=1 
     142;           IDL> colors = GetColor(/Load) 
     143;           IDL> PLOT, data, COLOR=colors.yellow 
    161144; 
    162145;       Note that the START keyword value is ignored if on a 24-bit device, 
     
    164147;       writing code like this: 
    165148; 
    166 ;           colors = GetColor(/Load) 
    167 ;           PLOT, data, Color=colors.yellow 
    168 ; 
    169 ; MODIFICATION HISTORY: 
    170 ;       Written by: David Fanning, 10 February 96. 
     149;           IDL> colors = GetColor(/Load) 
     150;           IDL> PLOT, data, Color=colors.yellow;           IDL> DEVICE, Decomposed=0 
     151;           IDL> colors = GetColor(/Load, Start=1) 
     152;           IDL> HELP, colors, /Structure 
     153;           PLOT, data, COLOR=colors.yellow 
     154; 
     155;       To get the direct color values as 24-bit integers in color structure fields: 
     156; 
     157;           IDL> DEVICE, Decomposed=1 
     158;           IDL> colors = GetColor(/Load) 
     159;           IDL> PLOT, data, COLOR=colors.yellow 
     160; 
     161;       Note that the START keyword value is ignored if on a 24-bit device, 
     162;       so it is possible to write completely device-independent code by 
     163;       writing code like this: 
     164; 
     165;           IDL> colors = GetColor(/Load) 
     166;           IDL> PLOT, data, Color=colors.yellow 
     167; 
     168; @history Written by: David Fanning, 10 February 96. 
    171169;       Fixed a bug in which N_ELEMENTS was spelled wrong. 7 Dec 96. DWF 
    172170;       Added the McIDAS colors to the program. 24 Feb 99. DWF 
     
    176174;       Added automatic recognition of DECOMPOSED=1 state. 7 June 99. DWF 
    177175;       Added LOAD AND START keywords. 7 June 99. DWF. 
     176; 
     177; @version $Id$ 
    178178;- 
    179  
    180  
    181  
    182 FUNCTION COLOR24, number 
    183 ; 
    184   compile_opt idl2, strictarrsubs 
    185 ; 
    186  
    187    ; This FUNCTION accepts a [red, green, blue] triple that 
    188    ; describes a particular color and returns a 24-bit long 
    189    ; integer that is equivalent to that color. The color is 
    190    ; described in terms of a hexidecimal number (e.g., FF206A) 
    191    ; where the left two digits represent the blue color, the 
    192    ; middle two digits represent the green color, and the right 
    193    ; two digits represent the red color. 
    194    ; 
    195    ; The triple can be either a row or column vector of 3 elements. 
    196  
    197 ON_ERROR, 1 
    198  
    199 IF N_ELEMENTS(number) NE 3 THEN $ 
    200    MESSAGE, 'Augument must be a three-element vector.' 
    201  
    202 IF MAX(number) GT 255 OR MIN(number) LT 0 THEN $ 
    203    MESSAGE, 'Argument values must be in range of 0-255' 
    204  
    205 base16 = [[1L, 16L], [256L, 4096L], [65536L, 1048576L]] 
    206  
    207 num24bit = 0L 
    208  
    209 FOR j=0,2 DO num24bit = num24bit + ((number[j] MOD 16) * base16[0,j]) + $ 
    210    (Fix(number[j]/16) * base16[1,j]) 
    211  
    212 RETURN, num24bit 
    213 END ; ************************  of COLOR24  ****************************** 
    214  
    215  
    216179 
    217180FUNCTION GETCOLOR, thisColor, index, TRUE=truecolor, $ 
Note: See TracChangeset for help on using the changeset viewer.