⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daoying.java

📁 java经典的源代码 我非常喜欢这个源代码 对于编程很有好处
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;
public class daoying extends Applet {
  Image im1,im2;
  Thread thread;
  Graphics gContext;
  int w,h;
  public void init() {
    im1=getImage(getCodeBase(),"leaf.gif");
    MediaTracker tracker=new MediaTracker(this);
    tracker.addImage(im1,0);
    try{
      tracker.waitForID(0);
    }
    catch(InterruptedException e){}
    w=im1.getWidth(this);
    h=im1.getHeight(this)/2;
    im2=createImage(3*w,h);
    gContext=im2.getGraphics();
    gContext.drawImage(im1,0,-h,this);
    for(int i=0;i<h;i++)
      gContext.copyArea(0,i,w,1,w,(h-1)-2*i);
    gContext.clearRect(0,0,w,h);
  }
  public void start(){
    if(thread==null){
      thread=new Thread();
      thread.start();
    }
  }
  public void stop(){
    if(thread!=null)
      thread=null;
  }
  public void run(){
    int dy,num=0;
    double d;
    while(true){
      d=num*Math.PI/12;
      for(int i=0;i<h;i++){
        dy=(int)((i/12.0D+1)*Math.sin(h/12.0D*(h-i)/(i-1)+d));
        gContext.copyArea(w,i+dy,w,1,-w,-dy);
      }
      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(im1,0,-h,this);
    g.drawImage(im2,-w,h,this);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -