/* autogenerated by Processing revision 1293 on 2023-09-27 */ import processing.core.*; import processing.data.*; import processing.event.*; import processing.opengl.*; import java.util.HashMap; import java.util.ArrayList; import java.io.File; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; public class FarbButtons extends PApplet { int size = 150; public void setup() { /* size commented out by preprocessor */; noStroke(); background(220); } public void draw() { int x1 = width / 2 - size / 2; int y1 = 105 - size / 2; int x2 = x1; int y2 = 285 - size / 2; int x3 = x1; int y3 = 475 - size / 2; drawButton(x1, y1, color(255, 0, 0), "Rot"); drawButton(x2, y2, color(0, 255, 0), "Grün"); drawButton(x3, y3, color(0, 0, 255), "Blau"); // Klick außerhalb der Elemente if (!(x1 <= mouseX && y1 <= mouseY && mouseX <= x1 + size && mouseY <= y1 + size) && !(x2 <= mouseX && y2 <= mouseY && mouseX <= x2 + size && mouseY <= y2 + size) && !(x3 <= mouseX && y3 <= mouseY && mouseX <= x3 + size && mouseY <= y3 + size)) { if (mousePressed) { background(220); } } } public void drawButton(int x, int y, int paint, String title) { // setze Füllfarbe ... if (x <= mouseX && y <= mouseY && mouseX <= x + size && mouseY <= y + size) { if (mousePressed) { background(paint); } fill(200); } // setze Rechteck rect(x, y, size, size); // setze Text fill(0); textAlign(CENTER); text(title, x + size / 2, y + size / 2); fill(255); } public void settings() { size(570, 570); } static public void main(String[] passedArgs) { String[] appletArgs = new String[] { "FarbButtons" }; if (passedArgs != null) { PApplet.main(concat(appletArgs, passedArgs)); } else { PApplet.main(appletArgs); } } }