Фон из кода: голубое небо переходит в персиковый закат, пушистые облака плывут слоями за курсором, кружатся тёплые лепестки.
Промпт
Сделай мне фон «Закатное небо с объёмными облаками и лепестками» (Сергей Дургалян, MIT). Ниже один HTML-файл: HTML, CSS и чистый JavaScript, без библиотек и картинок. Сначала перенеси его как есть и проверь: небо от голубого к персиковому и розовому, розовые перистые облака вверху, пушистые кучевые внизу со светлыми макушками и розово-сиреневой тенью, облака медленно плывут и сдвигаются за курсором, падают тёплые лепестки, поверх заголовок «Сайты, после которых хочется мечтать» и кнопка. Потом меняй.
Как устроен код:
- Всё небо — функция `createSky(canvas, опции)`: её можно вызвать для любого canvas, она сама следит за размером, паузой на скрытой вкладке и курсором.
- `LAYOUT` — список облаков: вид (`cloud` или `wisp`), положение, размер, глубина (0–1: чем больше, тем сильнее параллакс и дрейф) и тон (`near`, `mid`, `far` в `TONE`: свет, тело, кромка, тень).
- `cloud()` рисует облако один раз в отдельный canvas: силуэт задают несколько гауссовых «башен», внутри раскидываются мягкие круги, они делятся на три слоя по высоте. Для каждого слоя `rimLayer()` рисует тело, тень снизу и свет сверху: это маска слоя минус та же маска со сдвигом, с размытием. Потом общий градиент света, тёплая подсветка снизу и мягкий плоский низ.
- `wisp()` — перистые облака из растянутых размытых эллипсов.
- Каждый кадр `draw()` заливает градиент неба и солнце, сдвигает спрайты облаков (дрейф и параллакс) и двигает лепестки: падение, покачивание, вращение и «переворот» через `scale(1, cos)`.
- Случайность облаков с зерном (`rng(seed)`), поэтому небо одинаковое при каждой загрузке. Лепестки каждый раз новые.
- При `prefers-reduced-motion` небо рисуется один раз и стоит: без дрейфа, параллакса и падения.
Что заменить: цвета неба (`grad` в `build()`), положение солнца (`sun`), тона облаков в `TONE`, композицию в `LAYOUT`, число лепестков (опция `petals`, 0 — без лепестков) и их цвета в `PETAL_COLORS`, зерно `seed` (другая форма облаков), силу параллакса (множители 36 и 18 в `draw()`), контент поверх фона.
Чтобы поставить небо под свой сайт, оставь canvas с `position: fixed; inset: 0` под контентом и вызови `createSky`. Если проект на React: сделай компонент `<SunsetSky />` с canvas через `ref`, вызови `createSky` в `useEffect` и в очистке вызови `stop()` из результата (функция возвращает `{ resize, start, stop }`; обработчики `resize` и `pointermove` она вешает на `window`, в SPA добавь их снятие). На слабых телефонах уменьши число облаков в `LAYOUT` или лепестков.
Предложи цвета неба и тексты первого экрана под мой продукт.
Код скопируется вместе с промптом
Фон для первого экрана: сверху голубое небо, к горизонту оно теплеет до персикового и розового, у горизонта светится солнце. По небу тянутся розовые перистые облака, ниже стоят объёмные кучевые: светлые кремовые макушки, персиковые бока, сиренево-розовая тень снизу, как на анимешном закате. Облака лежат в трёх слоях на разной глубине, медленно дрейфуют и сдвигаются за курсором с разной силой, поэтому небо кажется глубоким. Сверху кружатся и падают тёплые лепестки-конфетти: они переворачиваются в воздухе, и их изнанка темнее. Поверх фона стоит пример контента (заголовок, текст и кнопка), чтобы было видно, как небо работает под сайтом.
Картинок и библиотек нет, всё рисует canvas 2D. Каждое облако рисуется один раз при загрузке: сотни мягких кругов собираются в силуэт с «башнями», делятся на три слоя по глубине, и для каждого слоя накладываются свет сверху и тень снизу. Так появляются те самые «кочаны» внутри облака, а не набор кругов. Потом каждый кадр облака только сдвигаются, поэтому фон держит 60 кадров в секунду. Подходит для лендинга курса, портфолио, приложения для сна или путешествий, промо-страницы, где нужно ощущение лёгкости и мечты. Это небо из прелоадеров «Колода раздаётся веером» и «Кольцо карточек»; приём подсмотрен в рилсе @avi_vashishta29 (портфолио на CSS 3D): оттуда взята только механика, код, тексты и графика свои.
Код
<!-- 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>Sunset Clouds Sky</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,500;0,600;1,500&family=Manrope:wght@500;700&display=swap">
<style>
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; background: #8fb4e6; color: #1c2140; font-family: "Manrope", sans-serif; }
/* the sky: one canvas behind everything */
#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* ---------- Example content on top of the sky ---------- */
.site { position: relative; z-index: 1; height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: 22px clamp(16px, 4vw, 48px); }
nav { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.logo { font: 600 1.6rem/1 "Cormorant", serif; color: inherit; text-decoration: none; }
nav ul { display: flex; gap: clamp(12px, 2.4vw, 28px); margin: 0; padding: 0; list-style: none; font-size: .9rem; }
nav a { color: inherit; text-decoration: none; opacity: .75; }
nav a:hover, nav a:focus-visible { opacity: 1; }
.hero { align-self: center; max-width: 820px; }
.hero small { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; opacity: .7; margin-bottom: 18px; }
h1 { margin: 0; font: 600 clamp(2.7rem, 7.4vw, 6.4rem)/.95 "Cormorant", serif; letter-spacing: -.01em; }
h1 em { font-weight: 500; color: #fff8f0; text-shadow: 0 2px 30px rgba(190, 90, 110, .35); }
.hero p { max-width: 34ch; font-size: clamp(1rem, 1.5vw, 1.15rem); line-height: 1.55; margin: 22px 0 30px; }
.cta { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; }
.btn { font: 700 1rem "Manrope", sans-serif; padding: 16px 28px; border-radius: 999px; border: 0; cursor: pointer;
background: #1c2140; color: #fff8f0; box-shadow: 0 10px 30px rgba(28, 33, 64, .25); transition: transform .2s; }
.btn:hover { transform: translateY(-2px); }
.btn:focus-visible, nav a:focus-visible, .link:focus-visible { outline: 3px solid #fff8f0; outline-offset: 3px; }
.link { color: inherit; font-weight: 700; }
footer { font-size: .82rem; opacity: .75; }
@media (max-width: 600px) { nav ul li:nth-child(n+3) { display: none; } }
</style>
</head>
<body>
<canvas id="sky" aria-hidden="true"></canvas>
<div class="site">
<nav>
<a class="logo" href="#">Мира Ланская.</a>
<ul>
<li><a href="#">Работы</a></li>
<li><a href="#">Курсы</a></li>
<li><a href="#">Обо мне</a></li>
<li><a href="#">Связаться</a></li>
</ul>
</nav>
<main class="hero">
<small>Сайты · бренды · курсы</small>
<h1>Сайты, после которых <em>хочется мечтать</em></h1>
<p>Делаю первые экраны, которые запоминаются, и бренды, которые не стыдно показать инвестору.</p>
<div class="cta">
<button class="btn" type="button">Обсудить проект</button>
<a class="link" href="#">Смотреть работы</a>
</div>
</main>
<footer>Фон: canvas 2D, без картинок и библиотек. Подвигайте курсором.</footer>
</div>
<script>
// Sunset sky: CSS-free canvas background. Clouds are pre-rendered once into sprites
// (hundreds of soft gradient puffs + top light, warm under-glow and lilac shade),
// then every frame only drifts the sprites with parallax and lets warm petals fall.
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
function createSky(cv, opt = {}) {
const ctx = cv.getContext('2d');
const PETAL_COLORS = ['#ff6b4a', '#ffb347', '#ffd166', '#f78fb3', '#e8505b', '#ff9f68'];
// cloud tones: light top, body, lobe rim, bottom shade (rgb)
const TONE = {
near: [[255, 249, 240], [255, 217, 190], [242, 160, 160], [150, 112, 170]],
mid: [[255, 240, 226], [252, 200, 180], [236, 150, 162], [140, 112, 176]],
far: [[255, 228, 220], [246, 186, 184], [226, 150, 176], [128, 120, 190]],
};
// layout: kind, centre x (of width), bottom y (of height), width, height (of cloud unit), depth, tone
const LAYOUT = [
['wisp', .22, .24, .55, .12, .15, 'far'], ['wisp', .82, .17, .5, .1, .15, 'far'], ['wisp', .56, .36, .45, .08, .2, 'far'],
['cloud', .5, .8, 1.15, .3, .25, 'far'],
['cloud', .12, .9, .55, .42, .5, 'mid'], ['cloud', .8, .74, .52, .46, .5, 'mid'],
['cloud', .95, 1.06, .72, .64, 1, 'near'], ['cloud', .04, 1.1, .6, .48, 1, 'near'], ['cloud', .5, 1.16, .72, .36, 1, 'near'],
];
let W = 0, H = 0, D = 1, sprites = [], petals = [], grad, sun, raf = 0, last = 0;
let px = 0, py = 0, tx = 0, ty = 0;
// small seeded random, so the sky looks the same on every load
const rng = (a) => () => { a = a + 0x6d2b79f5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; };
const rgba = (c, a) => `rgba(${c[0]},${c[1]},${c[2]},${a})`;
const mk = (w, h) => { const c = document.createElement('canvas'); c.width = w; c.height = h; return c; };
// paint `mask` in `color` minus the same mask shifted by dx/dy: the light (or shadow) rim of every lobe
function rimLayer(g, mask, color, dx, dy, soft, alpha) {
const t = mk(mask.width, mask.height), tg = t.getContext('2d');
tg.drawImage(mask, 0, 0); tg.globalCompositeOperation = 'source-in'; tg.fillStyle = color; tg.fillRect(0, 0, t.width, t.height);
if (dx || dy) { tg.globalCompositeOperation = 'destination-out'; tg.filter = `blur(${soft}px)`; tg.drawImage(mask, dx, dy); }
g.globalAlpha = alpha; g.drawImage(t, 0, 0); g.globalAlpha = 1;
}
function cloud(w, h, tone, r) {
const c = mk(w, h), g = c.getContext('2d'), [hi, body, rim, shade] = TONE[tone].map((v) => rgba(v, 1));
// silhouette = a few gaussian "towers" over a low base
const towers = Array.from({ length: 4 + (r() * 4 | 0) }, () => ({ x: .2 + r() * .6, w: .06 + r() * .13, h: .35 + r() * .65 }));
const top = (u) => { let v = .2 * Math.exp(-(((u - .5) / .38) ** 2)); for (const t of towers) v = Math.max(v, t.h * Math.exp(-(((u - t.x) / t.w) ** 2))); return v; };
const base = h * .8, pad = h * .05, puffs = [];
const count = Math.round(150 * Math.min(1.8, w / h / 1.5));
for (let k = 0; k < count; k++) {
const u = .05 + r() * .9, t = top(u);
if (t < .07) continue;
const edge = base - t * (base - pad); // top of the cloud at this x
const rad = h * (.05 + .09 * Math.sqrt(t)) * (.6 + r() * .6);
const y = Math.min(base - rad * .4, edge + rad * .9 + r() * Math.max(0, base - edge - rad * 1.3));
puffs.push({ x: u * w, y, r: rad });
}
puffs.sort((a, b) => a.y - b.y);
// three depth bands, back (upper) to front (lower): front lobes overlap the back ones,
// and the rim light of each band draws the inner "cauliflower" edges
const bands = [[], [], []];
puffs.forEach((p, i) => bands[Math.min(2, (i * 3 / puffs.length) | 0)].push(p));
const soft = Math.max(1, h / 150);
for (const band of bands) {
if (!band.length) continue;
const m = mk(w, h), mg = m.getContext('2d'), R = band.reduce((s, p) => s + p.r, 0) / band.length;
mg.filter = `blur(${soft}px)`; mg.fillStyle = '#fff';
for (const p of band) {
mg.beginPath(); mg.arc(p.x, p.y, p.r, 0, 7); mg.fill();
for (let j = 0; j < 3; j++) { // fluff on the upper edge of each puff
const a = -Math.PI * (.1 + r() * .8), rr = p.r * (.25 + r() * .2);
mg.beginPath(); mg.arc(p.x + Math.cos(a) * p.r * .85, p.y + Math.sin(a) * p.r * .85, rr, 0, 7); mg.fill();
}
}
rimLayer(g, m, body, 0, 0, 0, 1);
rimLayer(g, m, shade, -R * .06, -R * .4, R * .25, .6); // underside of the lobes
rimLayer(g, m, rim, R * .04, R * .12, R * .12, .35); // warm edge
rimLayer(g, m, hi, R * .12, R * .38, R * .3, .95); // sunlit tops
rimLayer(g, m, 'rgba(255,253,244,1)', R * .05, R * .14, R * .1, .7); // crisp rim
}
g.globalCompositeOperation = 'source-atop'; // overall light only where the cloud is
let lg = g.createLinearGradient(0, pad, 0, base);
lg.addColorStop(0, 'rgba(255,252,240,.35)'); lg.addColorStop(.5, 'rgba(255,240,225,0)'); lg.addColorStop(1, rgba(TONE[tone][3], .35));
g.fillStyle = lg; g.fillRect(0, 0, w, h);
const rg = g.createRadialGradient(w * .7, base, 0, w * .7, base, w * .55); // warm sunset light from below
rg.addColorStop(0, 'rgba(255,170,110,.35)'); rg.addColorStop(1, 'rgba(255,170,110,0)');
g.fillStyle = rg; g.fillRect(0, 0, w, h);
g.globalCompositeOperation = 'destination-in'; // soft flat bottom
lg = g.createLinearGradient(0, base - h * .1, 0, base + h * .04);
lg.addColorStop(0, '#000'); lg.addColorStop(1, 'rgba(0,0,0,0)');
g.fillStyle = lg; g.fillRect(0, 0, w, h);
return c;
}
function wisp(w, h, r) {
const c = mk(w, h), g = c.getContext('2d');
g.filter = 'blur(' + Math.max(2, h / 14) + 'px)';
for (let k = 0; k < 46; k++) {
const ry = h * (.07 + r() * .1), sx = Math.min(3 + r() * 6, w * .12 / ry);
const x = w * (.18 + r() * .64), y = h * (.5 + (r() - .5) * .35);
g.save(); g.translate(x, y); g.scale(sx, 1);
const gr = g.createRadialGradient(0, -ry * .3, 0, 0, 0, ry);
gr.addColorStop(0, `rgba(255,${222 + (r() * 20 | 0)},${214 + (r() * 20 | 0)},${.35 + r() * .3})`); gr.addColorStop(1, 'rgba(246,170,180,0)');
g.fillStyle = gr; g.beginPath(); g.arc(0, 0, ry, 0, 7); g.fill(); g.restore();
}
return c;
}
function build() {
const r = rng(opt.seed || 7);
const cw = Math.max(W, H * .9), ch = Math.min(H, cw * .62); // cloud unit keeps proportions on tall phones
const q = Math.min(D, 1.25); // sprites are soft: no need for full DPR
sprites = LAYOUT.map(([kind, x, y, w, h, d, tone]) => {
const sw = w * cw, sh = h * ch;
const c = kind === 'wisp' ? wisp(sw * q | 0, sh * q | 0, r) : cloud(sw * q | 0, sh * q | 0, tone, r);
return { c, x: x * W, y: y * H, w: sw, h: sh, d, v: (3 + d * 6) * (r() < .5 ? 1 : .7) };
});
grad = ctx.createLinearGradient(0, 0, 0, H);
grad.addColorStop(0, '#4f86d6'); grad.addColorStop(.38, '#8ab3e8'); grad.addColorStop(.62, '#e9c6c6');
grad.addColorStop(.8, '#f7b9a4'); grad.addColorStop(1, '#f093a0');
sun = ctx.createRadialGradient(W * .7, H * .78, 0, W * .7, H * .78, Math.max(W, H) * .6);
sun.addColorStop(0, 'rgba(255,214,160,.75)'); sun.addColorStop(.4, 'rgba(255,190,160,.25)'); sun.addColorStop(1, 'rgba(255,190,160,0)');
const n = Math.round(Math.min(64, Math.max(18, W * H / 26000)) * (opt.petals ?? 1));
petals = Array.from({ length: n }, () => ({
x: Math.random() * W, y: Math.random() * H, s: 4 + Math.random() * 6, d: .4 + Math.random() * .6,
vy: 16 + Math.random() * 34, sw: 12 + Math.random() * 30, ph: Math.random() * 6.3, fr: .6 + Math.random() * 1.2,
rot: Math.random() * 6.3, vr: (Math.random() - .5) * 3, fl: Math.random() * 6.3, vf: 2 + Math.random() * 4,
col: PETAL_COLORS[(Math.random() * PETAL_COLORS.length) | 0],
}));
}
function resize() {
const box = cv.getBoundingClientRect();
W = Math.max(1, box.width); H = Math.max(1, box.height); D = Math.min(devicePixelRatio || 1, 1.5);
cv.width = W * D | 0; cv.height = H * D | 0;
build(); draw(0, 0);
}
function draw(dt, t) {
px += (tx - px) * Math.min(1, dt * 3); py += (ty - py) * Math.min(1, dt * 3);
ctx.setTransform(D, 0, 0, D, 0, 0);
ctx.fillStyle = grad; ctx.fillRect(0, 0, W, H);
ctx.fillStyle = sun; ctx.fillRect(0, 0, W, H);
for (const s of sprites) {
s.x += s.v * dt;
if (s.x - s.w / 2 > W) s.x -= W + s.w; // wrap around when it drifts away
ctx.drawImage(s.c, s.x - s.w / 2 - px * s.d * 36, s.y - s.h - py * s.d * 18, s.w, s.h);
}
for (const p of petals) {
p.y += p.vy * dt * p.d; p.x += (Math.sin(t * p.fr + p.ph) * p.sw + 8) * dt * p.d;
p.rot += p.vr * dt; p.fl += p.vf * dt;
if (p.y > H + 12) { p.y = -12; p.x = Math.random() * W; }
if (p.x > W + 12) p.x = -12;
const f = Math.cos(p.fl);
ctx.setTransform(D, 0, 0, D, (p.x - px * p.d * 50) * D, (p.y - py * p.d * 25) * D);
ctx.rotate(p.rot); ctx.scale(1, Math.abs(f) < .12 ? .12 : f);
ctx.globalAlpha = .55 + p.d * .45;
ctx.fillStyle = p.col; ctx.beginPath(); ctx.ellipse(0, 0, p.s * p.d * 1.3, p.s * p.d * .7, 0, 0, 7); ctx.fill();
if (f < 0) { ctx.fillStyle = 'rgba(120,40,40,.25)'; ctx.fill(); } // darker back side of the petal
ctx.globalAlpha = 1;
}
}
function loop(now) {
const dt = Math.min(.05, (now - last) / 1000 || 0); last = now;
draw(dt, now / 1000);
raf = requestAnimationFrame(loop);
}
function start() { if (!raf && !opt.reduce && !document.hidden) { last = performance.now(); raf = requestAnimationFrame(loop); } }
function stop() { cancelAnimationFrame(raf); raf = 0; }
addEventListener('pointermove', (e) => { tx = e.clientX / innerWidth - .5; ty = e.clientY / innerHeight - .5; }, { passive: true });
document.addEventListener('visibilitychange', () => (document.hidden ? stop() : start())); // pause on a hidden tab
let rt; addEventListener('resize', () => { clearTimeout(rt); rt = setTimeout(resize, 120); });
resize(); start();
return { resize, start, stop };
}
createSky(document.getElementById('sky'), { reduce });
</script>
</body>
</html>