Animation: mouse doodle : JavaScript DHTML examples (example source code) » GUI Components » Animation

JavaScript DHTML










Java Products
Java Articles
JavaScript DHTML Home  »   GUI Components   » [  Animation  ]   

 
Animation: mouse doodle

Please note that some example is only working under IE or Firefox.

//Mouse Doodle 2  - http://www.btinternet.com/~kurt.grigg/javascript

/*
Paste this link between the body tags of your page.

<script type="text/javascript" src="mousedoodle2.js"></script>

To edit, right click on the mousedoodle2.js file icon and choose edit.
*/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<title>Mouse Doodle 2</title>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">

<style type="text/css">
<!--
body{
background-color : #000000;
}
//-->
</style>

</head>
<body>

<script type="text/javascript">
//Mouse Doodle 2  - http://www.btinternet.com/~kurt.grigg/javascript

if ((typeof window.event&&
window.attachEvent &&
document.getElementById &&
document.firstChild && 
document.firstChild.filters){

(function(){
var colours = new Array("#ff0000","#00ff00","#ffffff","#ff00ff","#ffff00","#00aaff","#ffa500");
var n = colours.length;
var dy = 0;
var dx = 0;
var ry = 0;
var rx = 0;
var v1 = 0.08;
var v2 = 0;
var y = 0;
var x = 0;
var ref = [];
var pulseCounter = [];
var pulsePath = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,30,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1];
var pulse = [];
var d = document;
var ref2;

if (d.documentElement && 
typeof d.documentElement.clientWidth == "number" && 
d.documentElement.clientWidth != 0)
ref2 = d.documentElement;
else
 if (d.body && 
 typeof d.body.clientWidth == "number")
 ref2 = d.body;
}

var idx = document.getElementsByTagName('div').length;
var pix = "px";

document.write('<div id="con'+idx+'" style="position:absolute;top:0px;left:0px;">'
+'<div style="position:relative">');

for (i = 0; i < n; i++){
document.write('<div id="lights'+(idx+i)+'" style="position:absolute;'
+'top:0px;left:0px;height:50px;width:50px;font-family:Courier New;'
+'font-size:10px;color:#ffffff;padding-top:18px;text-align:center">.<\/div>');
}

document.write('<\/div><\/div>');

for (i = 0; i < n; i++){
ref[i= document.getElementById("lights"+(idx+i)).style;
pulseCounter[i= i * 4;
}

function mouse(){
y = window.event.clientY;
x = window.event.clientX - 16;
}
document.attachEvent("onmousemove",mouse);

function stars(){
for (i = 0; i < n; i++){
 pulseCounter[i]++;
 if (pulseCounter[i>= pulsePath.length){
  pulseCounter[i0
 }
 pulse[i= pulsePath[pulseCounter[i]];
 ref[i].filter = 'glow(color='+colours[i]+', strength='+pulse[i]+')';
 ref[i].top = ry + Math.cos((20*Math.sin(v2/20))+i*70)*100*(Math.sin(10+v2/10)+0.2)*Math.cos((v2+i*25)/10+ pix; 
 ref[i].left = rx + Math.sin((20*Math.sin(v2/20))+i*70)*180*(Math.sin(10+v2/10)+0.2)*Math.cos((v2+i*25)/10+ pix; 
}
v2 += v1;
document.getElementById("con"+idx).style.top = ref2.scrollTop + pix; 
}

function delay(){
ry = dy += (y-dy0.05;
rx = dx += (x-dx0.05;
stars();
setTimeout(delay,40);
}
delay();
})();
}
</script>

</body>
</html>
Related examples in the same category
1.  Circle Animation
2.  Right to left animation
3.  Flash animation in Javascript
4.  Flash animation in JavaScript: Changing style Properties
5.  Animation along Straight Line
6.  Animation along a Circle
7.  Dancing Text (IE)
8.  Type Writer effect (IE)
9.  Type Writer Effect 1.1 (IE)
10.  JavaScript Ticker 1.2 (IE)
11.  Animation: Lottery Number Picker and Statistics
12.  Animation: wriggly
13.  Animation: welcome message
14.  Animation: trio
15.  Auto lotto dip
16.  Animation: snow
17.  Animation: star
18.  Animation: fireworks
19.  Animation: pretty
20.  Animation: Random Movement
21.  Lotto number draw
22.  Following eyes
23.  Animation: three eyes
24.  Animation: eyes
25.  Spot light
26.  Big static eyes
27.  Animation based on DIV with color flash
28.  Framework for creating CSS-based animations
29.  Animate dynamic element h1 tag
30.  Popup window animation (fly across screen)
31.  Animation on several images
32.  Using the onFilterChange Event Handler
33.  JavaScript Animation
34.  Periodically Updating the Text Displayed by an HTML Element
35.  Moving an Airplane Across a Web Page
36.  Link Hint Scroller 2.0 (IE)








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.