<commit_before>/*
 * 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;
    }
    
}<commit_msg>Introduce blending weight to tune muscle colors<commit_after>/*
 * 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 java.util.prefs.Preferences;
import org.opensim.modeling.GeometryPath;
import org.opensim.modeling.State;
import org.opensim.modeling.Vec3;
import org.opensim.utils.TheApp;

/**
 *
 * @author Ayman-NMBL
 * 
 * Default ColorMap for earlier versions of OpenSim red-to-blue 0-1
 *  RGB components scales linearly
 */
public class ModernPathColorMap implements PathColorMap {
    double weight = 0.0;
    
    void updateWeight (){
        String weightString="0.";
        String saved=Preferences.userNodeForPackage(TheApp.class).get("ColorMap Weight", weightString);
        Preferences.userNodeForPackage(TheApp.class).put("ColorMap Weight", saved);
        weight = Double.parseDouble(saved);
    }

    @Override
    public Vec3 getColor(GeometryPath path, State state) {
        updateWeight ();
        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);
        Vec3 rawColor = new Vec3(redness, 0, 1-redness);
        Vec3 weightedColor = new Vec3();
        for (int i=0; i<3; i++)
            weightedColor.set(i, weight*rawColor.get(i)+(1 - weight)*mappedColor.get(i));
        return weightedColor;
    }
    
}
{'fraction_non_alphanumeric': 0.10007974481658692, 'fraction_numerical': 0.03588516746411483, 'mean_word_length': 3.147107438016529, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2560394', 'n_tokens_mistral': 797, 'n_tokens_neox': 742, 'n_words': 203}