Skip to content

Commit

Permalink
Change 0D vs 1D and two D plus animation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeammimi committed Mar 3, 2017
1 parent b787a84 commit ac132bf
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions js/src/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ var ScatterView = widgets.WidgetView.extend( {
this.previous_values["vz"] = this.model.get("vz")[pindex]
this.attributes_changed["vz"] =["vz"]
}
if (this.model.get("color") ) {
color = this.model.get("color")
if (!(typeof color == "string" || typeof color[0] == "string")){
//check for 2d
this.previous_values["color"] = this.model.get("color")[Math.min(pindex,color.length-1)]
this.attributes_changed["color"] =["color"]
}
}


}
else if(key_animation == "geo") {
Expand Down Expand Up @@ -491,17 +500,16 @@ var ScatterView = widgets.WidgetView.extend( {

function get_value_index_color(variable,index,max_count){
//Return a two D array (max_count,3)
var tmp_color = new Array(max_count);


if ( typeof variable == "string") {
//OD
color = to_rgb(variable)
for(var i = 0; i < max_count; i++) {
tmp_color[i] = color
}
return color
}

else {
var tmp_color = new Array(max_count);
if ( typeof variable[0] == "string") {
// 1 D
to_convert = variable
Expand All @@ -515,34 +523,49 @@ var ScatterView = widgets.WidgetView.extend( {
for(var i = 0; i < max_count; i++) {
tmp_color[i] = to_rgb(to_convert[i])
}
return tmp_color
}

return tmp_color
}


var color = get_value_index_color(this.model.get("color"),index,max_count)
var color_d = 0; //Dimension of color
if (typeof color[0][0] != "undefined"){
color_d = 1
}

var color_previous = "color" in this.previous_values ? get_value_index_color(this.previous_values["color"],this.previous_values["index"],max_count) : color;
if(!color_previous)
color_previous = color;
console.log("color",color)
console.log("color_previous",color_previous)
var color_previous_d = 0; //Dimension of color_previous
if (typeof color_previous[0][0] != "undefined"){
color_previous_d = 1
}

var color_selected = to_rgb(this.model.get("color_selected"))
var color_selected_previous = "color_selected" in this.previous_values ? to_rgb(this.previous_values["color_selected"]) : color_selected;
if(!color_selected_previous)
color_selected_previous = color_selected;

for(var i = 0; i < max_count; i++) {
var cur_color = color[i];
if (color_d == 0){
var cur_color = color;
}
else{
var cur_color = color[i];
}

if(selected.indexOf(i) != -1)
cur_color = color_selected

colors.setXYZ(i, cur_color[0], cur_color[1], cur_color[2]);
if (color_previous_d == 0){
var cur_color_previous = color_previous;
}
else{
var cur_color_previous = color_previous[i];
}

var cur_color_previous = color_previous[i];
if(selected_previous.indexOf(i) != -1)
cur_color_previous = color_selected_previous
colors_previous.setXYZ(i, cur_color_previous[0], cur_color_previous[1], cur_color_previous[2]);
Expand Down

0 comments on commit ac132bf

Please sign in to comment.