📄 fireballtitle.java
字号:
import java.applet.*;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
public class fireballtitle extends Applet
implements Runnable
{
private int fontsize = 0;
private int l = 0;
private int dx = 0;
private int col = 0;
private int step = 0;
private int sel = 0;
private Thread program_thread = null;
private Font font = null;
private Image bufferscreen = null;
private int sleeptime = 0;
private Graphics g = null;
private Graphics g2 = null;
private int maxitems = 0;
String items[] = null;
String urls[] = null;
private Color colors[] = null;
private int colortable[] = null;
private Dimension d = null;
private double alpha = 0;
private double beta = 0;
private int charcount = 0;
private int backgroundcolorint = 0;
private int foregroundcolorint = 0;
private Color backgroundcolor = null;
private Color foregroundcolor = null;
private String target = null;
AppletContext appletcontrol = null;
public void init()
{
super.init();
setLayout(null);
prepareVariables();
alpha = 0.0D;
beta = 0.0D;
colortable = new int[100];
colors = new Color[20];
double bgRed = (backgroundcolorint & 0xff0000) >> 16;
double bgGreen = (backgroundcolorint & 0xff00) >> 8;
double bgBlue = backgroundcolorint & 0xff;
double fgRed = (foregroundcolorint & 0xff0000) >> 16;
double fgGreen = (foregroundcolorint & 0xff00) >> 8;
double fgBlue = foregroundcolorint & 0xff;
for(int i = 0; i < 20; i++)
{
double rangeRed = ((fgRed - bgRed) * (double)i) / 19D;
double rangeGreen = ((fgGreen - bgGreen) * (double)i) / 19D;
double rangeBlue = ((fgBlue - bgBlue) * (double)i) / 19D;
int currentRed = (int)(bgRed + rangeRed);
int currentGreen = (int)(bgGreen + rangeGreen);
int currentBlue = (int)(bgBlue + rangeBlue);
colors[i] = new Color(currentRed * 0x10000 + currentGreen * 256 + currentBlue + 0xff000000);
}
for(int j = 0; j < 40; j++)
colortable[j] = 0;
}
public int stylecheck()
{
int i = 0;
String s = getParameter("italic");
s = s.toLowerCase();
if(s.charAt(0) == 'y')
i = 2;
s = getParameter("bold");
s = s.toLowerCase();
if(s.charAt(0) == 'y')
i++;
return i;
}
int getParameter(String s1, int s2) {
String s = getParameter(s1) ;
return (s != null) ? Integer.parseInt(s) : s2 ;
}
Color getParameter(String s1, Color s2)
{
String s = getParameter(s1);
return (s != null) ? new Color(Integer.parseInt(s, 16)) : s2 ;
}
public void prepareVariables()
{
fontsize = getParameter("fontsize", 24);
sleeptime = getParameter("sleeptime", 50);
step = getParameter("step", 5);
resize(getSize().width, getSize().height);
font = new Font("Courier", stylecheck(), fontsize);
d = getSize();
bufferscreen = createImage(d.width, d.height);
appletcontrol = getAppletContext();
g2 = getGraphics();
g = bufferscreen.getGraphics();
foregroundcolor = getParameter("foreground", Color.white);
foregroundcolorint = foregroundcolor.getRGB();
backgroundcolor = getParameter("background", Color.black);
backgroundcolorint = backgroundcolor.getRGB();
target = getParameter("target");
String s = "";
maxitems = 0;
while(s != null)
{
s = getParameter("item" + maxitems);
if(s != null)
maxitems++;
}
items = new String[maxitems];
urls = new String[maxitems];
for(int i = 0; i < maxitems; i++)
{
items[i] = getParameter("item" + i);
urls[i] = getParameter("url" + i);
}
}
public boolean mouseEnter(Event event, int i, int j)
{
Container container = getParent();
for(boolean flag = false; container != null && !flag; container = container.getParent())
if(container instanceof Frame)
{
((Frame)container).setCursor(12);
flag = true;
}
showStatus(urls[sel]);
return true;
}
public boolean mouseExit(Event event, int i, int j)
{
Container container = getParent();
for(boolean flag = false; container != null && !flag; container = container.getParent())
if(container instanceof Frame)
{
((Frame)container).setCursor(0);
flag = true;
}
showStatus("");
return true;
}
public boolean mouseDown(Event event, int i, int j)
{
URL url;
try
{
url = new URL(urls[sel]);
}
catch(MalformedURLException _ex)
{
showStatus("Invalid URL.");
return true;
}
if(target != null)
{
if(target.length() > 0)
appletcontrol.showDocument(url, target);
else
appletcontrol.showDocument(url);
}
else
{
appletcontrol.showDocument(url);
}
return true;
}
public void drawfireball(Graphics g1, int i, int j, int k, int currentGreen)
{
for(double bgRed = currentGreen; bgRed < 2D * Math.PI + (double)currentGreen;)
{
bgRed += (30D * Math.PI) / 180D;
int i2 = 0;
int j2 = 0;
for(int currentBlue = 0; currentBlue < k / 4; currentBlue++)
{
int k1 = i2;
int l1 = j2;
double bgGreen = bgRed + Math.random() / 4D;
i2 = (int)((double)(-currentBlue * 4) * Math.sin(bgGreen));
j2 = (int)((double)(currentBlue * 4) * Math.cos(bgGreen));
Color color = new Color((65280 * (k / 4 - currentBlue) * 4) / k + 0xff0000);
g1.setColor(color);
g1.drawLine(i + k1, j + l1, i + i2, j + j2);
}
}
}
public void start()
{
if(program_thread == null)
{
program_thread = new Thread(this);
program_thread.start();
}
}
public void stop()
{
if(program_thread != null && program_thread.isAlive())
program_thread.stop();
program_thread = null;
}
public void run()
{
g.setFont(font);
FontMetrics fontmetrics = g.getFontMetrics(font);
do
{
sel = 0;
for(int i = 0; i < maxitems; i++)
{
sel = i;
g.setColor(backgroundcolor);
g.fillRect(0, 0, d.width, d.height);
dx = d.width / 2 - fontmetrics.stringWidth(items[i]) / 2;
for(int j = 0; j < d.width; j += step)
{
g.setColor(backgroundcolor);
g.fillRect(0, 0, d.width, d.height);
for(int k = 0; k < items[i].length(); k++)
{
g.setColor(colors[19]);
g.drawString(items[i].substring(k, k + 1), dx + k * (fontsize / 2), fontsize);
}
g.setColor(backgroundcolor);
g.fillRect(j, 0, d.width, d.height);
drawfireball(g, j, d.height / 2 + 4, fontsize / 2, j / 100);
g2.drawImage(bufferscreen, 0, 0, this);
try
{
Thread.sleep(sleeptime / 20);
}
catch(InterruptedException _ex) { }
}
for(int i1 = 0; i1 < 40; i1++)
{
g.setColor(backgroundcolor);
g.fillRect(0, 0, d.width, d.height);
dx = d.width / 2 - fontmetrics.stringWidth(items[i]) / 2;
for(int j1 = 0; j1 < items[i].length(); j1++)
{
if(j1 >= charcount)
{
charcount++;
colortable[j1] = 40;
for(int k1 = 0; k1 < j1 + 1; k1++)
if(--colortable[k1] < 0)
colortable[k1] = 0;
}
if(colortable[j1] > 19)
col = 19;
else
col = colortable[j1];
g.setColor(colors[col]);
g.drawString(items[i].substring(j1, j1 + 1), dx + j1 * (fontsize / 2), fontsize);
}
for(int l1 = 0; l1 < items[i].length() + 1; l1++)
if(--colortable[l1] < 0)
colortable[l1] = 0;
g2.drawImage(bufferscreen, 0, 0, this);
try
{
Thread.sleep(sleeptime);
}
catch(InterruptedException _ex) { }
}
charcount = 0;
}
}
while(true);
}
public boolean handleEvent(Event event)
{
return super.handleEvent(event);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -