Ver Fonte

Updated the element symbol color theme so that the carbon color is also adjusted by saturation and brightness props

Jason Pattle há 2 anos atrás
pai
commit
c9b14f0742
2 ficheiros alterados com 9 adições e 6 exclusões
  1. 2 2
      src/mol-theme/color/element-symbol.ts
  2. 7 4
      src/mol-util/color/color.ts

+ 2 - 2
src/mol-theme/color/element-symbol.ts

@@ -12,7 +12,7 @@ import { ColorTheme } from '../color';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { ThemeDataContext } from '../theme';
 import { TableLegend } from '../../mol-util/legend';
-import { getAdjustedColorMap } from '../../mol-util/color/color';
+import { getAdjustedColor, getAdjustedColorMap } from '../../mol-util/color/color';
 import { getColorMapParams } from '../../mol-util/color/params';
 import { ChainIdColorTheme, ChainIdColorThemeParams } from './chain-id';
 import { OperatorNameColorThemeParams, OperatorNameColorTheme } from './operator-name';
@@ -68,7 +68,7 @@ export function ElementSymbolColorTheme(ctx: ThemeDataContext, props: PD.Values<
 
     function elementColor(element: ElementSymbol, location: Location) {
         return (carbonColor && element === 'C')
-            ? carbonColor(location, false)
+            ? getAdjustedColor(carbonColor(location, false), props.saturation, props.lightness)
             : elementSymbolColor(colorMap, element);
     }
 

+ 7 - 4
src/mol-util/color/color.ts

@@ -166,13 +166,16 @@ export function ColorMap<T extends { [k: string]: number }>(o: T) { return o as
 export function getAdjustedColorMap<T extends { [k: string]: number }>(map: ColorMap<T>, saturation: number, lightness: number) {
     const adjustedMap: { [k: string]: Color } = {};
     for (const e in map) {
-        let c = map[e];
-        c = Color.saturate(c, saturation);
-        c = Color.darken(c, -lightness);
-        adjustedMap[e] = c;
+        adjustedMap[e] = getAdjustedColor(map[e], saturation, lightness);
     }
     return adjustedMap as ColorMap<T>;
 }
+export function getAdjustedColor(color: Color, saturation: number, lightness: number) {
+    let c = color;
+    c = Color.saturate(c, saturation);
+    c = Color.darken(c, -lightness);
+    return c
+}
 
 export type ColorSwatch = [string, Color][]
 export function ColorSwatch(l: [string, number][]) { return l as unknown as ColorSwatch; }