Lektion 2 Logische Operatoren

This commit is contained in:
2023-09-28 11:20:54 +02:00
parent 4c00f4785c
commit 7e705bc6cc
3 changed files with 53 additions and 0 deletions

View File

@@ -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;
}
}