I am trying to use ngl to create a visualization for a webserver. Is there a way to color by b-factor and set the color spectrum. For example, everything below a b-factor below 0.2 is blue, .2 to .8 is green, and .8 to 1 is red?
Thanks!
It is possible with a custom ColorMaker, try this:
var myScheme = NGL.ColorMakerRegistry.addScheme( function( params ){
this.atomColor = function( atom ){
if( atom.bfactor < 0.2 ){
return 0x0000FF; // blue
if( atom.bfactor > 0.8 ){
return 0xFF0000; // red
}else{
return 0x00FF00; // green
}
};
} );
// apply colorscheme to an existing representation
repr.setParameters( { color: myScheme } );
// set colorscheme when creating a new representation
component.addRepresentation( "cartoon", { color: myScheme } );
Also have a look at http://arose.github.io/ngl/doc/index.html#API_reference/Object/ColorMakerRegistry
I hope this helps. Please let me know if you further questions.
Most helpful comment
It is possible with a custom
ColorMaker, try this:Also have a look at http://arose.github.io/ngl/doc/index.html#API_reference/Object/ColorMakerRegistry
I hope this helps. Please let me know if you further questions.