Jump to content

Upside down Javascrip equalizer


law

Recommended Posts

OK, I found this javascript equalizer. It woks great. I cut it all up with php. I intend to make it easily editable. I am awful with javascript. I can't figure out how to flip this code. I would like the equalizer to operate upside down. The effect would look similar to filter: flipv; except be cross browser compatible.

 

<?php
//Number of Cols
$col = 10;
//0 is the starting number
$cols = $cols - 1;
//Number of Rows
$row = 10;
?>
<html>
<head>
<script language="JavaScript">
<!--
color=new Array();
<?php
for ($i=0;$i<$col;$i++){
?>
color[<?php echo $i;?>]="blue.gif";
<?php
}
?>

h=new Array();
for(var i=0;i<<?php echo $col;?>;i++)
  h[i]=-1;

function d_rand()
{
  for(var i=0;i<<?php echo $col;?>;i++)
  {
    var h_old=h[i];
    var sgn=1;
    var rndm=0;
    if(h[i]==-1)
    {
      h[i]= Math.floor(Math.random()*10)
      h_old=9;
    }
    else
    {
      rndm=Math.floor(Math.random()*3);
      sgn=Math.floor(Math.random()*2);
      if(sgn==0)
      {
        var h_old=h[i]
        h[i]+=rndm;
        if(h[i]>9) 
          h[i]=9;
      }
      else
      {
        var h_old=h[i]
        h[i]-=rndm;
        if(h[i]<0) 
          h[i]=0;
      }
    }
    if(sgn==0)
    {
      for(var j=h_old;j<=h[i];j++)
        document.images[i+j*<?php echo $col;?>].src = "black.gif";          
    }
    else
    {
      for(var j=h_old;j>=h[i];j--)
        document.images[i+j*<?php echo $col;?>].src = color[i];          
    }

  }    
  timerId=setTimeout("d_rand()",270)
}
//-->
</script>
<title>UpsideDown - JavaScript - Equalizer</title>
</head>

<body onload="d_rand()" bgcolor="Black" leftmargin=30 text="White" marginwidth=30 vlink=silver>

<table border="0" cellspacing="0" cellpadding="0">
<?php
for ($i=0;$i<$row;$i++){
?>
	<tr>
	<?php 
	for ($ii=0;$ii<$col;$ii++){
	?>
		<td><img src="black.gif" width="40" height="20"></td>
	<?php
	}
	?>
	</tr>
<?php
}
?>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.