Invention2.java
/* 
 * A program to draw colorful circle by using a rectangle. 
 */
 package npw;
 import painter.SPainter;
 import shapes.SRectangle;
 import javax.swing.*;
 import java.awt.*;
 import java.util.Random;

public class Invention2{

     private void paintTheImage(){
         SPainter painter = new SPainter("Colorful Circle",700,700);
         SRectangle rectangle = new SRectangle(6,650);
         int i = 0 ;
         while (i < 180) {
             if(i%2==0){
                 painter.tr(1);
                 painter.setColor(randomColor());
                 painter.paint(rectangle);
             }else{
                 painter.tr(1);
                 painter.setColor(randomColor());
                 painter.paint(rectangle);
             }
             i=i+1;
             try {
                 Thread.sleep(100);
             }catch (InterruptedException e) {
                 e.printStackTrace();
             }
         }
     }

    private Color randomColor() {
        Random rgen = new Random();
        int r = rgen.nextInt(256);
        int g = rgen.nextInt(256);
        int b = rgen.nextInt(256);
        return new Color(r,g,b);
    }
    public Invention2() {
        paintTheImage();
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new Invention2();
            }
        });
    }


}