audioclip hit, cr, ding ;
boolean alreadyrun = false,
soundon = false,
loop = false;
color bgcolor = color.lightgray,
textcolor = color.black ;
font font ;
image offscreen, background ;
int width, height,
currentline = 0,
currentword = 0,
currentletter = 0,
depth = 0,
margin = 0,
cycles = 0,
step = 0,
pause = 0,
speed = 0,
update = 0,
linecount = 0 ;
long lastread = 0;
mediatracker mt ;
string soundactivation, text, textfile, target ;
thread woohoo = null;
url hotlink = null;
vector lines = null;
public typewriter4()
}lines.addelement(s);
linecount = lines.size();
}depth = height - fontmetrics.getheight() / 2;
}public void checktextfile()
datainputstream.close();
lastread =
(new long((new date()).gettime())).longvalue();
return;
}catch(exception exception)
}public void init()
catch(exception e)
if(background != null) mt.addimage(background, 0);
}if ((param = getparameter("bgcolor")) != null)
bgcolor = new color(integer.parseint(param, 16)) ;
if ((param = getparameter("textcolor")) != null)
textcolor = new color(integer.parseint(param, 16)) ;
string fontname = "helvetica" ;
if ((param = getparameter("fontname")) != null)
fontname = param ;
int fontsize = 12 ;
if ((param = getparameter("fontsize")) != null)
fontsize = integer.parseint(param) ;
int fontstyle = font.plain ;
if ((param = getparameter("fontstyle")) != null)
font = new font(fontname, fontstyle, fontsize);
param = getparameter("cycles");
if(param == null || param.equalsignorecase("infinite"))
else
param = getparameter("margin");
margin = param == null ?
width / 10 : integer.parseint(param);
param = getparameter("pause");
pause = param == null ? 2000 : integer.parseint(param);
param = getparameter("soundactivation");
soundactivation = param == null ?
"enter" : param.tolowercase();
soundon = soundactivation.equals("auto");
if((param = getparameter("sound.keystroke")) != null)
trycatch(exception e)
if((param = getparameter("sound.return")) != null)
trycatch(exception e)
if((param = getparameter("sound.bell")) != null)
trycatch(exception _ex)
param = getparameter("speed");
speed = param == null ?
100 : math.max(10, integer.parseint(param));
param = getparameter("target");
target = param == null ? "_self" : param;
if((param = getparameter("url")) != null)
trycatch(exception e)
param = getparameter("text");
text = param == null ?
"this is a test... /nthis is a test..." : param;
text = text.replace('//', '/n');
textfile = getparameter("textfile") ;
param = getparameter("update");
update = param == null ? 15 : integer.parseint(param);
buildlines();
trycatch(interruptedexception _ex)
}public void run()
for(int j = 0; j < linecount; j++)
catch(interruptedexception interruptedexception)
currentletter++;
}currentletter = 0;
currentline++;
alreadyrun = false;
}currentline = currentline % linecount;
trycatch(interruptedexception interruptedexception)
}public void paintbuffer(graphics g)
else
g.setcolor(textcolor);
g.setfont(font);
fontmetrics fontmetrics = g.getfontmetrics();
for(int i = 0; i < currentline; i++)
g.drawstring(
(string)lines.elementat(currentline - i - 1),
margin, depth - (i + 1) * fontmetrics.getheight()
);string s = (string)lines.elementat(currentline);
string s1 = currentletter >= s.length() ?
s : s.substring(0, currentletter);
if(fontmetrics.stringwidth(s1) > (8 * width) / 10
&& !alreadyrun && soundon)
g.drawstring(s1, margin, depth);
}public void paint(graphics g)
public void update(graphics g)
public void start()
}public void stop()
public boolean mouseenter(event event, int i, int j)
public boolean mouseexit(event event, int i, int j)
JQ實現打字機效果
目錄 一 前言 二 效果圖 三 本篇部落格記錄一下基於jquery實現的打字機效果 感興趣的可以一起學習學習。將下面 複製到html檔案中即可預覽效果。documenttitle head 這是一段打字機效果的文字 div script function else ele.html str.subs...
用js實現打字機效果
1.難得有點時間,回憶下古詩文,順便練習下js,實現下打字機效果 春江花月夜 張若虛 唐 春江潮水連海平,海上明月共潮生。灩灩隨波千萬里,何處春江無月明!江流宛轉繞芳甸,月照花林皆似霰 空裡流霜不覺飛,汀上白沙看不見。江天一色無纖塵,皎皎空中孤月輪。江畔何人初見月?江月何年初照人?人生代代無窮已,江...
CSS實現文字的打字機效果
本文章是完全通過html和css實現的打字機效果。在網上反覆查詢了挺多的資料,還看了挺多作者製作的打字機效果,感覺都沒達到自己想要的效果,就自己想了,一套思路。廢話不多說,邊看 邊解釋 此方法主要是通過給右邊框新增透明化和關鍵幀樣式,使其達到跳動游標的效果,文字部分通過 overflow hidde...