Menu
Hi all,
If I have a grid / wall of 6 x 6 black squares, and I wanted them to change colour in a random way, one at a time. Has anyone seen any JQuery / JavaScript code for this type of animation?
Sorry to be a bit bleak, it would sort of be like the Close Encounters ending!! LOL!! ?
Regards,
Daz.
[CODE]function Rnd(w) {return parseInt(Math.random() * (w + 1));}
function rndcol() { return Rnd(255).toString(16);}
function rndcolor(){ return "#" + rndcol() + rndcol() + rndcol() ;}[/CODE]
[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Close Encounters Animation</title>
<style type="text/css">
body {
background-color: #000000;
}
.wrapper {
padding: 5px;
margin: 5px;
border: 1px solid #999;
width: 720px;
height: 120px;
}
.row {
clear: both;
height: 15%;
margin: 0;
padding: 0;
}
.cell {
float: left;
height: 100%;
width: 16.38%;
margin: 0;
border: 1px solid #111;
background-color: #000000;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]= function(fx){if ( fx.state == 0 ){fx.start = getColor( fx.elem,attr );fx.end = getRGB( fx.end );}fx.elem.style[attr]= "rgb(" + [Math.max(Math.min( parseInt((fx.pos * (fx.end[0]- fx.start[0]))+ fx.start[0]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[1]- fx.start[1]))+ fx.start[1]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[2]- fx.start[2]))+ fx.start[2]),255),0)].join(",")+ ")";}});function getRGB(color){var result;if ( color && color.constructor == Array && color.length == 3 )return color;if (result = /rgb(s*([0-9]{1,3})s*,s*([0-9]{1,3})s*,s*([0-9]{1,3})s*)/.exec(color))return [parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if (result = /rgb(s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*)/.exec(color))return [parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return [parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return [parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}function getColor(elem,attr){var color;do {color = jQuery.curCSS(elem,attr);if ( color != '' && color != 'transparent' || jQuery.nodeName(elem,"body"))break;attr = "backgroundColor";}while ( elem = elem.parentNode );return getRGB(color);};var colors = {aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);
</script>
<script type="text/javascript">
var o_timer, n_interval;
//Set the colour change interval in milliseconds:
n_interval = 200;
function randomize(mini, maxi) {
return Math.round(Math.random() * (maxi - mini)) + mini;
}
function toHex(n) {
var nlz = n.toString(16);
return nlz.length == 2 ? nlz : '0' + nlz;
}
function randomColor() {
return '#' + toHex(randomize(150, 255)) + toHex(randomize(150, 255)) + toHex(randomize(0, 200));
}
function changeColour() {
var cells = $('.cell'), cl = cells.length, cn = randomize(0, cl - 1);
$($('.cell')[cn]).animate( { backgroundColor : randomColor() }, 100)
.animate( {backgroundColor : '#000000'}, 1000);
}
$(document).ready(function () {
o_timer = setInterval("changeColour()", n_interval);
});
</script>
</head>
<body>
<div class="wrapper">
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
</div>
</body>
</html>[/code]
[CODE]function changeColour(row, column) {
var cn = ((row - 1) * 6) + (column - 1);
$($('.cell')[cn]).animate( { backgroundColor : randomColor() }, 100)
.animate( {backgroundColor : '#000000'}, 1000);
}[/CODE]
[Code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Close Encounters Animation</title>
<style type="text/css">
body {
background-color: #000000;
}
.wrapper {
padding: 5px;
margin: 5px;
border: 1px solid #999;
width: 410px;
height: 210px;
}
.row {
clear: both;
height: 50px;
margin: 0;
padding: 0;
}
.cell {
float: left;
height: 50px;
width: 100px;
margin: 0;
border: 1px solid #FFF;
background-color: #000000;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]= function(fx){if ( fx.state == 0 ){fx.start = getColor( fx.elem,attr );fx.end = getRGB( fx.end );}fx.elem.style[attr]= "rgb(" + [Math.max(Math.min( parseInt((fx.pos * (fx.end[0]- fx.start[0]))+ fx.start[0]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[1]- fx.start[1]))+ fx.start[1]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[2]- fx.start[2]))+ fx.start[2]),255),0)].join(",")+ ")";}});function getRGB(color){var result;if ( color && color.constructor == Array && color.length == 3 )return color;if (result = /rgb(s*([0-9]{1,3})s*,s*([0-9]{1,3})s*,s*([0-9]{1,3})s*)/.exec(color))return [parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if (result = /rgb(s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*)/.exec(color))return [parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return [parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return [parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}function getColor(elem,attr){var color;do {color = jQuery.curCSS(elem,attr);if ( color != '' && color != 'transparent' || jQuery.nodeName(elem,"body"))break;attr = "backgroundColor";}while ( elem = elem.parentNode );return getRGB(color);};var colors = {aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);
</script>
<script type="text/javascript">
var o_timer, n_interval;
//Set the colour change interval in milliseconds:
n_interval = 900;
function randomize(mini, maxi) {
return Math.round(Math.random() * (maxi - mini)) + mini;
}
function toHex(n) {
var nlz = n.toString(16);
return nlz.length == 2 ? nlz : '0' + nlz;
}
function randomColor() {
return '#' + toHex(randomize(150, 255)) + toHex(randomize(150, 255)) + toHex(randomize(0, 200));
}
/*
function changeColour() {
var cells = $('.cell'), cl = cells.length, cn = randomize(0, cl - 1);
$($('.cell')[cn]).animate( { backgroundColor : randomColor() }, 100)
.animate( {backgroundColor : '#000000'}, 1000);
}*/
function changeColour(row, column) {
var cn = ((row - 1) * 4) + (column - 1);
$($('.cell')[cn]).animate( { backgroundColor : randomColor() }, 100)
.animate( {backgroundColor : '#000000'}, 1000);
}
$(document).ready(function () {
o_timer = setInterval("changeColour()", n_interval);
});
</script>
</head>
<body>
<div class="wrapper">
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
</div>
</body>
</html>
[/Code]
[Code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Close Encounters Animation</title>
<style type="text/css">
body {
background-color: #2a2a2a;
}
.wrapper {
padding: 15px;
margin: 10px;
border: 2px solid #111;
width: 635px;
height: 230px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
background-color: #222;
}
.row {
clear: both;
height: 50px;
margin: 0;
padding: 0;
}
.cell {
float: left;
height: 50px;
width: 150px;
margin: 1px;
border: 3px solid #111;
background-color: #191919;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]= function(fx){if ( fx.state == 0 ){fx.start = getColor( fx.elem,attr );fx.end = getRGB( fx.end );}fx.elem.style[attr]= "rgb(" + [Math.max(Math.min( parseInt((fx.pos * (fx.end[0]- fx.start[0]))+ fx.start[0]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[1]- fx.start[1]))+ fx.start[1]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[2]- fx.start[2]))+ fx.start[2]),255),0)].join(",")+ ")";}});function getRGB(color){var result;if ( color && color.constructor == Array && color.length == 3 )return color;if (result = /rgb(s*([0-9]{1,3})s*,s*([0-9]{1,3})s*,s*([0-9]{1,3})s*)/.exec(color))return [parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if (result = /rgb(s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*)/.exec(color))return [parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return [parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return [parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}function getColor(elem,attr){var color;do {color = jQuery.curCSS(elem,attr);if ( color != '' && color != 'transparent' || jQuery.nodeName(elem,"body"))break;attr = "backgroundColor";}while ( elem = elem.parentNode );return getRGB(color);};var colors = {aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);
</script>
<script type="text/javascript">
var o_timer, n_interval;
//Set the colour change interval in milliseconds:
n_interval = 900;
function randomize(mini, maxi) {
return Math.round(Math.random() * (maxi - mini)) + mini;
}
function toHex(n) {
var nlz = n.toString(16);
return nlz.length == 2 ? nlz : '0' + nlz;
}
function randomColor() {
return '#' + toHex(randomize(150, 255)) + toHex(randomize(150, 255)) + toHex(randomize(0, 200));
}
/*
function changeColour() {
var cells = $('.cell'), cl = cells.length, cn = randomize(0, cl - 1);
$($('.cell')[cn]).animate( { backgroundColor : randomColor() }, 100)
.animate( {backgroundColor : '#191919'}, 1000);
}
*/
function changeColor(row, column) {
var cn = ((row - 1) * 4) + (column - 1);
$($('.cell')[cn]).animate( { backgroundColor : randomColor() }, 100)
.animate( {backgroundColor : '#191919'}, 1000);
}
/*$(document).ready(function () {
o_timer = setInterval("changeColor()", n_interval);
});*/
</script>
</head>
<body>
<div class="wrapper">
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
</div>
</body>
</html>
[/Code]
[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Close Encounters Animation</title>
<style type="text/css">
body {
background-color: #000000;
}
.wrapper {
padding: 5px;
margin: 5px;
border: 1px solid #999;
width: 720px;
height: 120px;
}
.row {
clear: both;
height: 23.8%;
margin: 0;
padding: 0;
}
.cell {
float: left;
height: 100%;
width: 24.7%;
margin: 0;
border: 1px solid #111;
background-color: #000000;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]= function(fx){if ( fx.state == 0 ){fx.start = getColor( fx.elem,attr );fx.end = getRGB( fx.end );}fx.elem.style[attr]= "rgb(" + [Math.max(Math.min( parseInt((fx.pos * (fx.end[0]- fx.start[0]))+ fx.start[0]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[1]- fx.start[1]))+ fx.start[1]),255),0),Math.max(Math.min( parseInt((fx.pos * (fx.end[2]- fx.start[2]))+ fx.start[2]),255),0)].join(",")+ ")";}});function getRGB(color){var result;if ( color && color.constructor == Array && color.length == 3 )return color;if (result = /rgb(s*([0-9]{1,3})s*,s*([0-9]{1,3})s*,s*([0-9]{1,3})s*)/.exec(color))return [parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if (result = /rgb(s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*,s*([0-9]+(?:.[0-9]+)?)%s*)/.exec(color))return [parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return [parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return [parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}function getColor(elem,attr){var color;do {color = jQuery.curCSS(elem,attr);if ( color != '' && color != 'transparent' || jQuery.nodeName(elem,"body"))break;attr = "backgroundColor";}while ( elem = elem.parentNode );return getRGB(color);};var colors = {aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);
</script>
<script type="text/javascript">
var o_sequence, b_runAnimation = true, i_count = 0;
a_sequence = [
{
'color' : 'yellow',
'row' : 2,
'column' : 2,
'length' : 400
},
{
'color' : 'green',
'row' : 3,
'column' : 3,
'length' : 400
},
{
'color' : 'blue',
'row' : 3,
'column' : 1,
'length' : 400
},
{
'color' : 'white',
'row' : 1,
'column' : 4,
'length' : 400
},
{
'color' : 'orange',
'row' : 4,
'column' : 2,
'length' : 1200
},
{
//a short pause
'color' : 'black',
'row' : 1,
'column' : 1,
'length' : 800
}
]
function changeColour() {
var cells = $('.cell'), seqNo = a_sequence[i_count],
cellNo = ((seqNo.row - 1) * $('.row:first .cell').length) + (seqNo.column - 1);
if (b_runAnimation) {
$(cells[cellNo]).animate( { backgroundColor : seqNo.color }, 100)
.animate( {backgroundColor : '#000000'}, {
duration : seqNo.length,
complete : function() {
i_count++;
if (i_count > (a_sequence.length - 1)) i_count = 0;
changeColour();
}
});
} else {
i_count = 0;
}
}
$(document).ready(function () {
changeColour();
});
</script>
</head>
<body>
<div class="wrapper">
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
<div class="cell"> </div>
</div>
</div>
</body>
</html>
[/code]
0.1.9 — BETA 6.16