Advertisement
powylv

img/gif clicksplosion

Jul 9th, 2022 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <script>
  2. var b = document.body;
  3. var imgurl = "https://media.discordapp.net/attachments/957960883374526546/985850899157106758/IMG_20220613_181903.png";
  4. var size = [10, 20];
  5. function rand(min, max)
  6. {
  7. return Math.floor(Math.random() * (max - min + 1) + min)
  8. }
  9. function getSize()
  10. {
  11. return rand(size[0], size[1]);
  12. }
  13. function lerp(a,b,f)
  14. {
  15. return (b-a)*f+a;
  16. }
  17. function heart(x,y)
  18. {
  19. var s = getSize();
  20. x -= s/2;
  21. y -= s/2;
  22. x = Math.floor(x) + rand(-5, 5);
  23. y = Math.floor(y) + rand(-5, 5);
  24. var fx = x + rand(-40, 40);
  25. var fy = y + rand(-40, 40);
  26. var i = document.createElement("img");
  27. i.src = imgurl;
  28. i.style = `pointer-events: none; position: fixed; width: ${s}px; left: ${x}px; top: ${y}px; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; z-index: 1000000;`;
  29. b.appendChild(i);
  30. var f = 0;
  31. var interval;
  32. interval = setInterval(function() {
  33. var _x = Math.floor(lerp(x, fx, f));
  34. var _y = Math.floor(lerp(y, fy, f));
  35. i.style = `pointer-events: none; position: fixed; width: ${s}px; left: ${_x}px; top: ${_y}px; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; z-index: 1000000;`;
  36. i.style.opacity = 1-f;
  37. f += 0.01;
  38. if (f > 1)
  39. {
  40. clearInterval(interval);
  41. b.removeChild(i);
  42. }
  43. }, 10);
  44. }
  45. function bro(x,y)
  46. {
  47. for (var i = 0; i < 5; i++)
  48. {
  49. heart(x,y);
  50. }
  51. }
  52. b.addEventListener("click", function(event){
  53. var x = event.clientX;
  54. var y = event.clientY;
  55. bro(x,y);
  56. });
  57. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement