Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. const mouse = {
  2. x: undefined,
  3. y: undefined,
  4. }
  5.  
  6. $('#canvas').mousemove(function(){
  7. mouse.x = event.x
  8. mouse.y = event.y
  9. })
  10.  
  11. let circleArray = []
  12.  
  13. //Create circles based on how long you hold the mouse down
  14. let timer = 0
  15. $('#canvas').mousedown(function () {
  16. timer = new Date()
  17. }).mouseup(function () {
  18. let timePassed = (new Date () - timer)/10
  19. if(timePassed > 100){
  20. timePassed = 100}
  21. let radius = timePassed
  22. timer = 0
  23. let x = event.x
  24. let y = event.y
  25. let dx = (Math.random()-0.5) *10
  26. let dy = (Math.random()-0.5) *10
  27. circleArray.push(new Circle(x, y, dx, dy, radius))
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement