Lektion 2 Logische Operatoren
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
int ellipseColor = 0;
|
||||
boolean onceWhite = false;
|
||||
|
||||
void setup() {
|
||||
size(400,400);
|
||||
}
|
||||
void draw() {
|
||||
background(255);
|
||||
fill(ellipseColor);
|
||||
|
||||
ellipse(width/2, height/2, 50, 50);
|
||||
// actually change color
|
||||
if (ellipseColor < 255 && onceWhite == false) {
|
||||
ellipseColor++;
|
||||
} else if (ellipseColor > 0 && onceWhite == true) {
|
||||
ellipseColor--;
|
||||
}
|
||||
|
||||
// switch between white and black
|
||||
if (ellipseColor == 255 && onceWhite == false) {
|
||||
onceWhite = true;
|
||||
}
|
||||
if (ellipseColor == 0 && onceWhite == true) {
|
||||
onceWhite = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user