/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
import java.awt.*;
import java.applet.*;
public class name1 extends java.applet.Applet implements Runnable
{
int width = 400;
int height = 200;
int d ;
int r = 60;
double alfa=-0.5;
Thread runner;
Image offscreenImage;
Graphics offscreenG;
public void init()
{
offscreenImage = createImage(width,height);
offscreenG = offscreenImage.getGraphics();
}
public void start()
{
if(runner == null)
{
runner = new Thread(this);
runner.start();
}
}
public void stop()
{
if(runner != null)
runner = null;
}
public void run()
{
while(true)
{
alfa += 0.5;
d = (int)Math.ceil(r*Math.sin(alfa*Math.PI/180));
repaint();
try
{
Thread.sleep(2);
}
catch(InterruptedException e)
{
}
if(alfa ==360)
alfa = 0;
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
offscreenG.setColor(Color.green);
offscreenG.fillRect(0,0,width,height);
offscreenG.setColor(Color.black);
offscreenG.drawLine((int)Math.ceil(-80*Math.cos(alfa*Math.PI/180)+d+width/2),60,(int)Math.ceil(-40*Math.cos(alfa*Math.PI/180)+d+width/2),60);
offscreenG.drawLine((int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),40,(int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),80);
offscreenG.drawLine((int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),60,(int)Math.ceil(-80*Math.cos(alfa*Math.PI/180)+d+width/2),80);
offscreenG.drawLine((int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),60,(int)Math.ceil(-40*Math.cos(alfa*Math.PI/180)+d+width/2),80);
offscreenG.drawLine((int)Math.ceil(-70*Math.cos(alfa*Math.PI/180)+d+width/2),80,(int)Math.ceil(-50*Math.cos(alfa*Math.PI/180)+d+width/2),80);
offscreenG.drawLine((int)Math.ceil(-50*Math.cos(alfa*Math.PI/180)+d+width/2),80,(int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),85);
offscreenG.drawLine((int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),85,(int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),110);
offscreenG.drawLine((int)Math.ceil(-60*Math.cos(alfa*Math.PI/180)+d+width/2),110,(int)Math.ceil(-65*Math.cos(alfa*Math.PI/180)+d+width/2),108);
offscreenG.drawLine((int)Math.ceil(-80*Math.cos(alfa*Math.PI/180)+d+width/2),95,(int)Math.ceil(-40*Math.cos(alfa*Math.PI/180)+d+width/2),95);
g.drawImage(offscreenImage,0,0,this);
}
}