Template:Team:Paris Saclay/simbox

From 2013.igem.org

(Difference between revisions)
Line 270: Line 270:
  }
  }
   
   
-
  //simbox_draw_graph(simid);
+
  simbox_draw_graph(simid);
  simbox_update_controls(simid);
  simbox_update_controls(simid);
Line 372: Line 372:
}
}
 +
function simbox_drawXcoord(simid, t)
 +
{
 +
var tmin= simulations[simid].draw_min_t;
 +
var tmax= simulations[simid].draw_max_t;
 +
return simulations[simid].canv.width*(t-tmin)/(tmax-tmin);
 +
}
 +
function simbox_drawYcoord(simid, v)
 +
{
 +
var vmin= simulations[simid].draw_min_v;
 +
var vmax= simulations[simid].draw_max_v;
 +
return simulations[simid].canv.height*(v-vmin)/(vmax-vmin);
 +
}
 +
 +
function simbox_draw_graph(simid)
 +
{
 +
var sim= simulations[simid];
 +
var canv= sim.canv;
 +
var ctx= sim.ctx;
 +
 +
for(var i= 0 ; i < sim.molecules.length ; ++i)
 +
{
 +
  if(sim.mulecules[i].curve_show)
 +
  {
 +
  var dta= sim.mulecules[i].history;
 +
  if(dta.length < 2) continue;
 +
  ctx.moveTo( simbox_drawXcoord(simid, 0), simbox_drawYcoord(simid, dta[0]) );
 +
  for(var ti= 1 ; ti < dta.length ; ++ti)
 +
    ctx.lineTo( simbox_drawXcoord(simid, ti*sim.timestep), simbox_drawYcoord(simid, dta[ti]) );
 +
  ctx.stroke();
 +
  }
 +
}
 +
}

Revision as of 01:06, 3 August 2013