Modeling2.html

From 2013.igem.org

(Difference between revisions)
Line 392: Line 392:
     plotSolution(this.yone, this.ytwo, graphyMin);  
     plotSolution(this.yone, this.ytwo, graphyMin);  
};
};
 +
 +
var mousePressed = function() {
 +
    mouseOverSlider = true;
 +
};
 +
 +
var mouseReleased = function() {
 +
    mouseOverSlider = false;
 +
};
 +
 +
//Setting up arrows to be in Vector field
 +
    /*Vector Field */
 +
    var arrows =  [];
 +
    var funcX = xMin + dx/2; /* Start X */
 +
    var funcY = yMin + dy/2;
 +
    var graphX = graphxMin + boxWidth/2;
 +
    var graphY = graphyMin - boxHeight/2;
 +
    var maxLength = 0;
 +
    var count = 0;
 +
 +
    /*This is for finding the actual values in the x and y direction*/
 +
    for (var k = 0; k < arrowsinRow; k++) {
 +
        for (var l = 0; l < arrowsinCol; l++){
 +
            arrows.push(new arrow(funcX, funcY, graphX, graphY));
 +
            arrows[count].calculate();
 +
            funcX += dx;
 +
            graphX+= boxWidth;
 +
 +
            /* Find Max Length to scale arrow lengths */
 +
            if (maxLength < arrows[count].length) {
 +
                maxLength = arrows[count].length;
 +
            }
 +
            count++;
 +
        }
 +
          funcY += dy;
 +
          funcX = xMin + dx;
 +
          graphX = graphxMin + boxWidth/2;
 +
          graphY -= boxHeight;
 +
    }
 +
 +
 +
    var nullClines = [];
 +
    nullClines.push(new odeSolution(1.001, 1.001));
 +
    nullClines.push(new odeSolution(0.999, 0.999));
 +
    nullClines[0].calculate();
 +
    nullClines[1].calculate();
 +
 +
var boxSlider = function(x, y, w, h, heading, theta, max, thetaInterval) {
 +
    this.x = x;
 +
    this.y = y;
 +
    this.w = w;
 +
    this.h = h;
 +
    this.heading = heading;
 +
    this.theta = theta;
 +
    this.max = max;
 +
    this.myX = (w-30)*(this.theta/this.max) + this.x + 15;
 +
    this.myY = this.y + 28;
 +
 +
   
 +
    this.draw = function(){
 +
    noStroke();
 +
    fill(50, 50, 50);
 +
    rect(x+2, y+2, w, h, 8);
 +
    fill(255, 255, 255, 230);
 +
    rect(x, y, w, h, 8);
 +
    textFont(myFont, 15);
 +
    fill(0, 0, 0);
 +
    textAlign(LEFT, BOTTOM);
 +
    text(heading + this.theta, x+10, y+16);
 +
    fill(50, 50, 50, 220);
 +
    rect(x+10, y+25, w-20, 6, 6);
 +
    ellipse(this.myX, this.myY, 15, 15);
 +
 
 +
};
 +
   
 +
    this.moveSlider = function(){
 +
      if (mouseX > x+5  && mouseX < x + w + 10 && mouseY        > y && mouseY < y + h + 30){
 +
            this.theta = round(((mouseX - x ) / w) * this.max* 10)/10;
 +
            thetaPlay = this.theta ;
 +
            this.myX = (w-30)*(this.theta/this.max) + x + 15;
 +
            this.draw(); 
 +
 +
            count = 0 ;
 +
            maxLength = 0;
 +
            for (var i = 0; i < arrowsinRow; i++){
 +
            for (var j = 0; j < arrowsinCol; j++){
 +
                arrows[count].calculate();  /*maxLength is to scale everything, boxHeight is the */
 +
             
 +
                if (maxLength < arrows[count].length) {
 +
                maxLength = arrows[count].length;
 +
            }
 +
            count++;
 +
            }
 +
        }
 +
            nullClines[0].calculate();
 +
            nullClines[1].calculate();
 +
 +
      }
 +
    };
 +
};
 +
 +
var slider = new boxSlider(uiBoxX, uiBoxY, uiWidth, uiHeight, heading, thetaPlay, thetaMax, thetaInterval);

Revision as of 23:40, 27 September 2013

iGEM