...

View Full Version : Text Fader



premshree
08-25-2002, 07:56 PM
"Text Fader" JavaScript fades the text you want from a start color to end color.

See example here :
http://www.qiksearch.com/javascripts/text-fader.htm



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Text Fader</title>
<!--BEGIN TEXT FADER JAVASCRIPT-->
<script language="JavaScript">
// Text Fader JavaScript
// By Premshree Pillai
// http://www.qiksearch.com

/* call the function wherever you want to fade the text
in the body section. See the body section code */

/* No need to edit from here */
var TF_hexChars=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");

function TF_dec2hex(decVal)
{
return(TF_hexChars[decVal>>4]+TF_hexChars[decVal&15]);
}

function TF_hex2dec(hexVal)
{
return(parseInt(hexVal,16))
}

function TextFade(TF_text,TF_font,TF_fontSize,TF_isBold,TF_isItalic,intColor,finalColor)
{
var TF_isBold_content;
var TF_isItalic_content;
var TF_isBold_end_content;
var TF_isItalic_end_content;
var TF_text_arr=TF_text.split("");
var rVal=TF_hex2dec(intColor.slice(1,3));
var gVal=TF_hex2dec(intColor.slice(3,5));
var bVal=TF_hex2dec(intColor.slice(5,7));
var r_step=Math.ceil((TF_hex2dec(finalColor.slice(1,3))-rVal)/(TF_text_arr.length));
var g_step=Math.ceil((TF_hex2dec(finalColor.slice(3,5))-gVal)/(TF_text_arr.length));
var b_step=Math.ceil((TF_hex2dec(finalColor.slice(5,7))-bVal)/(TF_text_arr.length));
if(TF_isBold)
{
TF_isBold_content="<b>";
TF_isBold_end_content="</b>";
}
else
{
TF_isBold_content="";
TF_isBold_end_content="";
}
if(TF_isItalic)
{
TF_isItalic_content="<i>";
TF_isItalic_end_content="</i>";
}
else
{
TF_isItalic_content="";
TF_isItalic_end_content="";
}
for(var i=1; i<=TF_text_arr.length; i++)
{
document.write('<font color="#' + TF_getColor(rVal,gVal,bVal,r_step,g_step,b_step) + '" face="' + TF_font + '" size="' + TF_fontSize + '">' + TF_isBold_content + TF_isItalic_content + TF_text_arr[i-1] + TF_isItalic_end_content + TF_isBold_end_content + '</font>');
if(TF_text_arr[i]!=" ")
{
rVal+=r_step;
gVal+=g_step;
bVal+=b_step;
}
}
}

function TF_getColor(rcol,gcol,bcol,rstep,gstep,bstep)
{
rcol+=rstep;
gcol+=gstep;
bcol+=bstep;
return(TF_dec2hex(rcol)+TF_dec2hex(gcol)+TF_dec2hex(bcol));
}
</script>
<!--END TEXT FADER JAVASCRIPT-->
</head>
<body bgcolor="#FFFFFF">

<center>
<!--BEGIN BODY SECTION CODE-->
<script language="JavaScript">
new TextFade('Text Fader JavaScript','verdana,arial,helvetica','5pt',true,false,'#DDDDFF','#000066');</script>
<!--END BODY SECTION CODE-->
</center>

</body>
</html>


:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum