hosptials

click pixel animation

Oct 22nd, 2021 (edited)
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <script>
  2. var b = document.body;
  3. var imgurl = "https://gnome.crd.co/assets/images/foodsb/8284fad2.gif?v=57709862";
  4. var size = [20, 30];
  5.  
  6. function rand(min, max) {
  7. return Math.floor(Math.random() * (max - min + 1) + min)
  8. }
  9.  
  10. function getSize() {
  11. return rand(size[0], size[1]);
  12. }
  13.  
  14. function lerp(a, b, f) {
  15. return(b - a) * f + a;
  16. }
  17.  
  18. function heart(x, y) {
  19. var s = getSize();
  20. x -= s / 2;
  21. y -= s / 2;
  22. x = Math.floor(x) + rand(-5, 5);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() {var _x = Math.floor(lerp(x, fx, f));
  33. var _y = Math.floor(lerp(y, fy, f));
  34. 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;`;
  35. i.style.opacity = 1 - f;
  36. f += 0.01;
  37. if(f > 1) {
  38. clearInterval(interval);
  39. b.removeChild(i);
  40. }
  41. }, 10);
  42. }
  43.  
  44. function bro(x, y) {
  45. for(var i = 0; i < 5; i++) {
  46. heart(x, y);
  47. }
  48. }
  49. b.addEventListener("click", function(event) {
  50. var x = event.clientX;
  51. var y = event.clientY;
  52. bro(x, y);
  53. });
  54. </script><script>
  55. var myIndex = 0;
  56. carousel();
  57.  
  58. function carousel() {
  59. var i;
  60. var x = document.getElementsByClassName("mySlides");
  61. for(i = 0; i < x.length; i++) {
  62. x[i].style.display = "none";
  63. }
  64. myIndex++;
  65. if(myIndex > x.length) {
  66. myIndex = 1
  67. }
  68. x[myIndex - 1].style.display = "block";
  69. setTimeout(carousel, 2000); // Change image every 2 seconds
  70. }
  71. </script></div>
Add Comment
Please, Sign In to add comment