Closed Thread Icon

Preserved Topic: help with a script (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18201" title="Pages that link to Preserved Topic: help with a script (Page 1 of 1)" rel="nofollow" >Preserved Topic: help with a script <span class="small">(Page 1 of 1)</span>\

 
kars10
Bipolar (III) Inmate

From: Europe
Insane since: Mar 2001

posted posted 06-23-2001 21:03

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

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-24-2001 00:43

You may be interested in knowing this:

(15).toString(16) will return "F" - it converts from base 10 to the base in the parens.

parseInt("F", 16) will return 15 - it converts from the base specified to base 10.

Thanks to Max for that info.

JakeB
Paranoid (IV) Inmate

From: us
Insane since: Oct 2000

posted posted 06-24-2001 03:40

i get a 404

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 06-24-2001 08:30

error 404: Datei nicht gefunden!

kars10
Bipolar (III) Inmate

From: Europe
Insane since: Mar 2001

posted posted 06-24-2001 08:40

sorry guyd, i messed up uploading it. i'll have to change that tomorros. thanl for the string thingy!
k10

« BackwardsOnwards »

Show Forum Drop Down Menu