Invention2.java
1    package npw;
2    
3    import painter.SPainter;
4    import shapes.SCircle;
5    import shapes.SSquare;
6    
7    import javax.swing.*;
8    import java.awt.*;
9    import java.util.Random;
10   
11   public class Invention2 {
12       private void paintTheImage(){
13           int x = 1;
14           while (x == 1){
15               // makes canvas
16               SPainter canvas = new SPainter(800 ,800);
17               // makes all shapes
18               SCircle circle = new SCircle(100);
19               SSquare square = new SSquare(200);
20               //
21               canvas.setColor(Color.BLUE);
22               square.x5();
23               canvas.paint(square);
24               canvas.setColor(randomColor());
25               canvas.mbk(750);
26               canvas.paint(square);
27               canvas.mfd(650);
28               canvas.mlt(310);
29               canvas.paint(circle);
30               canvas.mbk(130);
31               square.s7(); square.s2();
32               canvas.setColor(new Color(123, 31, 11));
33               canvas.paint(square);
34               canvas.setColor(randomColor());
35               canvas.mrt(620);
36               canvas.mfd(600);
37               canvas.paint(circle);
38               if (x == 1){
39                   x = x + 1;
40               }
41   
42           }
43   
44       }
45   
46       private static Color randomColor() {
47           Random rgen = new Random();
48           int r = rgen.nextInt(256);
49           int g = rgen.nextInt(256);
50           int b = rgen.nextInt(256);
51           return new Color(r,g,b);
52       }
53   
54       public Invention2() {paintTheImage();}
55   
56       public static void main(String[] args){
57           SwingUtilities.invokeLater(new Runnable() {
58               public void run() {
59                   new Invention2();
60               }});
61       }
62   }
63