source: trunk/SRC/Colors/lct.pro @ 134

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
RevLine 
[2]1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
[133]6; @file_comments
7; Fastest than type loadct,file='palette.tbl'
[2]8;
[133]9; @categories graphics, color specification
[2]10;
[133]11; @param numpal {in}{optional} number of the color palette we want to select in the file palette.tbl
[2]12;
[133]13; @keyword LIGHTNESS a scalar used to change the Lightness of the color
[19]14;            palette to be abble to adjust according to the printer we use,
15;            the media (paper or slide)...
16;               lightness < 1 to get lighter colors
17;                         > 1 to get darker colors
18;
[133]19; @keyword FILE {default=palette.tbl} is not specified, we are looking  a file containing
20; palettes named palette.tbl.
21; This file can be in any directory of the !path
[2]22;
[133]23; @keyword GET_NAME Set this keyword to a named variable in which the names of the color tables
24;          are reurned as a string array. No changes are made to the color table.
25;
26; @keyword _EXTRA Used to pass your keywords
27;
28; @history Sebastien Masson (smasson@lodyc.jussieu.fr)
29;          30/3/1999: add extra
30;          6/7/1999: mac/windows comptibility
31;
32; @version $Id$
33;
[2]34;-
35;------------------------------------------------------------
36;------------------------------------------------------------
37;------------------------------------------------------------
[133]38PRO lct, numpal, FILE = file, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex
[114]39;
40  compile_opt idl2, strictarrsubs
41;
[2]42@common
[133]43; definition of the name of the file containing colors palettes.
44   if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl'
45; What is the full adress of nametbl?
[2]46   thisOS = strupcase(strmid(!version.os_family, 0, 3))
47   CASE thisOS of
48   'MAC':BEGIN & sep = ':' & pathsep = ',' & end
49   'WIN':BEGIN & sep = '\' & pathsep = ';' & end
50   ELSE: BEGIN & sep = '/' & pathsep = ':' & end
51   ENDCASE
52   cd, current = current
[133]53   if strpos(nametbl,sep) lt 0 then BEGIN
[2]54      if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep
55      multipath = str_sep(!path,pathsep)
56      for i = 0, n_elements(multipath)-1 do $
57       if rstrpos(multipath[i],sep) NE strlen(multipath[i])-1 then $
58       multipath[i] = multipath[i] +sep
[133]59      nametbl = [current, multipath]+ nametbl
[2]60   ENDIF
[133]61; we test all possible name in order to find where file is.
62   nfile=n_elements(nametbl)
[2]63   n = 0
64   repeat begin
[133]65      res = findfile(nametbl[n])
[2]66      n = n+1
[133]67   endrep until res[0] NE '' OR n EQ n_elements(nametbl)
[2]68   if res[0] NE '' then BEGIN
[133]69      nametbl = nametbl[n-1]
[2]70      if n_elements(ex) NE 0 then $
[133]71        if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl
72; if we are in POSTSCRIPT mode, we have to pass in X mode in order to change the color palette
[2]73      oldname = !d.name
74      if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN
75         thisOS = !VERSION.OS_FAMILY
76         thisOS = STRMID(thisOS, 0, 3)
77         thisOS = STRUPCASE(thisOS)
78         CASE thisOS of
79            'MAC': SET_PLOT, thisOS
80            'WIN': SET_PLOT, thisOS
81            ELSE: SET_PLOT, 'X'
82         ENDCASE
83         !p.BACKGROUND=(!d.n_colors-1) < 255
84         !p.color=0
85         if !d.n_colors gt 256 then !p.background='ffffff'x
86      ENDIF
87;
88      if arg_present(get_name) then begin
[133]89         if n_elements(numpal) EQ 0 then loadct, file=nametbl, GET_NAME = get_name, _EXTRA = ex $
90         ELSE loadct,numpal, file=nametbl, /silent, GET_NAME = get_name,_EXTRA = ex
[2]91      ENDIF ELSE BEGIN
[133]92         if n_elements(numpal) EQ 0 then loadct, file=nametbl, _EXTRA = ex $
93         ELSE loadct,numpal, file=nametbl, /silent, _EXTRA = ex
[2]94      ENDELSE
95;
[19]96      if oldname EQ 'PS' AND keyword_set(lightness) then palit, lightness
97;
[2]98      set_plot, oldname
99      IF oldname EQ 'X' OR oldname EQ 'MAC' OR oldname EQ 'WIN' then BEGIN
100         !p.BACKGROUND=(!d.n_colors-1) < 255
101         !p.color=0
102         if !d.n_colors gt 256 then !p.background='ffffff'x
103      ENDIF
104
105   ENDIF ELSE ras = report('le fichier de palettes demande n''existe pas...')
106
107   return
108end
Note: See TracBrowser for help on using the repository browser.