Advertisement
Guest User

draw.html

a guest
Oct 25th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <style>
  2. *{overflow:hidden;
  3. margin:0px;
  4. padding:0px;}
  5.  
  6. #myCanvas{
  7. margin:0px;
  8. padding:0px;
  9. width:100%;
  10. height:100%;
  11. overflow-y:hidden;
  12. }
  13. </style>
  14.  
  15. <canvas id="myCanvas" height="2250px" width="4000px" >
  16.  
  17. <script >
  18.  
  19. window.switch=0;
  20. var c = document.getElementById("myCanvas");
  21. var ctx = c.getContext("2d");
  22. X=0;
  23. Y=0;
  24. document.getElementById("myCanvas").addEventListener("mousedown",function(){X=0;Y=0;window.switch=0;document.onmousemove=Mpos});
  25.  
  26.  
  27. function Mpos(e) {
  28. if(window.switch==0)
  29. {
  30. x= e.pageX
  31. y = e.pageY
  32. if(!X)
  33. {
  34. X=x;
  35. }
  36. if(!Y)
  37. {
  38. Y=y;
  39. }
  40. ctx.beginPath();
  41. ctx.moveTo(4000/document.body.clientWidth*X,2250/document.body.clientHeight*Y);
  42. ctx.lineTo(4000/document.body.clientWidth*x,2250/document.body.clientHeight*y);
  43. ctx.strokeStyle="rgb("+Math.round(Math.random()*1000%255)+","+Math.round(Math.random()*1000%255)+","+Math.round(Math.random()*1000%255)+")";
  44. ctx.lineWidth=(Math.round(Math.random()*100%50+1));
  45. ctx.stroke();
  46. X=x;
  47. Y=y;
  48. }
  49. }
  50. document.getElementById("myCanvas").addEventListener("mouseup",function(){window.switch=1;})
  51. alert(document.body.clientWidth);
  52.  
  53. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement