Files

12 lines
1.3 KiB
JavaScript

(()=>{
document.querySelectorAll("[data-shore-sand]").forEach(svg=>{
let seed=33;
const r=()=>((seed=(seed*1664525+1013904223)>>>0)/4294967296);
const grains=Array.from({length:70},()=>`<ellipse cx="${(r()*1440).toFixed(1)}" cy="${(r()*1500).toFixed(1)}" rx="${(1+r()*2).toFixed(1)}" ry="${(1+r()*1.6).toFixed(1)}"/>`).join("");
svg.setAttribute("viewBox","0 0 1440 1500");svg.setAttribute("preserveAspectRatio","xMidYMin slice");
svg.innerHTML=`<g transform="translate(0 80)"><path d="M-80 110C110 142 140 25 300 36S510 125 625 78S715 -25 870 6S1070 87 1220 30S1390 -25 1530 12L1530 81C1340 45 1300 115 1170 125S970 61 850 73S734 150 620 160S404 98 294 111S128 218-80 180Z" fill="#F7E4BD" opacity=".72"/><path d="M-80 110C110 142 140 25 300 36S510 125 625 78S715 -25 870 6S1070 87 1220 30S1390 -25 1530 12" fill="none" stroke="#F4DAAC" stroke-width="9" opacity=".48"/><path d="M-60 405C104 455 192 321 325 343S530 427 674 366S811 294 944 326S1145 395 1270 337S1415 296 1510 318L1510 1600H-60Z" fill="#F7E4BD" opacity=".7"/><g fill="#E4C582" opacity=".55">${grains}</g></g>`;
});
const io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add("bridge--play");io.unobserve(e.target)}}),{threshold:.25});
document.querySelectorAll("[data-bridge]").forEach(s=>io.observe(s));
})();