UNPKG

molstar

Version:

A comprehensive macromolecular library.

45 lines 1.68 kB
import { isPositionLocation } from '../../mol-geo/util/location-iterator'; import { Vec3 } from '../../mol-math/linear-algebra'; import { ColorTheme } from '../../mol-theme/color'; import { ColorNames } from '../../mol-util/color/names'; export function CustomColorTheme(ctx, props) { var _a; var _b = (_a = ctx.structure) === null || _a === void 0 ? void 0 : _a.boundary.sphere, radius = _b.radius, center = _b.center; var radiusSq = Math.max(radius * radius, 0.001); var scale = ColorTheme.PaletteScale; return { factory: CustomColorTheme, granularity: 'vertex', color: function (location) { if (!isPositionLocation(location)) return ColorNames.black; var dist = Vec3.squaredDistance(location.position, center); var t = Math.min(dist / radiusSq, 1); return ((t * scale) | 0); }, palette: { filter: 'nearest', colors: [ ColorNames.red, ColorNames.pink, ColorNames.violet, ColorNames.orange, ColorNames.yellow, ColorNames.green, ColorNames.blue ] }, props: props, description: '', }; } export var CustomColorThemeProvider = { name: 'basic-wrapper-custom-color-theme', label: 'Custom Color Theme', category: "Miscellaneous" /* Misc */, factory: CustomColorTheme, getParams: function () { return ({}); }, defaultValues: {}, isApplicable: function (ctx) { return true; }, }; //# sourceMappingURL=custom-theme.js.map