| 1 |
--- |
| 2 |
const cam = {dist: 800, tz: -390, angle: 67 * Math.PI / 180, scale: 0.7}; |
| 3 |
const step = 260; |
| 4 |
|
| 5 |
function project(x, y) { |
| 6 |
const xs = x * cam.scale; |
| 7 |
const ys = y * cam.scale; |
| 8 |
const depth = cam.dist - (ys * Math.sin(cam.angle) + cam.tz); |
| 9 |
if (depth <= 0) return null; |
| 10 |
return {x: xs / (depth / cam.dist), y: (ys * Math.cos(cam.angle)) / (depth / cam.dist)}; |
| 11 |
} |
| 12 |
|
| 13 |
const lines = []; |
| 14 |
|
| 15 |
// Horizontal: front to back, stop when lines converge |
| 16 |
let prevY = null; |
| 17 |
for (let j = 10; j >= -100; j--) { |
| 18 |
const l = project(-8000, j * step); |
| 19 |
const r = project(8000, j * step); |
| 20 |
if (!l || !r) continue; |
| 21 |
if (prevY !== null && Math.abs(prevY - l.y) < 1.5) break; |
| 22 |
lines.push({x1: l.x, y1: l.y, x2: r.x, y2: r.y}); |
| 23 |
prevY = l.y; |
| 24 |
} |
| 25 |
|
| 26 |
// Vertical: left to right |
| 27 |
for (let i = -30; i <= 30; i++) { |
| 28 |
const near = project(i * step, 1700); |
| 29 |
const far = project(i * step, -3000); |
| 30 |
if (!near || !far) continue; |
| 31 |
lines.push({x1: near.x, y1: near.y, x2: far.x, y2: far.y}); |
| 32 |
} |
| 33 |
--- |
| 34 |
|
| 35 |
<div id="background-grid" aria-hidden="true"> |
| 36 |
<svg viewBox="-1000 -1000 2000 2000" preserveAspectRatio="xMidYMid slice"> |
| 37 |
<defs> |
| 38 |
<linearGradient id="horizonFade" x1="0" y1="-100" x2="0" y2="-320" gradientUnits="userSpaceOnUse"> |
| 39 |
<stop offset="0%" stop-color="white"/> |
| 40 |
<stop offset="100%" stop-color="black"/> |
| 41 |
</linearGradient> |
| 42 |
<mask id="fadeMask"> |
| 43 |
<rect x="-8000" y="-8000" width="16000" height="16000" fill="url(#horizonFade)"/> |
| 44 |
</mask> |
| 45 |
</defs> |
| 46 |
<g mask="url(#fadeMask)"> |
| 47 |
{lines.map(l => |
| 48 |
<line x1={l.x1} y1={l.y1} x2={l.x2} y2={l.y2}/>)} |
| 49 |
</g> |
| 50 |
</svg> |
| 51 |
</div> |
| 52 |
|
| 53 |
<style> |
| 54 |
div { |
| 55 |
position: fixed; |
| 56 |
inset: 0; |
| 57 |
z-index: -10; |
| 58 |
overflow: hidden; |
| 59 |
pointer-events: none; |
| 60 |
display: flex; |
| 61 |
justify-content: center; |
| 62 |
align-items: center; |
| 63 |
mask-image: radial-gradient(ellipse 50% 70% at 50% 50%, black 10%, transparent 80%); |
| 64 |
will-change: transform; |
| 65 |
contain: strict; |
| 66 |
transition: opacity 0.5s; |
| 67 |
|
| 68 |
svg { |
| 69 |
width: 100vw; |
| 70 |
height: 100vh; |
| 71 |
min-width: 100%; |
| 72 |
min-height: 100%; |
| 73 |
} |
| 74 |
|
| 75 |
line { |
| 76 |
stroke: light-dark(rgb(0 0 0 / 0.02), rgb(255 255 255 / 0.01)); |
| 77 |
stroke-width: 1.5px; |
| 78 |
vector-effect: non-scaling-stroke; |
| 79 |
transition: stroke 0.5s ease; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
:global(body:has([data-home-page])) div line { |
| 84 |
stroke: light-dark(rgb(0 0 0 / 0.04), rgb(255 255 255 / 0.05)); |
| 85 |
} |
| 86 |
|
| 87 |
:global(body:has([data-home-page])) div:global(.grid-dimmed) line { |
| 88 |
stroke: light-dark(rgb(0 0 0 / 0.02), rgb(255 255 255 / 0.01)); |
| 89 |
} |
| 90 |
</style> |