Промпт Скопировать
Добавь на мою страницу эффект «Рисованное растение, которое можно полить» (Сергей Дургалян, MIT). Ниже готовая страница: HTML, SVG и JS без библиотек. Сначала перенеси её как есть и проверь: лейку можно тянуть мышью или пальцем, над горшком она наклоняется и льёт капли, стебли прорисовываются, листья и цветы появляются по очереди, в конце надпись меняется и появляется кнопка «полить заново», линии всё время слегка дрожат, без мыши лейка поливает сама. Потом меняй.
Как устроен код. Вся сцена — SVG с `viewBox`, рисунки внутри группы с фильтром `#boil` (`feTurbulence` + `feDisplacementMap`), `setInterval` меняет `seed` турбулентности 8 раз в секунду. Стебли — пути с `pathLength="1"`, рост задаётся `strokeDashoffset`. Листья и цветы — группы `.leaf` / `.flower` с `data-at` (порог роста) и `transform-origin` в точке крепления, масштаб с небольшой пружинкой. Лейка — группа `#can`, её положение и наклон пишутся в `transform`; координаты указателя переводятся в координаты SVG через `getScreenCTM().inverse()`. Носик считается поворотом точки `SPOUT`; если он над горшком — лейка наклоняется до `TILT`, из пула вылетают капли с гравитацией, `water` растёт со скоростью `FILL_SPEED`, `grow` догоняет его. Без ввода 6 секунд `demoTarget()` водит лейку по сценарию; `?auto=1` включает его сразу. На узком экране `fit()` кадрирует `viewBox` вокруг растения. При `prefers-reduced-motion` дрожания нет.
Что менять: рисунки растения, горшка и лейки (пути SVG), пороги `data-at`, тексты надписи и подвала, цвета ссылок, скорость полива.
Если проект на React: держи разметку в компоненте, а запуск анимации и подписки на события — в `useEffect` с очисткой (`cancelAnimationFrame`, снять слушатели, `clearInterval` для дрожания).
Подскажи, какой рисованный объект на моём сайте можно так же «оживить» действием посетителя. Код скопируется вместе с промптом
На странице нарисованный от руки пустой горшок и надпись «полей моё растение!» со стрелкой к лейке. Возьмите лейку и поднесите к горшку: она наклоняется, льётся вода, из земли тянутся стебли, распускаются листья, а потом три цветка. Когда растение полностью выросло, надпись благодарит, а кнопка «полить заново» возвращает всё к началу. Линии всё время слегка «кипят», как кадры рисованного мультика.
Подходит для подвала или страницы «обо мне» в портфолио иллюстратора, детского проекта, цветочного магазина, сервиса с заботливым тоном — как маленькая игра, после которой хочется написать автору.
Как это устроено
Всё — один SVG. «Дрожание» линий: фильтр feTurbulence + feDisplacementMap, у которого восемь раз в секунду меняется seed.
Рост: стебли рисуются через stroke-dashoffset (у путей pathLength="1"), листья и цветы появляются с пружинкой по порогам data-at. Прогресс полива плавно передаётся росту, поэтому растение тянется с небольшой задержкой.
Лейку можно тянуть за любую точку; когда носик оказывается над горшком, она наклоняется, вылетают капли (пул из 46 эллипсов с гравитацией) и копится вода.
Без мыши лейка сама прилетает, поливает и улетает. На узком экране сцена кадрируется вокруг растения. При «уменьшении движения» линии не дрожат, рост без задержки.
Код наш (MIT), идея подсмотрена в рилсе с подборкой личных сайтов (рисованная страница, где просят полить растение): взят только приём, рисунки и тексты свои.
Как получить такой же результат
Промпт содержит страницу одним файлом, она работает двойным щелчком.
Свои рисунки: замените пути в группе #plant и #can. Каждому листу или цветку дайте класс leaf или flower, data-at (на каком проценте полива появиться) и transform-origin в точке крепления.
Надписи и ссылки — в HTML, сила дрожания — атрибут scale у feDisplacementMap.
Код Скопировать
<!-- 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>Полей растение</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Inter:wght@400&display=swap">
<style>
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #f4f2ec; color: #222; font-family: "Caveat", cursive; overflow: hidden; }
nav { position: fixed; top: 22px; right: clamp(16px, 4vw, 48px); display: flex; gap: 26px; font-size: 22px; z-index: 2; }
nav a { color: inherit; text-decoration: none; background: no-repeat 0 100% / 100% 6px linear-gradient(transparent 40%, #222 40% 60%, transparent 60%); }
svg#scene { position: fixed; left: 0; top: 0; width: 100%; height: calc(100% - 120px); touch-action: none; cursor: grab; }
svg#scene.drag { cursor: grabbing; }
.ink { fill: none; stroke: #222; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
footer { position: fixed; left: 0; right: 0; bottom: clamp(18px, 5vh, 44px); text-align: center; pointer-events: none; }
footer p { margin: 0 auto 12px; max-width: 460px; padding: 0 16px; font: 400 12px/1.6 "Inter", sans-serif; color: #555; }
footer .links { display: flex; justify-content: center; gap: 22px; font-size: 21px; pointer-events: auto; }
footer .links a { text-decoration: none; }
button.again { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); font: 700 20px "Caveat"; border: 2px solid #222; border-radius: 30px 26px 32px 24px; background: #fff; padding: 2px 16px; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .4s; }
button.again.show { opacity: 1; pointer-events: auto; }
@media (max-width: 640px) { button.again { top: 64px; } }
</style>
</head>
<body>
<nav><a href="#">работы</a><a href="#">обо мне</a></nav>
<button class="again" id="again">полить заново</button>
<svg id="scene" viewBox="0 60 800 490" preserveAspectRatio="xMidYMid meet" aria-label="Рисованное растение и лейка">
<defs>
<!-- "Boiling" line: displacement noise with a seed that changes a few times per second -->
<filter id="boil" x="-5%" y="-5%" width="110%" height="110%">
<feTurbulence id="turb" type="fractalNoise" baseFrequency="0.028" numOctaves="2" seed="1"/>
<feDisplacementMap in="SourceGraphic" scale="3.2"/>
</filter>
</defs>
<g filter="url(#boil)">
<text id="say" x="250" y="118" font-family="Caveat" font-size="30" font-weight="700" text-anchor="middle">полей моё растение!</text>
<path id="arrow" class="ink" d="M372 108 C450 70 525 110 540 190 M528 176 L541 194 L556 178" stroke-width="2.2"/>
<!-- plant: stems draw in with growth, leaves and flowers scale in by thresholds -->
<g id="plant">
<path class="stem ink" pathLength="1" d="M400 452 C398 400 404 340 400 250" stroke="#2f7a3a"/>
<path class="stem ink" pathLength="1" d="M400 400 C370 370 340 330 320 290" stroke="#2f7a3a"/>
<path class="stem ink" pathLength="1" d="M402 370 C440 340 470 300 482 262" stroke="#2f7a3a"/>
<g class="leaf" data-at=".12" style="transform-origin:400px 430px"><path d="M400 430 C370 420 352 398 350 380 C374 384 394 402 400 430 Z" fill="#4caf50" stroke="#222" stroke-width="2.5"/></g>
<g class="leaf" data-at=".22" style="transform-origin:401px 410px"><path d="M401 410 C430 404 452 384 458 364 C432 364 410 382 401 410 Z" fill="#3f9b45" stroke="#222" stroke-width="2.5"/></g>
<g class="leaf" data-at=".38" style="transform-origin:360px 350px"><path d="M360 350 C330 352 310 336 302 318 C328 314 350 328 360 350 Z" fill="#5cbc5a" stroke="#222" stroke-width="2.5"/></g>
<g class="leaf" data-at=".46" style="transform-origin:448px 320px"><path d="M448 320 C474 322 492 306 500 290 C476 286 456 300 448 320 Z" fill="#4caf50" stroke="#222" stroke-width="2.5"/></g>
<g class="leaf" data-at=".58" style="transform-origin:402px 300px"><path d="M402 300 C378 290 368 268 370 250 C392 260 402 280 402 300 Z" fill="#3f9b45" stroke="#222" stroke-width="2.5"/></g>
<g class="flower" data-at=".78" style="transform-origin:400px 250px">
<g fill="#e2483d" stroke="#222" stroke-width="2.5">
<ellipse cx="400" cy="226" rx="11" ry="20"/><ellipse cx="400" cy="274" rx="11" ry="20"/><ellipse cx="376" cy="250" rx="20" ry="11"/><ellipse cx="424" cy="250" rx="20" ry="11"/>
</g><circle cx="400" cy="250" r="10" fill="#f2c230" stroke="#222" stroke-width="2.5"/>
</g>
<g class="flower" data-at=".86" style="transform-origin:320px 290px">
<path d="M320 290 L300 262 L318 270 L322 250 L332 270 L348 262 Z" fill="#e87fb8" stroke="#222" stroke-width="2.5"/>
</g>
<g class="flower" data-at=".94" style="transform-origin:482px 262px">
<circle cx="482" cy="262" r="17" fill="#f39a2b" stroke="#222" stroke-width="2.5"/><circle cx="482" cy="262" r="6" fill="#222"/>
</g>
</g>
<!-- pot -->
<path d="M352 450 L448 450 L436 520 C430 532 370 532 364 520 Z" fill="#f2c230" stroke="#222" stroke-width="3"/>
<path class="ink" d="M346 450 L454 450" stroke-width="4"/>
<path class="ink" d="M372 476 C390 482 410 470 428 476" stroke-width="2"/>
<path class="ink" d="M330 532 C380 538 420 528 470 534" stroke-width="2"/>
<!-- watering can -->
<g id="can">
<path d="M-34 -30 L34 -30 L38 34 L-38 34 Z" fill="#4a7fd8" stroke="#222" stroke-width="3"/>
<path class="ink" d="M-30 -6 L32 -6 M-32 14 L34 14" stroke="#cfe0ff" stroke-width="3"/>
<path class="ink" d="M-34 0 L-84 -46" stroke-width="7" stroke="#222"/>
<path class="ink" d="M-34 0 L-84 -46" stroke-width="3.5" stroke="#4a7fd8"/>
<path d="M-94 -56 L-76 -38 L-86 -60 Z" fill="#4a7fd8" stroke="#222" stroke-width="2.5"/>
<path class="ink" d="M34 -18 C70 -20 70 26 36 24" stroke-width="4"/>
<path class="ink" d="M-20 -30 C-16 -56 16 -56 20 -30" stroke-width="4"/>
</g>
</g>
<g id="drops"></g>
</svg>
<footer>
<p>Я рисую от руки и оживляю рисунки кодом. Если вам понравилось здесь — напишите, придумаем что-нибудь вместе.</p>
<div class="links"><a href="#" style="color:#3a6fd1">почта</a><a href="#" style="color:#d9822b">телеграм</a><a href="#" style="color:#b5489a">вконтакте</a><a href="#" style="color:#3f9b45">резюме</a></div>
</footer>
<script>
// ---- settings ----
const FILL_SPEED = 0.3; // growth per second of watering
const TILT = -0.62; // can tilt while pouring, radians
const HOME = { x: 640, y: 190 };
const SPOUT = { x: -90, y: -52 };
const AUTO = new URLSearchParams(location.search).has('auto');
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
const svg = document.getElementById('scene');
const can = document.getElementById('can');
const dropsG = document.getElementById('drops');
const say = document.getElementById('say');
const arrow = document.getElementById('arrow');
const again = document.getElementById('again');
const stems = [...document.querySelectorAll('.stem')];
const parts = [...document.querySelectorAll('.leaf, .flower')];
// boiling line: change the noise seed ~8 times a second
const turb = document.getElementById('turb');
let seed = 1;
if (!reduce) setInterval(() => turb.setAttribute('seed', (seed = (seed % 5) + 1)), 125);
// narrow screens: crop the scene around the plant and park the can closer
function fit() {
const narrow = innerWidth < innerHeight;
svg.setAttribute('viewBox', narrow ? '200 60 440 560' : '0 60 800 490');
HOME.x = narrow ? 560 : 640; HOME.y = narrow ? 170 : 190;
say.setAttribute('x', narrow ? 420 : 250); arrow.style.display = narrow ? 'none' : '';
}
fit(); addEventListener('resize', fit);
const state = { x: HOME.x, y: HOME.y, tilt: 0, water: 0, grow: 0, dragging: false, done: false };
const toSvg = (e) => { const p = svg.createSVGPoint(); p.x = e.clientX; p.y = e.clientY; return p.matrixTransform(svg.getScreenCTM().inverse()); };
let grab = null, lastInput = -1e9;
svg.addEventListener('pointerdown', (e) => {
const p = toSvg(e); grab = { dx: state.x - p.x, dy: state.y - p.y };
// tap far away from the can: the can jumps under the finger
if (Math.hypot(grab.dx, grab.dy) > 90) grab = { dx: 40, dy: 0 };
state.dragging = true; lastInput = performance.now();
svg.setPointerCapture(e.pointerId); svg.classList.add('drag');
});
svg.addEventListener('pointermove', (e) => {
if (!state.dragging) return;
const p = toSvg(e); state.x = p.x + grab.dx; state.y = p.y + grab.dy; lastInput = performance.now();
});
const drop = () => { state.dragging = false; svg.classList.remove('drag'); };
svg.addEventListener('pointerup', drop); svg.addEventListener('pointercancel', drop);
again.addEventListener('click', () => { state.water = 0; state.done = false; again.classList.remove('show'); say.textContent = 'полей моё растение!'; arrow.style.opacity = 1; });
// ---- drops pool ----
const POOL = Array.from({ length: 46 }, () => {
const c = document.createElementNS('http://www.w3.org/2000/svg', 'ellipse');
c.setAttribute('rx', 2.4); c.setAttribute('ry', 4); c.setAttribute('fill', '#5b9cf0'); c.style.display = 'none';
dropsG.appendChild(c); return { el: c, live: false };
});
function spawn(x, y) {
const d = POOL.find((p) => !p.live); if (!d) return;
Object.assign(d, { live: true, x: x + (Math.random() - 0.5) * 6, y, vx: -40 - Math.random() * 40, vy: 30 + Math.random() * 40 });
d.el.style.display = '';
}
// ---- demo path for the can (no pointer, or ?auto=1) ----
function demoTarget(t) {
const k = (t / 1000) % 9; // 0–2 fly in, 2–6 pour, 6–7.5 fly out, then wait
const pour = { x: 520, y: 210 };
const lerp = (a, b, u) => a + (b - a) * (u * u * (3 - 2 * u));
if (k < 2) return { x: lerp(HOME.x, pour.x, k / 2), y: lerp(HOME.y, pour.y, k / 2) };
if (k < 6) return { x: pour.x + Math.sin(k * 2) * 10, y: pour.y };
if (k < 7.5) return { x: lerp(pour.x, HOME.x, (k - 6) / 1.5), y: lerp(pour.y, HOME.y, (k - 6) / 1.5) };
return HOME;
}
let prev = performance.now(), demoStart = 0;
function frame(t) {
const dt = Math.min(0.05, (t - prev) / 1000); prev = t;
const idle = AUTO || (!reduce && t - lastInput > 6000 && !state.dragging);
if (idle) {
if (!demoStart) { demoStart = t; if (state.done) again.click(); }
const p = demoTarget(t - demoStart);
state.x += (p.x - state.x) * 0.2; state.y += (p.y - state.y) * 0.2;
if (state.done && (t - demoStart) % 9000 > 8500) again.click();
} else demoStart = 0;
if (!state.dragging && !idle) { state.x += (HOME.x - state.x) * 0.04; state.y += (HOME.y - state.y) * 0.04; }
// pour when the spout is above the plant
const tipX = state.x + SPOUT.x * Math.cos(state.tilt) - SPOUT.y * Math.sin(state.tilt);
const tipY = state.y + SPOUT.x * Math.sin(state.tilt) + SPOUT.y * Math.cos(state.tilt);
const over = tipX > 300 && tipX < 500 && tipY < 420;
state.tilt += ((over ? TILT : 0) - state.tilt) * 0.12;
const pouring = over && state.tilt < TILT * 0.6;
if (pouring) {
if (Math.random() < 0.8) spawn(tipX, tipY);
if (!state.done) state.water = Math.min(1, state.water + dt * FILL_SPEED);
}
can.setAttribute('transform', `translate(${state.x.toFixed(1)} ${state.y.toFixed(1)}) rotate(${(state.tilt * 57.3).toFixed(1)})`);
for (const d of POOL) {
if (!d.live) continue;
d.vy += 520 * dt; d.x += d.vx * dt; d.y += d.vy * dt;
if (d.y > 448) { d.live = false; d.el.style.display = 'none'; continue; }
d.el.setAttribute('cx', d.x.toFixed(1)); d.el.setAttribute('cy', d.y.toFixed(1));
}
// growth follows water with a little delay
state.grow += (state.water - state.grow) * (reduce ? 1 : 0.05);
const g = state.grow;
stems.forEach((s, i) => s.style.strokeDashoffset = (1 - Math.min(1, Math.max(0, (g - i * 0.15) / 0.55))).toFixed(3));
for (const el of parts) {
const at = +el.dataset.at; const u = Math.min(1, Math.max(0, (g - at) / 0.08));
const pop = u < 1 ? u * (1 + 0.25 * Math.sin(u * Math.PI)) : 1;
el.style.transform = `scale(${pop.toFixed(3)})`;
}
if (g > 0.05) arrow.style.opacity = Math.max(0, 1 - g * 4);
if (!state.done && g > 0.985) {
state.done = true; say.textContent = 'спасибо! теперь оно цветёт'; again.classList.add('show');
}
requestAnimationFrame(frame);
}
stems.forEach((s) => { s.style.strokeDasharray = 1; s.style.strokeDashoffset = 1; });
parts.forEach((el) => el.style.transform = 'scale(0)');
requestAnimationFrame(frame);
</script>
</body>
</html>