public class Line{ //member float x, y, xEnd, yEnd; int alpha; int steps; float[] scl; //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; // 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); 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(); } }