there you go!! Great.

On Fri, Nov 19, 2010 at 8:24 AM, Rolf Huehne <rhue...@fli-leibniz.de> wrote:

> On 11/18/2010 05:06 PM, Robert Hanson wrote:
> > Whenever you have the situation where a variable xxx won't work in a
> command
> > as @xxx (because Jmol is looking for a command argument keyword, not a
> > string), just use the script INLINE method:
> >
> > Var type = "bonds"
> > Var chain_color = "x447BD4"
> >
> > script INLINE @{"color " + type + " [" + chain_color + "]"}
> >
> > That way the command is constructed first, then compiled as any other
> > command.
> >
> Taking up this tip I streamlined the function (see below) and added the
> possibility to provide any color scheme as a parameter to the function.
> And it is no longer necessary to provide an empty type ("") if no custom
> color scheme is provided because it is the default now.
>
> The color scheme must be a comma-separated list of hexadecimal color
> values.
>
> Examples:
>
> color_scheme = "ff0000,00ff00,0000ff";
> color_by_chain("", color_scheme);
> color_by_chain("cartoon", color_scheme);
> color_by_chain();
> color_by_chain("cartoon");
> color_by_chain("", "ff0000,00ff00,0000ff");
>
> Regards,
> Rolf
>
> ==========================================================
> function color_by_chain(type, custom_color_list) {
>   var chain_list  = script("show chain").trim().lines;
>  var chain_count = chain_list.length;
>
>   var type_list  =
>
> array("backbone","cartoon","dots","halo","label","meshribbon","polyhedra","rocket","star","strand","strut","trace");
>
>  var color_list =
>
> array("104BA9","AA00A2","C9F600","FFA200","284A7E","7F207B","9FB82E","BF8B30","052D6E","6E0069","83A000","A66A00","447BD4","D435CD","D8FA3F","FFBA40","6A93D4","D460CF","E1FA71","FFCC73");
>
>  if (custom_color_list) {
>    color_list = custom_color_list.split(",").trim();
>   }
>
>  var color_count = color_list.length;
>
>   if (type) {
>    # type parameter was provided, use it
>  } else {
>    # set all types dependent on 'atom' as default
>    type = "";
>  }
>
>  define current_selection selected;
>
>  for (var chain_number=1; chain_number<=chain_count; chain_number++) {
>    var color_index   = chain_number % color_count;
>    var chain_color   = color_list[color_index];
>     var color_command = "";
>
>    var selection_expression = "current_selection and :" +
> chain_list[chain_number];
>    select @selection_expression;
>
>    if (type == "") {
>       color_command = "color atom [x" + chain_color + "]; color " +
> type_list.join(" none; color ") + " none;";
>
>    } else {
>      color_command = "color " + type + " [x" + chain_color + "]";
>    }
>
>    script INLINE @{color_command}
>   }
>
>  select current_selection;
> }
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to