const theta = Math.PI * (1 - p);
const z = 220 * Math.sin(theta), perspective = 1100 / (1100 - z);
const outerX = 220 - 220 * Math.cos(theta) * perspective;
const topY = 150 - 150 * perspective, bottomY = 150 + 150 * perspective;
const left = [[outerX, topY], [220, 0], [220, 300], [outerX, bottomY]];
book.style.setProperty('--leaf-clip', clip(left)); /* .leaf { clip-path: var(--leaf-clip) } */
leafShape.setAttribute('d', roundedPath(left));Folding card
A business card that opens like a book.
su.a small introduction
Su / 苏Search, recommendation
& AI systems
& AI systems
made with curiosity
su.hello there
Su / 苏Search, recommendation
& AI systems
& AI systems
Closed. Tap the card to open it.
Key CSS & implementation tricks
const middle = Math.sin(Math.PI * p);
book.style.setProperty('--cover-opacity', String(1 - smooth(.08, .47, p)));
book.style.setProperty('--inner-opacity', String(smooth(.63, .98, p)));
book.style.setProperty('--blur', `${12 * (1 - smooth(.65, 1, p))}px`);
book.style.setProperty('--fold-shade', String(.52 * middle));const nx = Math.sin(angle), nz = Math.cos(angle); // surface normal
const diffuse = Math.max(0, (nx * lightX + nz * 1.6) / Math.hypot(lightX, lightY, 1.6));
surface.style.setProperty('--spectrum-x', `${50 + lightX * 65 + nx * 55}%`);
surface.style.setProperty('--specular', String(.18 + .48 * diffuse));
.foil { background: repeating-linear-gradient(var(--rainbow-angle), …);
background-position: var(--spectrum-x) var(--spectrum-y);
mask-image: radial-gradient(ellipse at var(--light-x) var(--light-y), #000, transparent 78%); }velocity += ((target - position) * 145 - velocity * 23) * dt;
position += velocity * dt;
toggle.addEventListener('click', () => setTarget(target > .5 ? 0 : 1)); // reversal = new target