NGL@1.0.0-beta.7 Home Manual Reference Source Gallery

src/color/entityindex-colormaker.js

  1. /**
  2. * @file Entityindex Colormaker
  3. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  4. * @private
  5. */
  6.  
  7. import { ColormakerRegistry } from '../globals.js'
  8. import Colormaker from './colormaker.js'
  9.  
  10. /**
  11. * Color by entiry index
  12. */
  13. class EntityindexColormaker extends Colormaker {
  14. constructor (params) {
  15. super(params)
  16.  
  17. if (!params.scale) {
  18. this.scale = 'Spectral'
  19. }
  20. if (!params.domain) {
  21. this.domain = [ 0, this.structure.entityList.length - 1 ]
  22. }
  23. var entityindexScale = this.getScale()
  24.  
  25. this.atomColor = function (a) {
  26. return entityindexScale(a.entityIndex)
  27. }
  28. }
  29. }
  30.  
  31. ColormakerRegistry.add('entityindex', EntityindexColormaker)
  32.  
  33. export default EntityindexColormaker