MCPcopy
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / animate

Function animate

assets/js/Mousehover.js:59–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59function animate() {
60 if (tx != window.innerWidth || ty != window.innerHeight) {
61 tx = window.innerWidth;
62 ty = window.innerHeight;
63 canvas.width = tx;
64 canvas.height = ty;
65 }
66 requestAnimationFrame(animate);
67 c.clearRect(0, 0, tx, ty);
68 for (var i = 0; i < bal.length; i++) {
69 bal[i].update();
70 bal[i].y += bal[i].dy;
71 bal[i].x += bal[i].dx;
72 if (bal[i].y + bal[i].radius >= ty) {
73 bal[i].dy = -bal[i].dy * grav;
74 } else {
75 bal[i].dy += bal[i].vel;
76 }
77 if(bal[i].x + bal[i].radius > tx || bal[i].x - bal[i].radius < 0){
78 bal[i].dx = -bal[i].dx;
79 }
80 if(mousex > bal[i].x - 20 &&
81 mousex < bal[i].x + 20 &&
82 mousey > bal[i].y -50 &&
83 mousey < bal[i].y +50 &&
84 bal[i].radius < 70){
85
86 bal[i].radius +=5;
87 } else {
88 if(bal[i].radius > bal[i].startradius){
89 bal[i].radius += -5;
90 }
91 }
92
93
94 }
95
96}
97
98animate();
99

Callers 1

Mousehover.jsFile · 0.70

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected