import java.awt.*; import java.applet.Applet; import java.math.*; /* ** --- Spiral.java --- ** ** (c) 2000 Stefan Robl ** ** Web: http://www.qdev.de */ public class Spiral extends Applet implements Runnable { Image img; Graphics gfx; Thread thread; int width, height, mx, my, x, y, ox, oy; double ww=0.0, f=0.0, b=20.0; public void init() { width=this.size().width; height=this.size().height; img=createImage(width,height); gfx=img.getGraphics(); mx=width>>1; my=height>>1; } public void start() { if (thread == null) { thread = new Thread(this); thread.start(); } } public void stop() { if (thread != null) { thread.stop(); thread = null; } } public void run() { while (true) { repaint(); try { Thread.sleep(25); } catch(InterruptedException e) {} } } public void paint( Graphics g ) { double w=ww; gfx.setColor(new Color(0,0,0)); gfx.fillRect(0, 0, width, height); gfx.setColor(new Color(255,255,255)); x=mx;y=my; for(f=0; f<300; f+=b) { for(int l=0; l<62; l++) { double ff=f+(((double) l/62.0)*b); ox=x; oy=y; x=mx+(int) (Math.sin(w)*ff); y=my+(int) (Math.cos(w)*ff); gfx.drawLine(ox,oy,x,y); gfx.drawLine(ox,oy+1,x,y+1); gfx.drawLine(ox+1,oy,x+1,y); w-=0.1; } } g.drawImage(img,0,0,this); ww+=0.3; } public void update(Graphics g) { paint(g); } }