ok, I worked on a background changing script I found in the net. It is my way to try to figure it out and if possible make it even better. well, I understand it now, but it doesn't seem 'graceful' enough.
It boils down to that. each hex number has to go through a couple of functions (increasing it, converting it and changing the bgColor) Instead of sending all three of them through it, I want that those modifing functions are called three times (on for each hexnumber). the value returns and the background color is changed.
This is the script up til now. I will work on it also, to make this peace graceful, but a some tipps from the gurus wouldn't hurt, of course! *g*: (the page is published at www.kars10.de/BGcolor2.htm )
script <shortened>:
<script language="JavaScript" type="text/JavaScript">
//globals
hexa = new makearray(16);
for(var i = 0; i < 10; i++){hexa[i] = i;}
hexa[10]="a";
hexa[11]="b";
hexa[12]="c";
hexa[13]="d";
hexa[14]="e";
hexa[15]="f";
//starter
bgf();
function bgf()
{
var br=256; var er=0; var sr=100; var dr=(br-er)/sr;
var bg=256; var eg=0; var sg=100; var dg=(bg-eg)/sg;
var bb=256; var eb=0; var sb=100; var db=(bb-eb)/sb;
var w=10;
var cr=br;
var cg=bg;
var cb=bb;
id="bgColor";
var xr=1;
var xg=1;
var xb=1;
fade(id,br,bg,bb,sr,sg,sb,dr,dg,db,cr,cg,cb,xr,xg,xb,w);
/*remeber this note here*/
}
function fade(id,br,bg,bb,sr,sg,sb,dr,dg,db,cr,cg,cb,xr,xg,xb,w)
{
if(sr>0){cr=br-Math.floor(dr*xr); sr--;xr++;}
if(sg>0){cg=bg-Math.floor(dg*xg); sg--;xg++;}
if(sb>0){cb=bb-Math.floor(db*xb); sb--;xb++;}
setbgColor(id,br,bg,bb,sr,sg,sb,dr,dg,db,cr,cg,cb,xr,xg,xb,w);
}
function setbgColor(id,br,bg,bb,sr,sg,sb,dr,dg,db,cr,cg,cb,xr,xg,xb,w)
{
var hr = hex(cr);var hg = hex(cg); var hb = hex(cb);
eval("document." +id+ "='#'+hr+hg+hb");
setTimeout('fade("'+id+'",'+br+','+bg+','+bb+','+sr+','+sg+','+sb+','+dr+','+dg+','+db+','+cr+','+cg+','+cb+','+xr+','+xg+','+xb+','+w+')',w);
}
function hex(aw)
{
if (aw < 0){return "00";}
else if (aw > 255){return "ff";}
else{return "" + hexa[Math.floor(aw/16)] + hexa[aw%16];}
}
//utilities
function makearray(n)
{
this.length = n;
for(var i = 1; i <= n; i++){this[i] = 0;}
return this;
}
</script>
well, remember that note up there? that's were the solution begins, I think. Since I have been working on it for hours to change it down to this, I will now have some sleep and await you guys tips. I hae an idea but my brain is fried.
k10