Processing Forum
int alpha = 0;
boolean fade;
void setup() {
smooth();
frameRate(1);
fade = false;
}
void draw() {
fill(200, 50, 100, alpha);
ellipse(50, 50, 50, 50);
twinkle();
println("cycle");
}
void twinkle() {
//fade in and out
if (fade == false) {
for (float i = 0; i<=255; i++) {
alpha = (int)i;
println("++ " + alpha);
}
if (alpha == 255) {
fade = true;
println("fade = true");
}
}
else {
for (float i=255; i>=0; i--) {
alpha = (int)i;
println("-- " + alpha);
}
if (alpha == 0) {
fade = false;
println("fade = false");
}
}
}