UNPKG

molstar

Version:

A comprehensive macromolecular library.

49 lines (48 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomColorThemeProvider = exports.CustomColorTheme = void 0; var location_iterator_1 = require("../../mol-geo/util/location-iterator"); var linear_algebra_1 = require("../../mol-math/linear-algebra"); var color_1 = require("../../mol-theme/color"); var names_1 = require("../../mol-util/color/names"); 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 = color_1.ColorTheme.PaletteScale; return { factory: CustomColorTheme, granularity: 'vertex', color: function (location) { if (!(0, location_iterator_1.isPositionLocation)(location)) return names_1.ColorNames.black; var dist = linear_algebra_1.Vec3.squaredDistance(location.position, center); var t = Math.min(dist / radiusSq, 1); return ((t * scale) | 0); }, palette: { filter: 'nearest', colors: [ names_1.ColorNames.red, names_1.ColorNames.pink, names_1.ColorNames.violet, names_1.ColorNames.orange, names_1.ColorNames.yellow, names_1.ColorNames.green, names_1.ColorNames.blue ] }, props: props, description: '', }; } exports.CustomColorTheme = CustomColorTheme; exports.CustomColorThemeProvider = { name: 'basic-wrapper-custom-color-theme', label: 'Custom Color Theme', category: "Miscellaneous" /* ColorTheme.Category.Misc */, factory: CustomColorTheme, getParams: function () { return ({}); }, defaultValues: {}, isApplicable: function (ctx) { return true; }, };