annemarie
YaBB Newbies
Offline
Posts: 43
problems calling a function ...
Jun 4th , 2007, 10:38am
Hi, In the below code, why can't I call up the function twice and put different numbers into the variables, when I activate the interpolation ? import processing.opengl.*; void setup() { size(390, 390, OPENGL); background(0); frameRate(30); } void draw() { background(0); // - why can't I call up the function twice and put different numbers into the variables, when I activate the interpolation ? if(mouseX> 0 && mouseX<100 && mouseY> 0 && mouseY<100){ lines(6, 12, 1, 50, 20, 1, 100, 90, 0.3, 0, 0, 250); // lAmt, lDist, sw, tx, ty, tz, lw, speed, smooth, r, g, b lines(20, 3, 1, 20, 10, 1, 100, 90, 0.5, 255, 0, 0); } else { lines(3, 5, 1, 20, 10, 1, 200, 90, 0.3, 0, 0, 255); lines(9, 3, 1, 50, 50, 1, 200, 90, 0.5, 255, 20, 0); } } float ilDist, ilw, itx, ity, itz; // float ilDist, float ilw, float itx, float ity, float itz void lines(float lAmt, float lDist, float sw, float tx, float ty, float tz, float lw, float speed, float smooth_, int r, int g, int b) { // draw the lines pushMatrix(); translate(itx, ity, itz); for(int i=0; i<lAmt; i++){ stroke(r, g, b); //line(0, i*ilDist, ilw, i*ilDist); line(0, i*lDist, lw, i*lDist); } // end forloop popMatrix(); // interpolation ilw = ilw * smooth_ + lw * (1.0 - smooth_); ilDist = ilDist * smooth_ + lDist * (1.0 - smooth_); itx = itx * smooth_ + tx * (1.0 - smooth_); ity = ity * smooth_ + ty * (1.0 - smooth_); itz = itz * smooth_ + tz * (1.0 - smooth_); } // end lines1