agam360 -1 Light Poster

Here is my code:
the problem is that the arcs are not painted in the same position that the mouse is...

So I tried to center it so I could take off 0.25 of the document so it will be precise, but It didn't work:

<html> 
<head> 
	<title>My AWESOME website...</title> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<style type="text/css"> 
  canvas { 
	width:50%;
	height:50%;
	position:absolute;
	left:50%;
	top:50%;
	margin:-25% 0 0 -25%;
	border:1 solid black;
}
</style> 
</head> 
<body> 
<h2 id="status"> 
0, 0
</h2> 

<h3 id="numb">0</h3> 
<canvas id="myCanvas" width="1000" height="1000"></canvas> 
<script type="text/javascript"> 
 
jQuery(document).ready(function(){
var dWidth = $(document).width() ;
var dHeight= $(document).height() ;
 canvas = document.getElementById('myCanvas');
 context = canvas.getContext('2d');
 var numB = 0;
	

   $(document).mousedown(function(e){
   $(document).mousemove(function(e){
   
   
   $('#status').html(e.pageX +', '+ e.pageY);
    var col = new Array(); 
	col[0]="#FF0000";       
	col[1]="#FFFF00";
	col[2]="#00FF00";
	col[3]="#00FFFF";       
	col[4]="#0000FF";
	col[5]="#FF00FF";
	
 
    
	context.beginPath();
	context.fillStyle=col[Math.round(Math.random()*6)];
	context.arc(e.pageX-dWidth*0.25,e.pageY-dHeight*0.25, Math.round(Math.random()*25),0,Math.PI*2,true);
	context.fill();
	numB++;
	$("#numb").html("Number of cicles:"+numB);
	
   });
   });
})
</script> 
</body> 
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.