Invention2.java
package npw;
import painter.SPainter;
import shapes.SRectangle;

import java.awt.*;
import java.util.Random;

public class Invention2 {

    public static void main(String[]args)

    {

        SPainter Invention = new SPainter("Invention 2",600,600);
        SRectangle rectangle = new SRectangle(20,70);



        Invention.setColor(Color.BLACK);
        Invention.paint(rectangle);


        int x =1;
        while (x<100){

            Invention.setColor(RandomColor());
            Invention.tl();
            Invention.move();
            Invention.paint(rectangle);
            Invention.tr();
            x = x + 1;

        }
        Invention.moveToCenter();
        x =1;
        while(x < 500) {

            if (x > 250) {

                Invention.setColor(RandomColor());
                Invention.move();
                Invention.paint(rectangle);
            } else if (x < 250){


                Invention.setColor(Color.lightGray);
                Invention.move();
                Invention.paint(rectangle);
            }



            x = x + 1;
        }


    }

    private static Color RandomColor() {
        int re = (int)(Math.random()*256);
        int gr = (int)(Math.random()*256);
        int bl = (int)(Math.random()*256);

        return new Color(re, gr, bl);
    }


}