UNPKG

molstar

Version:

A comprehensive macromolecular library.

54 lines 2.57 kB
/** * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { __assign } from "tslib"; import { Color } from '../../mol-util/color'; import { StructureElement, Unit, Bond } from '../../mol-model/structure'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ChainIdColorTheme, ChainIdColorThemeParams } from './chain-id'; var DefaultIllustrativeColor = Color(0xEEEEEE); var Description = "Assigns an illustrative color that gives every chain a unique color with lighter carbons (inspired by David Goodsell's Molecule of the Month style)."; export var IllustrativeColorThemeParams = __assign({}, ChainIdColorThemeParams); export function getIllustrativeColorThemeParams(ctx) { return IllustrativeColorThemeParams; // TODO return copy } export function IllustrativeColorTheme(ctx, props) { var _a = ChainIdColorTheme(ctx, props), chainIdColor = _a.color, legend = _a.legend; function illustrativeColor(location, typeSymbol) { var baseColor = chainIdColor(location, false); return typeSymbol === 'C' ? Color.lighten(baseColor, 0.8) : baseColor; } function color(location) { if (StructureElement.Location.is(location) && Unit.isAtomic(location.unit)) { var typeSymbol = location.unit.model.atomicHierarchy.atoms.type_symbol.value(location.element); return illustrativeColor(location, typeSymbol); } else if (Bond.isLocation(location) && Unit.isAtomic(location.aUnit)) { var elementIndex = location.aUnit.elements[location.aIndex]; var typeSymbol = location.aUnit.model.atomicHierarchy.atoms.type_symbol.value(elementIndex); return illustrativeColor(location, typeSymbol); } return DefaultIllustrativeColor; } return { factory: IllustrativeColorTheme, granularity: 'group', preferSmoothing: true, color: color, props: props, description: Description, legend: legend }; } export var IllustrativeColorThemeProvider = { name: 'illustrative', label: 'Illustrative', category: "Miscellaneous" /* Misc */, factory: IllustrativeColorTheme, getParams: getIllustrativeColorThemeParams, defaultValues: PD.getDefaultValues(IllustrativeColorThemeParams), isApplicable: function (ctx) { return !!ctx.structure; } }; //# sourceMappingURL=illustrative.js.map