Browse Source

sanitize scale.color input to domain

Alexander Rose 6 years ago
parent
commit
c71c1b0f41
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/mol-util/color/scale.ts

+ 1 - 1
src/mol-util/color/scale.ts

@@ -31,7 +31,7 @@ export namespace ColorScale {
         const diff = (max - min) || 1
 
         function color(value: number) {
-            const t = ((value - min) / diff) * count1
+            const t = Math.min(colors.length - 1, Math.max(0, ((value - min) / diff) * count1))
             const tf = Math.floor(t)
             const c1 = colors[tf]
             const c2 = colors[Math.ceil(t)]