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

src/color/value-colormaker.js

  1. /**
  2. * @file Value 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 volume value
  12. */
  13. class ValueColormaker extends Colormaker {
  14. constructor (params) {
  15. super(params)
  16. this.valueScale = this.getScale()
  17. }
  18.  
  19. /**
  20. * return the color for a volume cell
  21. * @param {Integer} index - volume cell index
  22. * @return {Integer} hex cell color
  23. */
  24. volumeColor (index) {
  25. return this.valueScale(this.volume.data[ index ])
  26. }
  27. }
  28.  
  29. ColormakerRegistry.add('value', ValueColormaker)
  30.  
  31. export default ValueColormaker