Hi Mick, Thanks for your mail and fixes. Here is the slightly modified version of original rgb_colors GO file, which reads the necessary informations from an ASCII input file rgb_colors_custom.dat. So, those who have problems with "showrgb" command can use this version, instead of the original one. The new GO file (rgb_colors_custom.jnl) uses Ferret commands Fdata to locate the path to the input ASCII file. The input file can be placed in cwd or in any of the directories accessed by Fdata command (ferret/fer_dets/data, ferret/go, ferret/examples, ferret/contrib). Moreover, the ferret/bin directory should be there in the executable search path defined by files like .cshrc, /etc/csh.csrc etc in order to access Ferret commands Fdata and Fenv. GO file (rgb_colors_custom.jnl) and gzipped ASCII input file (rgb_colors_custom.dat.gz) are attached. For examples and details see the header part of GO file and this mail : http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2006/msg00725.html Mick, i have mentioned about your fixes in this new GO file. Thanks & Regards, Jaison On Mon, 20 Nov 2006, mick spillane wrote: > Hi Jaison, > > What a great utility -- especially to someone like me who has a bit > of trouble with colors and > palettes. It may be that I don't understand it completely yet, but I > had to set an alias > > alias showrgb '/usr/X11R6/bin/showrgb /usr/X11R6/lib/X11/rgb' > > on one machine and on my Mac > > alias showrgb '/usr/X11R6/bin/showrgb /usr/X11R6/lib/X11/rgb.txt' > > to get rgb_colors to brighten my day. > > Congratulations and thanks, > Mick > ---------------------- > Jaison Kurian wrote: > > Hi All, > > If you want have a fancy color for your line plot or label in > > Ferret, always you have to search for its RGB values and then define a > > new "ppl color". I wrote one GO file (rgb_colors.jnl) to make this > > process easy. Its usage is similar to "ppl color" but instead of last > > 3 arguments you can use a color name (sounds interesting ?) : > > > > For maroon color, the "ppl color" usage is like > > > > yes? ppl color 5, 0.6902,0.1882,0.3765 > > > > With the new GO file rgb_colors, it is as simple as > > > > yes? go rgb_colors 5, "maroon" > > > > Color name should be in double quotes and there is absolutely no problem > > with blank spaces or case (ie. "medium violet red", " Sandy Brown " are > > just fine). One constraint is that the command "showrgb" should be > > available on your computer. Also the grep command should support the -w > > argument. Other details are given in the header part of the go file (see > > the attachment). Few examples are given below. Hope this will be useful... > > > > Let us make Ferret more colorful !!!! > > > > Regards, > > > > Jaison > > > > set mode/last verify > > >
\ cancel mode verify ! ! Description: To define RGB Ferret/PPL colors, based on ASCII file rgb_colors_custom.dat ! ------------ ! ! IMPORTANT : rgb_colors_custom.dat should be present in cwd or in any of the ! directories accessed by Fdata command (ferret/fer_dets/data, ! ferret/go, ferret/examples, ferret/contrib) ! ! RGB colors specified in the ASCII file rgb_colors_custom.dat is used to create ! fancy line/label colors in Ferret. This jnl file and associated ! rgb_colors_custom.dat is meant for those who have problems with accessing ! "showrgb" command on their computer. If this command is working perfectly, ! use original rgb_colors.jnl available at ! ! http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2006/msg00725.html ! ! Also have a look at the fix suggested by Mick Spillane ! ! http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2006/msg00732.html ! !To see the color names and colors, have a look at... ! ! 1. http://www.math.utah.edu/faq/color/rgb-chart.pdf ! 2. http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ! ! Arguments : (all are optional) ! --------- ! $1 : Ferret color number; should be between 1 & 6 ; default is 5 ! $2 : RGB Color Name, in double quotes : "" ; case insensitive ; ! trailing/preceeding blank characters are fine provided ! the color exists. ! use showrgb or sites mentioned above for color names. ! ! Usage : ! --------- ! GO rgb_colors_custom [ferret_color_number] [rgb color name] ! ! Examples ! -------- ! 1. go rgb_colors_custom ! without any arguments 5 will be defined as SALMON ! plot/color=5 SIN(i[i=1:100]/10) ! ! 2. go rgb_colors_custom 5, "dark red" ; plot/color=11 SIN(i[i=1:100]/10) ! ! 3. go rgb_colors_custom 5, "Pale Violet Red" ; plot/color=5 SIN(i[i=1:100]/10) ! ! Notes : Default Ferret color can be restored by calling rgb_colors_custom again ! ------ with proper color_number and color_name. ! Machine should have the command "grep" (with options like -w and [[:space:]]] ! To know more about Ferret line/label colors have a look at the user manual, ! Ch6 Sec5.1.2. PPLUS text and line color commands & ! Appendix C Sec2.3 COLOR n, red, green, blue ! This script uses the following Ferret commands : Fdata, Fenv & hence ! the ferret/bin directory should be there in your executable search path ! set up by files like .cshrc, /etc/csh.csrc etc. ! Internal variables have the prefix "rlc_" --> rgb_line/label_color_ ! !----------------------------------------------------------------------------- ! Created By : Jaison Kurian (jaison@caos.iisc.ernet.in) ! Created On : 18/Nov/2006 ! ! Modifications : ! ! 1. 21/Nov/2006 : This version (rgb_colors_custom.jnl) reads the RGB values ! from an ASCII file (rgb_colors_custom.dat) instead of ! using showrgb command (as in rgb_colors.jnl). ! ! Modifications Planned : ! ! 1. Try to replace grep command with more reputed one like awk. ! !-------------------------------------------------------------------------------- ! set the input parameters define symbol rlc_numb = $1"5" ! Ferret Color Number define symbol rlc_name = $2"salmon" ! RGB Color Name ! do a check for specified color number IF `($rlc_numb) LT 1 OR ($rlc_numb) GT 6` THEN say say " ERROR (rgb_colors_custom) : 1st Argument (Ferret color No.) should be in the range 1-6." say ; EXIT/SCRIPT ENDIF ! check whether rgb_colors_custom.dat file exists in any Ferret Dir ! it is assumed that the path starts at 20th character of Fdata output ! and the last character is not a "/" let rlc_path_all = {spawn:"Fdata rgb_colors_custom.dat"} let rlc_exist = SUBSTRING(rlc_path_all[i=1],1,17) IF `rlc_exist EQ "No files matching"` THEN say say " ERROR (rgb_colors_custom) : Could NOT locate input ASCII file rgb_colors_custom.dat" say " in any of the following directories" sp Fenv | grep FER_DATA ; say say " Default color will be used." ; say ; EXIT/SCRIPT ENDIF let rlc_path_len = STRLEN(rlc_path_all[i=1]) let rlc_path = SUBSTRING(rlc_path_all[i=1],20,`rlc_path_len-19`) let rlc_data = rlc_path + "/rgb_colors_custom.dat" ! check whether the defined color exists, if not exit from current script define symbol rlc_color = `{spawn:"echo ($rlc_name) | sed 's/ //g'"}` let rlc_all = {spawn:"grep -i -w '[[:space:]]($rlc_color)' `rlc_data`"} let rlc_ok = STRLEN(rlc_all[i=1]) IF `rlc_ok LE 0` THEN say say " SORRY (rgb_colors_custom) : Requested color ($rlc_name) does NOT exist." say " The DEFAULT Ferret color will be used." say EXIT/SCRIPT ENDIF let rlc_all_x = XSEQUENCE(rlc_all) let rlc_ncols = SUBSTRING(rlc_all_x,12,100) let rlc_ncol = `rlc_all_x,r=iend` IF `rlc_ncol GT 1` THEN say ; say " WARNING (rgb_colors_custom) : More than 1 color found. Using the 1st one." say " `rlc_ncols[i=1]`" ; say ENDIF ! If color exists, convert RGB values to %, as required by Ferret. let rlc_r = SUBSTRING(rlc_all_x[i=1],1,3) let rlc_g = SUBSTRING(rlc_all_x[i=1],5,3) let rlc_b = SUBSTRING(rlc_all_x[i=1],9,3) let rlc_red = (`rlc_r`/255) * 100 let rlc_green = (`rlc_g`/255) * 100 let rlc_blue = (`rlc_b`/255) * 100 ! Define requested color, using the specified color number ppl color `($rlc_numb)`, `rlc_red`, `rlc_green`, `rlc_blue` ! clean up cancel symbol rlc_* ; cancel var rlc_* set mode/last verify
Attachment:
rgb_colors_custom.dat.gz
Description: GNU Zip compressed data