/******* Do not edit this file ******* Simple Custom CSS and JS - by Silkypress.com Saved: Jul 11 2025 | 07:12:45 */ const canvas = document.getElementById("canvas"); const ctx = canvas.getContext("2d"); let w, h; let stars = [], bubbles = []; function resize() { w = canvas.width = window.innerWidth; h = canvas.height = window.innerHeight; } window.addEventListener("resize", resize); resize(); class Star { constructor() { this.reset(); } reset() { this.x = Math.random() * w; this.y = Math.random() * h; this.radius = Math.random() * 1.5 + 0.2; this.alpha = Math.random() * 0.5 + 0.3; this.speed = Math.random() * 0.2 + 0.05; } update() { this.y -= this.speed; if (this.y < -5) this.y = h + 5; } draw() { ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fillStyle = `rgba(255,255,255,${this.alpha})`; ctx.fill(); } } class Bubble { constructor() { this.reset(); } reset() { this.x = Math.random() * w; this.y = h + Math.random() * 200; this.radius = Math.random() * 30 + 10; this.alpha = Math.random() * 0.2 + 0.1; this.speed = Math.random() * 0.5 + 0.2; this.dx = (Math.random() - 0.5) * 0.5; } update() { this.y -= this.speed; this.x += this.dx; if (this.y < -50 || this.x < -50 || this.x > w + 50) this.reset(); } draw() { const gradient = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.radius); gradient.addColorStop(0, `rgba(255,255,255,${this.alpha + 0.1})`); gradient.addColorStop(1, `rgba(255,255,255,0)`); ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fillStyle = gradient; ctx.fill(); } } for (let i = 0; i < 150; i++) stars.push(new Star()); for (let i = 0; i < 20; i++) bubbles.push(new Bubble()); function animate() { ctx.clearRect(0, 0, w, h); stars.forEach(star => { star.update(); star.draw(); }); bubbles.forEach(bubble => { bubble.update(); bubble.draw(); }); requestAnimationFrame(animate); } animate();

Posts in スマホアプリ・モバイル開発

Latest Comments

表示できるコメントはありません。