Site hosted by Angelfire.com: Build your free website today!










For more examples see www.huntingground.freeserve.co.uk complete with sound.

The script is set up for a six way light display. The lights are randomly generated with the exception that the same light is not shown twice in a row.
The text in red relates to one light source. If adding more lights variable count must be sequencial
At the line count=Math.round(Math.random()*5) this number must be 1 less than the total number of light effects.

Changes can be made to the lights effects by altering some of the integer values within the script.
Each colour is randomly generated within its own spectrum (ie dark red to light red).
See Notes
The following script allows you to create a display similar to the above.

<script language="javascript">
<!--
z=100
flash=0.75 // permanent flash.time light is off before next light is lit. higher flashrate leaves light on longer
timez=""
thisnum=0

function checknum(){ //prevent showing the same colour light in sequence. ie red after red
lastnum=thisnum
count=Math.round(Math.random()*5)
if(count==lastnum){
checknum()}
else{
thisnum=count
preview()
}
}

function preview(){
clearTimeout(timez)
red=100+Math.round(Math.random()*155)
green=100+Math.round(Math.random()*155)
blue=100+Math.round(Math.random()*155)

speed=50+Math.round(Math.random()*400) //100=minspeed, 100+400=maxspeed
//flash=0.1+Math.random()*0.9 // for random flash rate each run. higher flashrate leaves light on longer
flashrate=speed*flash // time light is off before next light is lit.

//count=Math.round(Math.random()*5) // transfered to function checknum

if(count==0){
document.all.test.filters.Light(1).addcone(50,70,z,50,70,0,green,0,100,90);
dim=setTimeout("clearme()",flashrate)
}

if(count==1){
document.all.test.filters.Light(1).addcone(150,70,z,150,70,green,green,0,100,90); //yellow
dim=setTimeout("clearme()",flashrate)
}
if(count==2){
document.all.test.filters.Light(1).addcone(250,70,z,250,70,red,0,0,100,90);
dim=setTimeout("clearme()",flashrate)
}
if(count==3){
document.all.test.filters.Light(1).addcone(350,70,z,350,70,0,0,blue,100,90);
dim=setTimeout("clearme()",flashrate)
}

if(count==4){
document.all.test.filters.Light(1).addcone(450,70,z,450,70,red,0,blue,100,90);
dim=setTimeout("clearme()",flashrate)
}
if(count==5){
document.all.test.filters.Light(1).addcone(550,70,z,550,70,red,green,blue,100,90);
dim=setTimeout("clearme()",flashrate)
}

timez=setTimeout("checknum()",speed)
}

function clearme(){
test.filters.Light(1).clear();
document.all.test.filters.Light(0).Addambient(50,50,50,50) // colour and intensity of background light
return
}

setTimeout("checknum()",1000)
// -->
</script>

<div id="test" style="position:absolute;left:80; top:100;filter:Light(1);width:600;height:140;background-color:white; border:10 ridge black;text-align:center;font-size:100"></div>

Notes:
Javascript counts from zero.
The maximum value you can have for a color is 255 so minimum + multiplier should always be equal to 255.

red=50+Math.round(Math.random()*205)

Some integer values only need slight changes to make a big difference to the light effect.
With respect to the addcone filter variables z and spread require only small changes

addcone(x1, y1, z, x2, y20, red, green, blue, strength, spread)

In this example z = 100 and spread = 90
In Example 2 z = 100 and spread = 30

For more information about the addcone filter see Addcone

For more information about the ambient filter see Ambient