sc********@gmail.com wrote:
Lee wrote:
It's all done the hard way. It may be old enough that RegExp
couldn't be trusted to exist/work on all platforms, but
Number.toString(16) has been around for a long time.
YES! Its all done possibly the worst way. I've never saw SO DUMB code.
Things do change rapidly on the web. Let us start with a script from
1996.
1996 original
// Michael P. Scholtis (mp****@planetx.bloomu.edu) // All rights
reserved. January 15, 1996 // You may use this JavaScript example as
you see fit, as long as the // information within this comment above is
included in your script. function MakeArray(n){ this.length=n; for(var
i=1; n>=i; i++) this[i]=i-1; return this } hex=new MakeArray(16);
hex[11]="A"; hex[12]="B"; hex[13]="C"; hex[14]="D"; hex[15]="E";
hex[16]="F"; function ToHex(x){ // Changes a int to hex (in the range 0
to 255) var high=x/16; var s=high+""; //1 s=s.substring(0,2); //2 the
combination of these are the same as the trunc function
high=parseInt(s,10); //3 var left=hex[high+1]; // left part of the
hex-value var low=x-high*16; // calculate the rest of the values
s=low+""; //1 s=s.substring(0,2); //2 the combination of these are the
same as the trunc function low=parseInt(s,10); //3 var
right=hex[low+1]; // right part of the hex-value var
string=left+""+right; // add the high and low together return string; }
function rainbow(text){ text=text.substring(3,text.length-4); // gets
rid of the HTML-comment-tags color_d1=255; // any value in 'begin' 0 to
255 mul=color_d1/text.length; for(i=0;text.length i;i++){
color_d1=255*Math.sin(i/(text.length/3)); // some other things you can
try >"=255-mul*i" to fade out, "=mul*i" to fade in, or try
"255*Math.sin(i/(text.length/3))" color_h1=ToHex(color_d1);
color_d2=mul*i; color_h2=ToHex(color_d2);
document.write(""+text.substring(i,i+1)+"<\/font>"); } } // --End
Hiding Here -- This is a rainbow text effect which you may upload to
your own site and use as you wish. Unfortunately you can only add about
10 lines of text here and then you have to use the code over again in
the next paragraph. You only need to use the code that's in the body
tag over again, not the part in the head tag. Let's see what happens
here if I continue to add text and see if it continues to change the
color of the text. And I'll just ramble on here a little more so you
can see the effect here and how it changes the text color. Cool effect
Huh!
Sorry the above has had white space removed. Note that it has hex
conversion. Now, if we consider the head script, we find that if we use
r,g,b colors instead of hex, we can avoid the hex conversion
completely, and the head script can be written:
js/rt.
/* Written by
cw****@webtv.net in Feb. 2003 */
function paint(blah){
var x; var i; var c1=255; var x=blah.length; var f=c1/x; var c0=255;
for (i=0;x>i;i++){
c1=255*Math.round(Math.sin(i/(x/3))); var c2=Math.round(f*i);
document.write('<span style="color:
rgb('+c0+','+c1+','+c2+')">'+blah.substring(i,i+1) +'<\/span>');
}
}
The revised page using the above head script is at:
http://www.cwdjr.net/text/RainbowText.html . Today you can thus save a
huge amount of code.
This page shows age. All we need is a midi of the Beatle's "Lucy In The
Sky" and a few dancing cow animated gifs to make the page true to that
long gone era.