shape-group.ts 800 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { ColorTheme, ColorThemeProps } from '../color';
  7. import { Color } from 'mol-util/color';
  8. import { Location } from 'mol-model/location';
  9. import { Shape } from 'mol-model/shape';
  10. const DefaultColor = Color(0xCCCCCC)
  11. export function ShapeGroupColorTheme(props: ColorThemeProps): ColorTheme {
  12. return {
  13. granularity: 'group',
  14. color: (location: Location): Color => {
  15. if (Shape.isLocation(location)) {
  16. return location.shape.colors.ref.value[location.group]
  17. }
  18. return DefaultColor
  19. },
  20. description: props.description,
  21. legend: props.legend
  22. }
  23. }