Ngl: Color Spectrum BGR by b-factor

Created on 12 Feb 2016  路  1Comment  路  Source: nglviewer/ngl

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!

question

Most helpful comment

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arose picture arose  路  6Comments

LivC182 picture LivC182  路  6Comments

sunhwan picture sunhwan  路  4Comments

fcharih picture fcharih  路  3Comments

garyo picture garyo  路  5Comments