const canvas = document.getElementById("sky"); const ctx = canvas.getContext("2d"); let w = canvas.width = window.innerWidth; let h = canvas.height = window.innerHeight; const starsCount = 120; const maxDist = 80; const highlightDist = 45; const stars = []; const mouse = { x: -1000, y: -1000 }; window.addEventListener('mousemove', e => { mouse.x = e.clientX; mouse.y = e.clientY; }); window.addEventListener('mouseleave', () => { mouse.x = -1000; mouse.y = -1000; }); window.addEventListener('resize', () => { w = canvas.width = window.innerWidth; h = canvas.height = window.innerHeight; }); for(let i=0; i w) s.dx *= -1; if(s.y < 0 || s.y > h) s.dy *= -1; } for(let i=0; i -dy) { err -= dy; x0 += sx; } if (e2 < dx) { err += dx; y0 += sy; } } } animate();