Planet Shake
You are watching the site as a guest to see everything that gets offered register for free or log in....or take a look around on the few things that you can see as a guest.....

Planet Shake

Discover Your World Here !
 
HomeHome  PortalPortal  GalleryGallery  FAQFAQ  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Disco background color - really great.

View previous topic View next topic Go down 
AuthorMessage
jimzstone
Moderator
Moderator


Posts : 67
Points : 2882
Reputation : 2
Join date : 2009-02-19
Age : 25
Location : Laguna

Planet Shake
huo: 4

PostSubject: Disco background color - really great.   Fri Feb 20, 2009 12:14 am

This code gives a disco bg.the color changes for every second.

Copy this code

Code:
<script language="Javascript">
<!--
//brought to you by (YOUR NAME HERE)
//you can assign the initial color of the background here
r=255;
g=255;
b=255;
flag=0;
t=new Array;
o=new Array;
d=new Array;

function hex(a,c)
{
t[a]=Math.floor(c/16)
o[a]=c%16
switch (t[a])
{
case 10:
t[a]='A';
break;
case 11:
t[a]='B';
break;
case 12:
t[a]='C';
break;
case 13:
t[a]='D';
break;
case 14:
t[a]='E';
break;
case 15:
t[a]='F';
break;
default:
break;
}
switch (o[a])
{
case 10:
o[a]='A';
break;
case 11:
o[a]='B';
break;
case 12:
o[a]='C';
break;
case 13:
o[a]='D';
break;
case 14:
o[a]='E';
break;
case 15:
o[a]='F';
break;
default:
break;
}
}

function ran(a,c)
{
if ((Math.random()>2/3||c==0)&&c<255)
{
c++
d[a]=2;
}
else
{
if ((Math.random()<=1/2||c==255)&&c>0)
{
c--
d[a]=1;
}
else d[a]=0;
}
return c
}
function do_it(a,c)
{
if ((d[a]==2&&c<255)||c==0)
{
c++
d[a]=2
}
else
if ((d[a]==1&&c>0)||c==255)
{
c--;
d[a]=1;
}
if (a==3)
{
if (d[1]==0&&d[2]==0&&d[3]==0)
flag=1
}
return c
}
function disco()
{
if (flag==0)
{
r=ran(1, r);
g=ran(2, g);
b=ran(3, b);
hex(1,r)
hex(2,g)
hex(3,b)
document.body.style.background="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3]
flag=50
}
else
{
r=do_it(1, r)
g=do_it(2,g)
b=do_it(3,b)
hex(1,r)
hex(2,g)
hex(3,b)
document.body.style.background="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3]
flag--
}

setTimeout('disco()',50)
}
//-->
</script><body onload="disco()">
Back to top Go down
View user profile http://www.friendster.com/12252675
 
Disco background color - really great.
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Background-color:
» Icons Mix background
» Solved: Navigation Bar Background Color
» How to take the screen shot? when i set a kwargs, it is showing error... when i not set kwargs it is coming black color as background
» Mario Background

Permissions in this forum:You cannot reply to topics in this forum
Planet Shake :: Tutorials :: Scripting-
Jump to:  
Make a forum | © phpBB | Free forum support | Contact | Report an abuse | Free forum