Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-22-2009, 07:57 AM   PM User | #1
Magicjax
New to the CF scene

 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Magicjax is an unknown quantity at this point
Disco Background effect to work with Text and Images

Hello everyone. I hope I'm posting this in the right place.

I'm using the Disco Background Effect script found here that causes the background color of the page to continuously change.

For my design I need other aspects of the page to change along with it. Such as some title Text and HR lines.

Is it possible to call this script to work on other things such as images, text and HR lines? In other words I want some text to change color in time with the background changing.

I appreciate any help you might have.

Ron
Magicjax is offline   Reply With Quote
Old 11-23-2009, 05:36 AM   PM User | #2
rubenbuhr
Regular Coder

 
Join Date: Oct 2006
Posts: 107
Thanks: 3
Thanked 5 Times in 5 Posts
rubenbuhr is an unknown quantity at this point
Well, maybe you can get a grip on this code instead?
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
>
<
HTML>
<
HEAD><TITLE>Su8-35pm49</TITLE>
<
META http-equiv=Content-Type content="text/html; charset=UTF-8">
<
STYLE type=text/CSS>


</
STYLE>
<
SCRIPT type="text/javascript">

 var 
steps=50;     var speed=50;     var tt;     var ck=steps;
 var 
oz='rgb('+newColor()+','+newColor()+','+newColor()+')';

function 
newColor(){return Math.round(Math.random()*255)}
function 
dif(a,b){return (Number(b)+Number(a))}
function 
fbgc(z){
    
oz='rgb('+newColor()+','+newColor()+','+newColor()+')';
    
n=oz.substring(4,oz.length-1).split(',');
    
document.body.style.backgroundColor=z;
    
o=z.substring(4,z.length-1).split(',');
    
e=[Math.round((n[0]-o[0])/steps),Math.round((n[1]-o[1])/steps),Math.round((n[2]-o[2])/steps)];
 
tt=setTimeout("fade()",speed)
}
function 
fade(){
    
d=[dif(e[0],o[0]),dif(e[1],o[1]),dif(e[2],o[2])]
    
z'rgb('+d[0]+','+d[1]+','+d[2]+')';
    
tz='rgb('+(255-d[0])+','+(255-d[1])+','+(255-d[2])+')'
    
document.body.style.backgroundColor=z;
    
o=z.substring(4,z.length-1).split(',');
 
ck--; 
 if(
ck != 0){    tt=setTimeout("fade()",speed)}
 else{
ck=stepsfbgc(z) }
document.getElementById('zcT').innerHTML='Background= '+z+'<BR>TextColor= '+tz+'';
document.getElementById('zcT').style.color=tz
}
</SCRIPT>
</HEAD>
<BODY scroll="auto" onload="fbgc(oz)">
<div id="zcT"></div><p>
<input type=button onclick="this.value=='stop'?clearTimeout(tt,this.value='go'):fade(this.value='stop');" value="stop">
</BODY></HTML> 

Last edited by rubenbuhr; 11-23-2009 at 05:52 AM.. Reason: negative numbers in rgb?
rubenbuhr is offline   Reply With Quote
Reply

Bookmarks

Tags
background, disco, effect, images, text

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:59 AM.


Advertisement
Log in to turn off these ads.