package npw; import painter.SPainter; import shapes.SRectangle; import javax.swing.*; import java.awt.*; public class Invention2 { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new npw.Invention2(); } }); } public Invention2() { paintTheImage(); } private void paintTheImage() { SPainter davinci = new SPainter("Invention 2", 800, 800); SRectangle rectangle = new SRectangle(randomHeight(),randomWidth()); paintPic(davinci, rectangle); } private void paintPic(SPainter davinci, SRectangle rectangle) { int i = (int) Math.random(); int height = randomHeight(); int width = randomWidth(); rectangle.setHeight(height); rectangle.setWidth(width); Color color = randomColor(); Color color1 = randomColor(); davinci.setColor(color); davinci.paint(rectangle); while (i <500) { if(i % 2 ==0){ davinci.setColor(color1); davinci.mrt(i); davinci.paint(rectangle); }else{ davinci.setColor(color); davinci.mlt(i); davinci.paint(rectangle); } i++; } } private static Color randomColor() { int rv = (int) (Math.random() * 256); int gv = (int) (Math.random() * 256); int bv = (int) (Math.random() * 256); return new Color(rv, gv, bv); } private static int randomHeight(){ int height = (int)(Math.random()*200); return height; } private static int randomWidth(){ int width = (int)(Math.random()*300); return width; } }