/** KaosAnimationV2 Applet Copyright(c) 2001 WakuWaku.All rights reserved.*/ import java.awt.*; import java.awt.image.*; import java.applet.Applet; public class KaosWing extends Applet implements Runnable { public static final int width=400,height=400; Thread th=null; Image img; //オフスクリーンバッファ boolean clear=false; public void init() { setBackground(Color.black); img=createImage(width,height); } public void start() { if(th==null) { th=new Thread(this); //スレッド作成 th.setPriority(th.NORM_PRIORITY+1); } th.start(); } public void stop() { if(th!=null) { th.stop(); //スレッド停止 th=null; } } public void run() { int count=0,i=0,px,py; double x,y,x0,y0,x00=0.1,y00=0.0 ,a=-0.97,da=0.01,b=0.97,db=0.01; x0=x00; y0=y00; int[] p=new int[width*height]; //イメージ配列を黒色で初期化 for(int j=0;j300.0) { x0=x00; y0=y00; } //イメージ配列に演算結果を代入 p[getOff((int)((x+y)*6)+width/2,(int)((x-y)*6)+height/2-20)]=0xffffffff; a+=0.0000005; //アニメーションの為、値を少しずつ変更 b+=0.00000001; if(++count%10000==0) { //c=col[++i%15]; //配列からイメージを作成 img=createImage(new MemoryImageSource(width,height,p,0,width)); repaint(); //実際の画面に描画 th.sleep(15); //15msのウェイト //残像処理 int k; for(int j=0;j=width) x=y=0; if(y<0 || y>=height) y=x=0; return y*width+x; } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(img,0,0,this); } }