/home/jfernan6/NetBeansProjects/CSX/src/npw/Invention2.java
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package npw;
 7 
 8 import java.awt.Color;
 9 import java.util.Random;
10 import painter.SPainter;
11 import shapes.SRectangle;
12 
13 /**
14  *
15  * @author jfernan6
16  */
17 public class Invention2 {
18 public static Random rand = new Random();
19    
20 /**
21      * @param args the command line arguments
22      */
23     public static void main(String[] args) {
24         
25         SPainter painter = new SPainter(600,600);
26         SRectangle rectangle = new SRectangle(30,10);
27         SRectangle background = new SRectangle(600,600);
28         Color skyBlue = new Color(135,206,250);
29         painter.setColor(skyBlue);
30         painter.paint(background);
31      
32        
33          
34          int i = 0;
35         while(i<400){
36             painter.setColor(randomColor());
37             if(i%2==0){
38             painter.draw(rectangle);
39             painter.setColor(randomColor());
40             painter.paint(rectangle);
41             painter.mrt(rectangle.width());
42             rectangle.shrink(7, 7);
43             painter.mfd(i);
44             painter.mrt(i);
45             painter.tr(i);
46             i++;
47             }
48             else{
49             painter.setColor(randomColor());
50             painter.paint(rectangle);
51             painter.mlt(rectangle.width());
52             rectangle.expand(4, 4);
53             painter.mbk(i);
54             painter.mlt(i);
55             painter.tr(i);
56             i++;
57             }
58             
59         }
60          
61     }
62  
63     public static  Color randomColor(){
64         
65         int rv = rand.nextInt(256);
66         int gv = rand.nextInt(256);
67         int bv = rand.nextInt(256);
68         return new Color(rv,gv,bv);
69          }
70     }
71     
72 
73 
74