For those of you who are interested, i have included my code on bezier curves after the jump. Copy the code into a new sketch, run, and click in the resulting window. The code uses a switch statement, which is really a simplified series of if/else statements. In the comments are my first two iterations of the the algorithm. I've never used processing before, so this was fun to write. Are there better ways of writing this? And is it cool if i post my homework here when i am finished with it? Anyone want me to keep writing up example code?
int value = 0;
void setup(){
size(300,300);
noFill();
}
void draw(){
stroke(0);
strokeWeight(0);
for (int x=1; x <10; x++){
line(0, 30*x, 300, 30*x);
line(30*x,0,30*x,300);
}
}
void mouseReleased(){
if (value >= 4) {value=0; background(255);}
int tempStart = 60*value;
int tempEnd = 60 +60*value;
strokeWeight(3);
switch(value){
case 1:
stroke(255,0,0);
println("the bezier handles are 1 unit away and the curve is red");
break;
case 2:
stroke(0,255,0);
println("the bezier handles are 2 unit away and the curve is green");
break;
case 3:
stroke(0,0,255);
println("the bezier handles are 3 unit away and teh curve is blue");
break;
}
bezier(tempStart,tempStart,tempStart+(30*value), tempStart,tempEnd-(30*value),tempEnd,tempEnd,tempEnd);
line(tempStart,tempStart,(tempStart+(30*value)), tempStart);
line((tempEnd-(30*value)),tempEnd,tempEnd,tempEnd);
value = value+1;
}
/*
int tempStart = 30*Value;
int tempEnd = 60 +30*Value;
strokeWeight(3);
case 1:
stroke(255,0,0);
println("the bezier handles are 1 unit away and the curve is red");
bezier(tempStart,tempStart,(tempStart+(30*value)), tempStart,(tempEnd-(30*value)),tempEnd,tempEnd,tempEnd);
line(tempStart,tempStart,(tempStart+(30*value)), tempStart);
line((tempEnd-(30*value)),tempEnd,tempEnd,tempEnd);
break;
case 2:
stroke(0,255,0);
println("the bezier handles are 2 unit away and the curve is green");
bezier(tempStart,tempStart,tempStart+(30*value), tempStart,tempEnd-(30*value),tempEnd,tempEnd,tempEnd);
line(tempStart,tempStart,(tempStart+(30*value)), tempStart);
line((tempEnd-(30*value)),tempEnd,tempEnd,tempEnd);
break;
case 3:
stroke(0,0,255);
println("the bezier handles are 3 unit away and teh curve is blue");
bezier(tempStart,tempStart,tempStart+(30*value), tempStart,tempEnd-(30*value),tempEnd,tempEnd,tempEnd);
line(tempStart,tempStart,(tempStart+(30*value)), tempStart);
line((tempEnd-(30*value)),tempEnd,tempEnd,tempEnd);
break;
*/
//original version
/*
case 1:
stroke(255,0,0);
strokeWeight(3);
println("the bezier handles are 1 unit away and the curve is red");
bezier(150,150,(150+(30*value)), 150,(240-(30*value)),240,240,240);
line(150,150,(150+(30*value)), 150);
line((240-(30*value)),240,240,240);
break;
case 2:
stroke(0,255,0);
strokeWeight(3);
println("the bezier handles are 2 unit away and the curve is green");
bezier(150,150,150+(30*value), 150,240-(30*value),240,240,240);
line(150,150,(150+(30*value)), 150);
line((240-(30*value)),240,240,240);
break;
case 3:
stroke(0,0,255);
strokeWeight(3);
println("the bezier handles are 3 unit away and teh curve is blue");
bezier(150,150,150+(30*value), 150,240-(30*value),240,240,240);
line(150,150,(150+(30*value)), 150);
line((240-(30*value)),240,240,240);
break;
*/