From 84e220b332bfffb0f2dcc39b9697a6fd6691d265 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:36:30 +0200 Subject: Initial commit --- src/aufgaben/blatt1/Aufgabe2bEPIC.java | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 src/aufgaben/blatt1/Aufgabe2bEPIC.java (limited to 'src/aufgaben/blatt1/Aufgabe2bEPIC.java') diff --git a/src/aufgaben/blatt1/Aufgabe2bEPIC.java b/src/aufgaben/blatt1/Aufgabe2bEPIC.java new file mode 100755 index 0000000..aa8596a --- /dev/null +++ b/src/aufgaben/blatt1/Aufgabe2bEPIC.java @@ -0,0 +1,97 @@ +package aufgaben.blatt1; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Polygon; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import aufgaben.Aufgabe; +import misc.Utils; + +public class Aufgabe2bEPIC extends Aufgabe { + + private final int width = 1920, height = 1080; + private boolean done = false; + private String name; + + public Aufgabe2bEPIC() { + name = "Blatt 1 - 2bEPIC"; + this.setSize(width, height); + this.setTitle("Blatt 1 - Aufgabe 2b - Unendlich Objekte"); + this.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("close"); + done = true; + } + } + ); + } + + @Override + public boolean done() { + return done; + } + + public void paint(Graphics g) { + int x, y; + while(true) { + x = Utils.randomInt(0, width); + y = Utils.randomInt(0, height); + switch(Utils.randomInt(0, 8)) { + case 0: + g.drawRect(x, y, Utils.randomInt(0, width-x), Utils.randomInt(0, height-y)); + break; + case 1: + g.fillRect(x, y, Utils.randomInt(0, width-x), Utils.randomInt(0, height-y)); + break; + case 2: + g.drawArc(x, y, Utils.randomInt(0, width-x), Utils.randomInt(0, height-y), Utils.randomInt(0, 360), Utils.randomInt(0, 360)); + break; + case 3: + g.fillArc(x, y, Utils.randomInt(0, width-x), Utils.randomInt(0, height-y), Utils.randomInt(0, 360), Utils.randomInt(0, 360)); + break; + case 4: + g.drawOval(x, y, Utils.randomInt(0, width-x), Utils.randomInt(0, height-y)); + break; + case 5: + g.fillOval(x, y, Utils.randomInt(0, width-x), Utils.randomInt(0, height-y)); + break; + case 6: + g.drawPolygon(getPolygon()); + break; + case 7: + g.fillPolygon(getPolygon()); + break; + case 8: + g.drawLine(Utils.randomInt(0, width), Utils.randomInt(0, height), Utils.randomInt(0, width), Utils.randomInt(0, height)); + break; + } + g.setColor(new Color(Utils.randomInt(0, 255), Utils.randomInt(0, 255), Utils.randomInt(0, 255))); + } + } + + private Polygon getPolygon() { + int bla = Utils.randomInt(1, 100); + int[] x = new int[bla], y = new int[bla]; + for(int i = 0; i