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 = 20; 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){ pushMatrix(); translate(x, y); scale(scl[steps-1]); line(0, 0, xEnd - x, yEnd - y); popMatrix(); steps--; } else line(x, y, xEnd, yEnd); } void disappear(){ x = y = xEnd = yEnd = 1000; bdraw(); } }