/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.opensim.threejs;

import org.opensim.modeling.GeometryPath;
import org.opensim.modeling.State;
import org.opensim.modeling.Vec3;

/**
 *
 * @author Ayman-NMBL
 * 
 * Default ColorMap for earlier versions of OpenSim red-to-blue 0-1
 *  RGB components scales linearly
 */
public class ModernPathColorMap implements PathColorMap {

    @Override
    public Vec3 getColor(GeometryPath path, State state) {
        Vec3 activationBasedColor = path.getColor(state);
        double redness = activationBasedColor.get(0);
        Vec3 mappedColor = new Vec3(0.6435 + 0.07588*redness,
            0.7009 - 0.6396*redness,
            0.8554 - 0.6891*redness);
        return mappedColor;
    }
    
}

@@ -208,16 +208,52 @@
 reejs;%0A%0A
+import java.util.prefs.Preferences;%0A
 import o
@@ -286,16 +286,16 @@
 ryPath;%0A
-
 import o
@@ -354,16 +354,49 @@
 ng.Vec3;
+%0Aimport org.opensim.utils.TheApp;
 %0A%0A/**%0A *
@@ -586,16 +586,344 @@
 lorMap %7B
+%0A    double weight = 0.0;%0A    %0A    void updateWeight ()%7B%0A        String weightString=%220.%22;%0A        String saved=Preferences.userNodeForPackage(TheApp.class).get(%22ColorMap Weight%22, weightString);%0A        Preferences.userNodeForPackage(TheApp.class).put(%22ColorMap Weight%22, saved);%0A        weight = Double.parseDouble(saved);%0A    %7D
 %0A%0A    @O
@@ -989,16 +989,41 @@
 tate) %7B%0A
+        updateWeight ();%0A
         
@@ -1275,19 +1275,241 @@
     
-return mapp
+Vec3 rawColor = new Vec3(redness, 0, 1-redness);%0A        Vec3 weightedColor = new Vec3();%0A        for (int i=0; i%3C3; i++)%0A            weightedColor.set(i, weight*rawColor.get(i)+(1 - weight)*mappedColor.get(i));%0A        return weight
 edCo

Introduce blending weight to tune muscle colors