Ridgelines
Row on row of fine lines rising into peaks in the middle, each hiding the ones behind it, all slowly shifting.
A signal, from far away.
Rows of fine lines rising into peaks, each hiding the ones behind.
Options
Code
import { useEffect, useRef } from "react";
import "./ridgelines.css";
function paint(ctx, w, h, t, colour) {
const rows = 30;
ctx.strokeStyle = colour;
ctx.lineWidth = 1.2;
ctx.lineJoin = "round";
for (let row = 0; row < rows; row++) {
const base = h * (0.2 + row * 0.027);
const trace = () => {
ctx.beginPath();
for (let x = 0; x <= w; x += 6) {
const middle = Math.exp(-Math.pow((x - w / 2) / (w * 0.2), 2));
const peak = Math.sin(x * 0.021 + row * 1.7 + t * 0.6) + Math.sin(x * 0.047 - row * 0.9 - t * 0.9) + Math.sin(x * 0.011 + row + t * 0.3);
ctx.lineTo(x, base - (Math.abs(peak) / 3) * middle * h * 0.17 - Math.sin(x * 0.09 + row * 2.1 + t) * 1.5);
}
};
trace();
ctx.lineTo(w, h);
ctx.lineTo(0, h);
ctx.globalCompositeOperation = "destination-out";
ctx.globalAlpha = 1;
ctx.fill();
trace();
ctx.globalCompositeOperation = "source-over";
ctx.globalAlpha = 0.2 + 0.5 * (row / rows);
ctx.stroke();
}
}
export function Ridgelines({ children }) {
const ref = useRef(null);
useEffect(() => {
const canvas = ref.current;
const ctx = canvas.getContext("2d");
const still = matchMedia("(prefers-reduced-motion: reduce)").matches;
let w = 0;
let h = 0;
let frame = 0;
let seen = true;
const draw = (now) => {
frame = 0;
ctx.clearRect(0, 0, w, h);
ctx.globalAlpha = 1;
paint(ctx, w, h, now / 1000, getComputedStyle(canvas).color);
if (seen && !still) frame = requestAnimationFrame(draw);
};
const start = () => {
if (!frame) frame = requestAnimationFrame(draw);
};
const sized = new ResizeObserver(() => {
const ratio = Math.min(window.devicePixelRatio || 1, 2);
w = canvas.clientWidth;
h = canvas.clientHeight;
canvas.width = w * ratio;
canvas.height = h * ratio;
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
start();
});
const watched = new IntersectionObserver(([entry]) => {
seen = entry.isIntersecting;
if (seen) start();
});
sized.observe(canvas);
watched.observe(canvas);
return () => {
cancelAnimationFrame(frame);
sized.disconnect();
watched.disconnect();
};
}, []);
return (
<section className="dh-ridges">
<canvas ref={ref} className="dh-ridges-art" aria-hidden="true" />
<div className="dh-ridges-content">{children}</div>
</section>
);
}.dh-ridges {
position: relative;
display: grid;
place-items: center;
overflow: hidden;
min-height: 720px;
background: var(--dh-bg, #fff);
color: var(--dh-fg, #171717);
font-size: 14px;
line-height: 1.5;
}
.dh-ridges-art {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
/* The drawing takes this colour. */
color: var(--dh-accent, #2563ff);
pointer-events: none;
-webkit-mask-image: linear-gradient(to right, transparent, #000 16%, #000 84%, transparent);
mask-image: linear-gradient(to right, transparent, #000 16%, #000 84%, transparent);
}
.dh-ridges-content {
position: relative;
isolation: isolate;
padding: 32px;
text-align: center;
}
/* A soft clearing behind the words, so they stay easy to read. */
.dh-ridges-content::before {
content: "";
position: absolute;
inset: -24px -96px;
z-index: -1;
background: radial-gradient(closest-side, var(--dh-bg, #fff) 45%, transparent);
}
.dh-ridges h1 {
margin: 0;
font-size: 44px;
font-weight: 500;
line-height: 1.08;
letter-spacing: -0.04em;
}
.dh-ridges p {
max-width: 360px;
margin: 14px auto 0;
color: var(--dh-muted, #6b6b6b);
font-size: 15px;
}
@media (max-width: 640px) {
.dh-ridges h1 { font-size: 32px; }
}<section class="dh-ridges">
<canvas class="dh-ridges-art" aria-hidden="true"></canvas>
<div class="dh-ridges-content">
<h1>A signal, from far away.</h1>
<p>Rows of fine lines rising into peaks, each hiding the ones behind.</p>
</div>
</section>.dh-ridges {
position: relative;
display: grid;
place-items: center;
overflow: hidden;
min-height: 720px;
background: var(--dh-bg, #fff);
color: var(--dh-fg, #171717);
font-size: 14px;
line-height: 1.5;
}
.dh-ridges-art {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
/* The drawing takes this colour. */
color: var(--dh-accent, #2563ff);
pointer-events: none;
-webkit-mask-image: linear-gradient(to right, transparent, #000 16%, #000 84%, transparent);
mask-image: linear-gradient(to right, transparent, #000 16%, #000 84%, transparent);
}
.dh-ridges-content {
position: relative;
isolation: isolate;
padding: 32px;
text-align: center;
}
/* A soft clearing behind the words, so they stay easy to read. */
.dh-ridges-content::before {
content: "";
position: absolute;
inset: -24px -96px;
z-index: -1;
background: radial-gradient(closest-side, var(--dh-bg, #fff) 45%, transparent);
}
.dh-ridges h1 {
margin: 0;
font-size: 44px;
font-weight: 500;
line-height: 1.08;
letter-spacing: -0.04em;
}
.dh-ridges p {
max-width: 360px;
margin: 14px auto 0;
color: var(--dh-muted, #6b6b6b);
font-size: 15px;
}
@media (max-width: 640px) {
.dh-ridges h1 { font-size: 32px; }
}{
const paint = (ctx, w, h, t, colour) => {
const rows = 30;
ctx.strokeStyle = colour;
ctx.lineWidth = 1.2;
ctx.lineJoin = "round";
for (let row = 0; row < rows; row++) {
const base = h * (0.2 + row * 0.027);
const trace = () => {
ctx.beginPath();
for (let x = 0; x <= w; x += 6) {
const middle = Math.exp(-Math.pow((x - w / 2) / (w * 0.2), 2));
const peak = Math.sin(x * 0.021 + row * 1.7 + t * 0.6) + Math.sin(x * 0.047 - row * 0.9 - t * 0.9) + Math.sin(x * 0.011 + row + t * 0.3);
ctx.lineTo(x, base - (Math.abs(peak) / 3) * middle * h * 0.17 - Math.sin(x * 0.09 + row * 2.1 + t) * 1.5);
}
};
trace();
ctx.lineTo(w, h);
ctx.lineTo(0, h);
ctx.globalCompositeOperation = "destination-out";
ctx.globalAlpha = 1;
ctx.fill();
trace();
ctx.globalCompositeOperation = "source-over";
ctx.globalAlpha = 0.2 + 0.5 * (row / rows);
ctx.stroke();
}
};
document.querySelectorAll(".dh-ridges-art").forEach((canvas) => {
if (canvas.dataset.ready) return;
canvas.dataset.ready = "true";
const ctx = canvas.getContext("2d");
const still = matchMedia("(prefers-reduced-motion: reduce)").matches;
let w = 0;
let h = 0;
let frame = 0;
let seen = true;
const draw = (now) => {
frame = 0;
ctx.clearRect(0, 0, w, h);
ctx.globalAlpha = 1;
paint(ctx, w, h, now / 1000, getComputedStyle(canvas).color);
if (seen && !still) frame = requestAnimationFrame(draw);
};
const start = () => {
if (!frame) frame = requestAnimationFrame(draw);
};
new ResizeObserver(() => {
const ratio = Math.min(window.devicePixelRatio || 1, 2);
w = canvas.clientWidth;
h = canvas.clientHeight;
canvas.width = w * ratio;
canvas.height = h * ratio;
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
start();
}).observe(canvas);
new IntersectionObserver(([entry]) => {
seen = entry.isIntersecting;
if (seen) start();
}).observe(canvas);
});
}Ridgelines is not in the Figma file yet.
Use the React or HTML code for now.