Эффекты и шейдерыСветлыйРетро и пиксельМинимализмТипографикаБесплатно
Постеры, которые проявляются чёрными блоками
Сетка постеров проявляется случайными чёрными квадратами при появлении на экране и «сбоит» блоками при наведении. Canvas, без библиотек.
Промпт
Добавь на мою страницу эффект «Постеры, которые проявляются чёрными блоками» (Сергей Дургалян, MIT). Ниже готовая страница без библиотек: HTML, CSS и canvas 2D. Сначала перенеси её как есть и проверь: при загрузке и при прокрутке постеры проявляются через случайные чёрные квадраты, уходя с экрана, рассыпаются; при наведении или касании блоки на мгновение сбоят; если 3 секунды ничего не трогать, случайные постеры сами сбоят и проявляются заново. Потом меняй.
Как устроен код. Каждая карточка — `figure` с canvas и подписью, их создаёт функция `Card(i)` по массиву `POSTERS` (код, название, два цвета). Постер рисует `paint()` во внутренний canvas `src` под реальный размер карточки с учётом `devicePixelRatio`; это процедурная графика (кольца, штриховка, растр, закат, волны, колонны, сфера, шахматы), вместо неё можно рисовать картинку через `drawImage`. Видимый canvas делится на блоки: `COLS` по ширине, строк по пропорции. У каждого блока случайный порог `order[k]` от 0 до 1. Прогресс `p` идёт от 0 до 1 за `REVEAL_MS`, и при `q = p · (1 + BAND)` блок рисуется так: порог меньше `q − BAND` — кусок постера, меньше `q` — чёрный квадрат, иначе пусто. Поэтому перед картинкой всегда пробегает волна чёрных блоков шириной `BAND`. Обратный ход (уход с экрана) — тот же прогресс к нулю. Появление и уход ловит `IntersectionObserver`, в одной пачке карточки стартуют с задержкой 140 мс друг за другом. Глитч: пока `glitchUntil` не прошёл, каждый блок с вероятностью 14% рисуется чёрным или берётся из соседнего столбца `src`. Перерисовка идёт только когда что-то меняется (`dirty`), иначе canvas не трогается. `ResizeObserver` пересоздаёт постер под новый размер. При `prefers-reduced-motion` постеры появляются сразу, без блоков и глитча.
Что менять: размер блоков — `COLS` (меньше — крупнее пиксели); ширину чёрной волны — `BAND`; скорость — `REVEAL_MS` и `GLITCH_MS`; цвет фона и «пустых» блоков — `PAPER`; постеры и подписи — `POSTERS` и `paint()`. Чтобы показывать свои картинки, загрузи `Image`, дождись `decode()` и в `resize` рисуй её в `src` через `drawImage` с обрезкой по `object-fit: cover`. Чёрный цвет блоков можно заменить на фирменный.
Если проект на React: сделай компонент `BlockRevealCard` с пропсами `src` и `caption`, canvas через `useRef`, а `IntersectionObserver`, `ResizeObserver` и цикл `requestAnimationFrame` заводи в `useEffect` и снимай в очистке. Прогресс и пороги блоков держи в `useRef`, не в состоянии: они меняются каждый кадр.
Покажи, где на моём сайте такое проявление уместно, и предложи подписи в «лабораторном» стиле под мои работы.
Код скопируется вместе с промптом
Сетка постеров в духе архива лаборатории: подписи вида «ЛФ-017 · Кольца · проба 01/12». Когда карточка попадает на экран, она не просто появляется: сначала пустое место в случайном порядке заполняется чёрными квадратами, а уже на их месте проступает картинка. Уходя с экрана, постер так же рассыпается обратно. При наведении или касании карточка «сбоит»: часть блоков на мгновение чернеет или съезжает вбок. Если ничего не трогать, случайные постеры сами сбоят и заново проявляются. Приём подсмотрен на exp.fiddle.digital.
Всё сделано на обычном canvas 2D без библиотек: постер рисуется один раз во внутренний canvas, а видимый canvas собирает его по блокам сетки 12 × 16. У каждого блока свой случайный порог, и одна переменная прогресса решает, что в нём сейчас: пусто, чёрный квадрат или кусок картинки. Подходит для портфолио, каталога работ, блога, витрины коллекции, особенно в техно- и пиксельной стилистике.
Код
<!-- MIT License. Copyright (c) 2026 Sergei Durgalian, learn.create-products.com/design. Free to use, copy and modify with this notice kept. -->
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Block Reveal Posters</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Unbounded:wght@800&display=swap">
<style>
*, *::before, *::after { box-sizing: border-box; }
html { background: #ecebe6; }
body { margin: 0; color: #111; font-family: "IBM Plex Mono", monospace; }
header { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 28px clamp(16px, 3vw, 40px) 22px; border-bottom: 1px solid #1111; }
header h1 { margin: 0; font: 800 clamp(30px, 5vw, 64px)/.95 "Unbounded", sans-serif; letter-spacing: -.03em; }
header p { margin: 0; max-width: 32ch; font-size: 12px; line-height: 1.5; text-transform: uppercase; opacity: .65; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(12px, 2vw, 28px); padding: 22px clamp(16px, 3vw, 40px) 60px; }
figure { margin: 0; cursor: crosshair; }
canvas { display: block; width: 100%; aspect-ratio: 3 / 4; }
figcaption { display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: space-between; margin-top: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
figcaption span:last-child { opacity: .5; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } header { flex-direction: column; align-items: start; } }
</style>
</head>
<body>
<header>
<h1>Архив<br>образцов</h1>
<p>Лаборатория формы · партия 26/11 · наведите или коснитесь образца, чтобы сбить сигнал</p>
</header>
<main class="grid" id="grid"></main>
<script>
const COLS = 12; // blocks across a poster (rows follow the aspect)
const BAND = 0.22; // share of the dissolve that shows black blocks before the image
const REVEAL_MS = 1100; // full dissolve duration
const GLITCH_MS = 420;
const IDLE_DEMO = 3000;
const PAPER = "#ecebe6";
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
const POSTERS = [
["ЛФ-017", "Кольца", "#ff4d2e", "#ffd6c9"], ["ЛФ-022", "Штрих", "#2b4cff", "#dfe4ff"], ["ЛФ-031", "Растр", "#111111", "#ffd23f"],
["ЛФ-038", "Полдень", "#16c79a", "#0f3d33"], ["ЛФ-044", "Волна", "#7a5cff", "#f0ebff"], ["ЛФ-051", "Колонны", "#ff9f1c", "#1b1b1b"],
["ЛФ-063", "Сфера", "#ff8fd8", "#2b1240"], ["ЛФ-070", "Шахматы", "#e8e3d6", "#111111"],
];
// procedural poster art, drawn once per size into an offscreen canvas
function paint(g, w, h, i, a, b) {
g.fillStyle = b; g.fillRect(0, 0, w, h);
g.fillStyle = g.strokeStyle = a; g.lineWidth = w * .035;
const cx = w / 2, cy = h / 2;
switch (i) {
case 0: for (let r = w * .62; r > 0; r -= w * .09) { g.beginPath(); g.arc(cx, h * .58, r, 0, 7); g.stroke(); } break;
case 1: for (let x = -h; x < w; x += w * .09) { g.beginPath(); g.moveTo(x, h); g.lineTo(x + h, 0); g.stroke(); } g.fillStyle = b; g.fillRect(w * .18, h * .3, w * .64, h * .4); break;
case 2: for (let y = 0; y < h; y += w * .07) for (let x = 0; x < w; x += w * .07) { g.beginPath(); g.arc(x, y, w * .033 * (1 - Math.hypot(x - cx, y - cy) / h), 0, 7); g.fill(); } break;
case 3: { const gr = g.createLinearGradient(0, 0, 0, h); gr.addColorStop(0, "#ffe9a8"); gr.addColorStop(1, a); g.fillStyle = gr; g.fillRect(0, 0, w, h * .62);
g.fillStyle = b; g.beginPath(); g.arc(cx, h * .62, w * .3, Math.PI, 0); g.fill(); break; }
case 4: for (let y = h * .1; y < h; y += h * .07) { g.beginPath(); for (let x = 0; x <= w; x += 6) g.lineTo(x, y + Math.sin(x / w * 9 + y / h * 6) * h * .025); g.stroke(); } break;
case 5: for (let k = 0; k < 5; k++) g.fillRect(w * (.08 + k * .18), h * (.2 + (k % 2) * .15), w * .12, h * .7); break;
case 6: { const gr = g.createRadialGradient(cx * .8, cy * .8, 0, cx, cy, w * .45); gr.addColorStop(0, "#fff"); gr.addColorStop(.35, a); gr.addColorStop(1, "#5b1d6e");
g.fillStyle = gr; g.beginPath(); g.arc(cx, cy, w * .4, 0, 7); g.fill(); break; }
default: { const s = w / 6; for (let y = 0; y < h / s; y++) for (let x = 0; x < 6; x++) if ((x + y) % 2) g.fillRect(x * s, y * s, s, s); }
}
g.fillStyle = "#111"; g.fillRect(w * .05, h * .88, w * .14, w * .085); // sample number chip
g.fillStyle = "#fff"; g.font = `600 ${w * .055}px "IBM Plex Mono", monospace`;
g.fillText(String(i + 1).padStart(2, "0"), w * .065, h * .88 + w * .064);
}
function Card(i) {
const [code, name, a, b] = POSTERS[i];
const fig = document.createElement("figure");
const cv = document.createElement("canvas");
cv.setAttribute("role", "img"); cv.setAttribute("aria-label", `Постер ${code}: ${name}`);
const cap = document.createElement("figcaption");
cap.innerHTML = `<span>${code} · ${name}</span><span>проба ${String((i * 7) % 12 + 1).padStart(2, "0")}/12</span>`;
fig.append(cv, cap); document.getElementById("grid").append(fig);
const g = cv.getContext("2d"), src = document.createElement("canvas");
const c = { fig, p: 0, target: 0, from: 0, t0: 0, glitchUntil: 0, order: [], cols: COLS, rows: 0, dirty: true, visible: false };
c.resize = () => {
const dpr = Math.min(devicePixelRatio, 2), w = Math.round(cv.clientWidth * dpr), h = Math.round(cv.clientHeight * dpr);
if (!w || (w === cv.width && h === cv.height)) return;
cv.width = src.width = w; cv.height = src.height = h;
paint(src.getContext("2d"), w, h, i, a, b);
c.rows = Math.round(COLS * h / w);
c.order = Array.from({ length: c.cols * c.rows }, () => Math.random()); // random fill order
c.dirty = true;
};
c.show = (on, delay = 0) => { c.from = c.p; c.target = on ? 1 : 0; c.t0 = performance.now() + delay; };
c.glitch = () => { if (!reduced) c.glitchUntil = performance.now() + GLITCH_MS; };
c.draw = (now) => {
if (c.p !== c.target && now >= c.t0) {
const k = reduced ? 1 : Math.min(1, (now - c.t0) / REVEAL_MS);
c.p = c.from + (c.target - c.from) * k; c.dirty = true;
}
const glitching = now < c.glitchUntil;
if (!c.dirty && !glitching) return;
c.dirty = glitching; // one more clean frame after the glitch ends
const W = cv.width, H = cv.height, bw = W / c.cols, bh = H / c.rows, q = c.p * (1 + BAND);
g.fillStyle = PAPER; g.fillRect(0, 0, W, H);
for (let y = 0; y < c.rows; y++) for (let x = 0; x < c.cols; x++) {
const r = c.order[y * c.cols + x], sx = Math.floor(x * bw), sy = Math.floor(y * bh), sw = Math.ceil(bw), sh = Math.ceil(bh);
if (glitching && Math.random() < .14) {
if (Math.random() < .5) { g.fillStyle = "#000"; g.fillRect(sx, sy, sw, sh); }
else g.drawImage(src, ((x + (Math.random() < .5 ? -2 : 3) + c.cols) % c.cols) * bw, sy, sw, sh, sx, sy, sw, sh);
} else if (r < q - BAND) g.drawImage(src, sx, sy, sw, sh, sx, sy, sw, sh);
else if (r < q) { g.fillStyle = "#000"; g.fillRect(sx, sy, sw, sh); }
}
};
fig.addEventListener("pointerenter", () => { if (c.p > .9) c.glitch(); });
fig.addEventListener("click", () => c.glitch());
return c;
}
const cards = POSTERS.map((_, i) => Card(i));
const byFig = new Map(cards.map((c) => [c.fig, c]));
let order = 0;
// dissolve in when a card enters the viewport, out when it leaves
const io = new IntersectionObserver((entries) => {
for (const e of entries) {
const c = byFig.get(e.target); c.visible = e.isIntersecting;
c.show(e.isIntersecting, e.isIntersecting ? (order++ % 4) * 140 : 0);
}
order = 0;
}, { threshold: 0.15 });
document.fonts.ready.then(() => cards.forEach((c) => { c.resize(); io.observe(c.fig); }));
cards.forEach((c) => c.resize());
new ResizeObserver(() => cards.forEach((c) => c.resize())).observe(document.getElementById("grid"));
// demo: with no input, a random visible poster glitches or re-dissolves
let lastInput = performance.now(), nextDemo = 0;
["pointermove", "scroll", "keydown", "touchstart"].forEach((ev) => addEventListener(ev, () => { lastInput = performance.now(); }, { passive: true }));
function frame(now) {
if (!reduced && now - lastInput > IDLE_DEMO && now > nextDemo) {
const pool = cards.filter((c) => c.visible && c.p === 1);
const c = pool[Math.floor(Math.random() * pool.length)];
if (c) { if (Math.random() < .5) c.glitch(); else { c.show(false); setTimeout(() => c.show(true), REVEAL_MS * .7); } }
nextDemo = now + 900;
}
for (const c of cards) c.draw(now);
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
</script>
</body>
</html>