From: Luis Gracia (lug2002_at_med.cornell.edu)
Date: Wed Sep 29 2004 - 15:11:24 CDT

Hi!

I haven't been following this thread from the beginning, until I just
realized that some time ago I actually had a color problem in one of my
plugins. In this case I needed to map vmd colors to rgb, so that
different items in a TK listbox had the same colors as they
corresponding vmd objects (graphical representations in this case). I
wrote this function, if it helps in any way:

------------
# Convert a VMD color index to rgb
proc index2rgb {i} {
   set len 2
   lassign [colorinfo rgb $i] r g b
   set r [expr int($r*255)]
   set g [expr int($g*255)]
   set b [expr int($b*255)]
   #puts "$i $r $g $b"
   return [format "#%.${len}X%.${len}X%.${len}X" $r $g $b]
}
------------

Best,

Luis

John Stone said the following on 09/29/04 10:55:
> Konrad,
>
> On Wed, Sep 29, 2004 at 10:45:18AM +0200, hinsen_at_llb.saclay.cea.fr wrote:
>
>>On 28.09.2004, at 19:31, John Stone wrote:
>>
>>> We removed the particular RGB-color commands used in the past in
>>>favor of consistency with the rest of VMD, using the indexed color
>>>scales.
>>
>>Consistency is fine, but at the price of removing features...
>
>
> Well, I should probably explain more but I didn't think it would
> interest you when I first replied. :)
>
> Basically, by eliminating that feature, we could
> completely rewrite the low-level graphics code in VMD, eliminating
> several things that were responsible for lowering the graphics performance
> substantially. In the process of doing this, we eliminated all of the
> code that used RGB triplets rather than indexed colors. The only code
> that remained that had been exposed as a feature to the user's was the
> "draw color r g b", and so I decided that unless we found significant
> scripts that used this feature, it would be deleted. Thus far only two
> people (you're the second) have noticed in the last several years since
> the change was made, so it seems to have been a reasonable decision.
> In the intervening years, all of the users of the current versions of
> the program have benefited from the various performance improvements that
> were the direct result of these changes.
>
> We do make test versions of VMD available so that people can try them
> out before they are finalized. Since nobody complained back in 2001
> when that change was made, we've long-since moved on and forgotten about it.
>
>
>>>If you want to assign specific colors, this can still be done by
>>>modifying
>>>the color scale via a script and assigning the appropriate color index.
>>
>>The problem with that is that there is a fixed and small number of
>>colors available. It is not uncommon in my applications to have
>>hundreds of different colors (e.g. placing arrows on a grid covering a
>>protein, with the color of the arrow indicating the value of some
>>property).
>
>
> The VMD color scale has 1024 entries, so it should be relatively easy
> to map your colors within that range.
>
>
>>Moreover, the indexed colors are global. If I generate two scripts that
>>use colors, I can't load both without the second destroying the colors
>>of the first.
>
>
> True, but a better way to do it is to only add colors which are "different
> enough" to justify having their own index, rather than blindly adding them
> all. This is one of the reasons we chose to eliminate the user-accessible
> methods for directly altering RGB colors. If you like, I can provide
> you with an example of how to do this type of thing.
>
> By minimizing various OpenGL state changes, VMD can render various
> things significantly faster than was possible when unindexed RGB colors
> were allowed to be used. This also allowed us to make several of the
> external renderer modules produce more efficient scenes, and reduce
> rendering times. This is definitely a trade-off between
> flexibility and speed. Since our users tend to work with very large
> molecular structures, we chose to enhance the speed, for better or for worse.
>
> If you can show me the types of things you've been using the RGB
> colors for, I can help you solve your problems or come up with an
> another solution for this for the next version of the program.
>
> John
>

-- 
Luis Gracia, PhD
Department of Physiology & Biophysics
Weill Medical College of Cornell University
1300 York Avenue, Box 75
New York, NY 10021
Tel: (212) 746-6375
Fax: (212) 746-6226
lug2002_at_med.cornell.edu