// Fws3DDrive.java // Flower Works Animation Applet (Sub Driving Applet) // Copyright (C) 1997,1998 Yukinori NAGATANI // nagatani@eken.phys.nagoya-u.ac.jp import java.applet.Applet; import java.awt.*; import java.util.Date; import java.net.URL; import Fws3D; //import StringRoll; public class Fws3DDrive extends Applet { int xSize, ySize; Fws3D fws; int nFwTime; double angleXY; // StringRoll RollWelcome; public void init (int xWin, int yWin) { xSize = xWin; ySize = yWin; resize (xWin, yWin); fws = new Fws3D (); nFwTime = 0; angleXY = 0.0; // URL ImageURL = getDocumentBase(); // Image imageStrings // = getImage (ImageURL, "WelcomeNagatani.gif"); // RollWelcome // = new StringRoll (imageStrings, 50, 0, this); } public void paint (Graphics g) { g.setColor (getBackground()); g.fillRect (0, 0, size().width, size().height); // RollWelcome.paint (g, this); for (Fw3D fw = fws.first ; fw != null ; fw = fw.next) { double X = +Math.cos (angleXY) * fw.x +Math.sin (angleXY) * fw.y, Y = -Math.sin (angleXY) * fw.x +Math.cos (angleXY) * fw.y, Z = fw.z; double depth = 1000; int x = (int) (0.5*xSize + X * depth/(depth+Y)), y = (int) (1.0*ySize - Z * depth/(depth+Y)); g.setColor (fw.getColor ()); g.fillRect (x,y, 2,2); } fws.evolute (); if (nFwTime <= 0) { double x = -10 + (int) (20.0*Math.random ()), rAngle = Math.PI * (0.35 + 0.3*Math.random ()), V = 8.0 + 9.0*Math.random (), xV = V * Math.cos (rAngle), yV = 0.0, zV = V * Math.sin (rAngle); Fw3D fw = new Fw3D (x, 0.0, 0.0, xV, yV, zV, 0.01, 20, 2); fws.add (fw); double R = Math.random (); nFwTime = 1 + (int) (50.0*R*R); } angleXY += 2.0*Math.PI * 5/360; nFwTime --; } }