FMC2nd_p43_Lines14

p43_Lines14

p43_Lines14


イメージからアプレットを起動

Lines13を元に、線が延びていく時に回転。
Lines13のメインはそのまま、再びLines.pde(クラス)の変更。


Lines.pde(クラス)
[java]
public class Line{
//member
float x, y, xEnd, yEnd;
int alpha;
int steps;
float[] scl;
float r;
float nowR;
//constructor
Line(float x, float y, float xEnd, float yEnd){
this.x = x;
this.y = y;
this.xEnd = xEnd;
this.yEnd = yEnd;
alpha = 255;
steps = 0;
r = 2*PI/20;
nowR = 0;
// scl = new float[steps];
// scl[0] = 0;
// for(int i=0; i < steps; i++){
// float pre = 100000/(i+1);
// scl[i] = pre/100000;
// println(i+" = "+scl[i]);
// }
}
//method
void setAlpha(int alpha){
this.alpha = alpha;
bdraw();
}

void bdraw(){
stroke(0, alpha);
// if(steps > 0){
if(steps < 20){
pushMatrix();
translate(x, y);
// scale(scl[steps-1]);
// line(0, 0, (xEnd – x)/steps, (yEnd – y)/steps);
nowR += r;
rotate(nowR);
line(0, 0, ((xEnd – x)/20)*steps, ((yEnd – y)/20)*steps);
popMatrix();
// steps–;
steps++;
}
else line(x, y, xEnd, yEnd);

}

void disappear(){
x = y = xEnd = yEnd = 1000;
bdraw();
}
}
[/java]

タグ:

コメントをどうぞ