import java.awt.*;
import java.applet.*;
public class LX extends Applet implements Runnable
{
Thread animate;
Image img,buffer;
Graphics gContext;
int w,h;
public void init()
{
img=getImage(getCodeBase(),"hongyu.jpg");
MediaTracker tracker=new MediaTracker(this);
tracker.addImage(img,0);
try
{
tracker.waitForID(0);
}
catch (InterruptedException e){ }
w=img.getWidth(this);
h=img.getHeight(this);
buffer=createImage(2*w,h);
gContext=buffer.getGraphics();
gContext.drawImage(img,0,-h,this);
gContext.clearRect(0,0,w,2*h);
}
public void start()
{
if(animate==null)
{
animate=new Thread(this);
animate.start();
}
}
public void stop()
{
if(animate!=null)
animate=null;
}
public void run()
{
int dy,num=0;
double d;
while(true)
{
d=num*Math.PI/6;
for(int i=0;i<h;i++)
{
dy=(int)((i/12.0D+1)*Math.sin(h/12.0D*(h-i)/(i+1)+d));
repaint();
num=++num%12;
try
{
Thread.sleep(50);
}
catch (InterruptedException e){ }
}
}
}
public void update(Graphics g)
{ paint(g); }
public void paint(Graphics g)
{
g.drawImage(img,0,-h,this);
g.drawImage(buffer,0,h,this);
}
}