#1697·downshift

bn022

作者: brennovhs-web创建于 2026年8月28日更新于 2026年8月28日
  • { margin: 0; padding: 0; box-sizing: border-box; user-select: none; } html, body { width: 100%; height: 100%; overflow: hidden; background: #000; font-family: Arial, sans-serif; } canvas { display: block; width: 100vw; height: 100vh; } const canvas = document.getElementById("c"); const ctx = canvas.getContext("2d"); let W, H, CX, CY, SCALE; const DPR = Math.min(window.devicePixelRatio || 1, 2); const text = "I love you"; const points = []; const TOTAL = 95; // fewer points = less clutter, cleaner function resize() { W = window.innerWidth; H = window.innerHeight; canvas.width = W * DPR; canvas.height = H * DPR; canvas.style.width = W + "px"; canvas.style.height = H + "px"; ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.scale(DPR, DPR); CX = W / 2; CY = H / 2 + 20; // size adapted to mobile SCALE = Math.min(W, H) * 0.014; buildPoints(); } // Classic heart equation function heart(t) { const x = 16 * Math.pow(Math.sin(t), 3); const y = 13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t); return { x: x * SCALE, y: -y * SCALE }; } function buildPoints() { points.length = 0; for (let i = 0; i < TOTAL; i++) { const t = (i / TOTAL) * Math.PI * 2; points.push({ baseT: t, phase: Math.random() * Math.PI * 2 }); } } function glowText(txt, x, y, angle, size, alpha = 1) { ctx.save(); ctx.translate(x, y); ctx.rotate(angle); ctx.font = bold ${size}px Arial, sans-serif; ctx.textAlign = "center"; ctx.textBaseline = "middle"; // Strong neon glow ctx.shadowColor = "rgba(255, 120, 190, 0.95)"; ctx.fillStyle = "rgba(255, 120, 190, " + alpha + ")"; ctx.fillText(txt, 0, 0); ctx.restore(); }

内容来源: downshift-js/downshift