Animated Rainbow in Applet

import java.applet.*;
import java.awt.*;
import java.lang.*;
import java.math.*;
import java.awt.Color;


/*<applet code="rainbow" height=1200 width=1200></applet>
  */
public class rainbow extends Applet implements Runnable

{
int i=0,j=0;
int rr[]={148,75,0,0,255,255,255};
int gg[]={0,0,0,255,255,127,0};
int bb[]={211,130,255,0,0,0,0};
Thread t;
public void init()
{
t=new Thread(this);
t.start();
}
public void run()
{
int sec=0;
setSize(1200,1200);
try
{
while(true)
{
repaint();
sec+=1;

t.sleep(1000);

}
}catch(Exception e)
{
System.out.println(e);
}
}

public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{

setBackground(Color.black);


for(i=0;i<7;i++)
{
Color r=new Color((int)rr[i],(int)gg[i],(int)bb[i]);
g.setColor(r);
g.fillArc(8+30*i,8+30*i,1000-60*i,1000-60*i,0,j);
}
g.setColor(Color.black);
g.fillArc(218,218,580,580,0,180);
if(j==180)
t.stop();
j+=10;


}
}

Post a Comment