HTMLify
Loder 2
Views: 287 | Author: djdj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Lissajous Curve Animation</title> <style> body { margin: 0; background-color: black; } canvas { display: block; } </style> </head> <body> <canvas id="canvas"></canvas> <script> const canvas = document.getElementById("canvas"); const ctx = canvas.getContext("2d"); let width = canvas.width = window.innerWidth; let height = canvas.height = window.innerHeight; function drawLissajous(time) { ctx.clearRect(0, 0, width, height); ctx.beginPath(); ctx.strokeStyle = 'rgba(0, 153, 255, 0.8)'; ctx.shadowColor = '#00f0ff'; ctx.shadowBlur = 25; ctx.lineWidth = 2; const a = 5; // x frequency const b = 4; // y frequency const delta = Math.PI / 2; const scale = 150; const centerX = width / 2; const centerY = height / 2; for (let t = 0; t <= 2 * Math.PI; t += 0.01) { const x = centerX + scale * Math.sin(a * t + time / 1000); const y = centerY + scale * Math.sin(b * t); if (t === 0) { ctx.moveTo(x, y); } else { ctx.lineTo(x, y); } } ctx.stroke(); requestAnimationFrame(drawLissajous); } drawLissajous(0); </script> </body> </html> |