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