import java.awt.*; import java.awt.image.*; public class SineWaves extends java.applet.Applet implements Runnable { Image img; Thread runThread; long firstFrame, frames, fps; int width, height; int w=64, h=64; int[] waveTable=new int[256]; int[] xPoints=new int[w+3]; int[] yPoints=new int[w+3]; boolean ready; public void init() { width = size().width; height = size().height; img=createImage(width, height); } public void start() { if (runThread == null) { runThread=new Thread(this); runThread.start(); firstFrame=System.currentTimeMillis(); frames = 0; ready = false; }; } public void stop() { if (runThread != null) { runThread.stop(); runThread=null; } } public void update(Graphics g) { if (ready) { g.drawImage(img, 0, 0, null); frames++; fps = (frames*10000) / (System.currentTimeMillis()-firstFrame); g.drawString(fps/10 + "." + fps%10 + " fps", 2, height - 2); } } void calculateWaveTable() { for(int i=0;i<256;i++) waveTable[i]=(int)(32*(1+Math.sin(((double)i*2*Math.PI)/256))); } public void run() { int x,y; int index; int tempval,result; int spd1=2,spd2=5,spd3=1,spd4=4; int pos1=0,pos2=0,pos3=0,pos4=0; int tpos1,tpos2,tpos3,tpos4; int inc1=6,inc2=3,inc3=3,inc4=9; Graphics ig = img.getGraphics(); runThread.setPriority(Thread.MIN_PRIORITY); calculateWaveTable(); while(true) { ig.setColor(Color.white); ready=false; ig.fillRect(0,0,width,height); ig.setColor(Color.black); tpos1=pos1; tpos2=pos2; tpos3=pos3; tpos4=pos4; for(int i=0;i