Журнал Тильды
/
Библиотека промптов
/
Обложка для сайта клиники с анимированным фоном
Обложки, Анимация
Обложка для сайта клиники с анимированным фоном
Первый экран сайта женской клиники: стеклянные ленты на анимированном розовом фоне плавно оживают при наведении курсора.
Обложка сайта клиники с анимированным фоном
Промпт
Вы можете скопировать промпт и вставить его в вайб блок в поле ввода. Подробнее в инструкции.
Сделай первый экран сайта женской клиники WomenClinic: розовая карточка с небольшим отступом от краёв, на фоне WebGL-сцена со стеклянными лентами, которая оживает при наведении.

Намеренно: весь текст Arial, заголовок до 140px обычным начертанием. Ничего не добавляй от себя.

Тексты с data-tilda-edit="y". Canvas только для фона, под ним CSS-градиент. Скрипт — IIFE после HTML, root через document.currentScript?.getRootNode()||document. Ссылки href="#" без перехода.

Тексты. Логотип WomenClinic. Меню: Направления (Гинекология — Плановые осмотры и анализы; Беременность — Ведение от теста до родов; Менопауза — Поддержка и терапия), Врачи, Запись. H1 тремя группами: Доказательная / медицина / для женщин (nbsp). Подзаголовок: Клиника, где врачи руководствуются только научно доказанными методами и знаниями о здоровье женщины. Кнопка: Записаться к врачу.

Секция #fbf1f3, текст #3d0f25, отступ clamp(8px,1vw,12px). Карточка 100svh минус отступы, мин. 560px, радиус 20px, linear-gradient(100deg,#f6d0dc,#eeb0c0 60%,#8c2f52).

Шапка absolute, отступ 16px, 56px, радиус 14px, фон rgb(255 250 251/.68), blur 14px. Логотип 18px/400. Пункты 40px, 12px/500, капс, трекинг .06em, радиус 10px; Запись #6e1f42, белая. Подсветка rgb(61 15 37/.09) скользит за курсором. Дропдаун 280px #fffafb, радиус 14px: клик, Esc, клик вне.

H1: top 120px, left 32px, 11ch, clamp(48px,8.2vw,140.8px), line-height .98, трекинг -.035em.

Низ: left 32px, right 24px, bottom 24px. Подзаголовок 30ch, clamp(17px,1.4vw,20px). Кнопка 52px #6e1f42, 13px/500, капс, радиус 12px; зазор 6px, квадрат 52px #ffd0dc, стрелка #3d0f25 16×16: (2,8)–(13,8), наконечник (9,4)→(13,8)→(9,12), штрих 1.6; при ховере уезжает на 44px, новая въезжает слева.

До 820px: вместо меню кнопка 40px #6e1f42: две линии в крест, панели нет; h1 top 104px, поля 20px, низ столбиком, кнопка на всю ширину. До 520px h1 min(48px,(100vw - 60px)/7.5).

Шейдер, p=(pixel-.5res)/res.y. База: диагональ #8c2f52→#eeb0c0→#f6d0dc, пятно #d9627f справа снизу. Четыре кольца-трубки (центр; радиус; ширина; размытие; непрозрачность):
-1.05,1.5; 1.55; .09; .035; .55
1.25,-1.05; 1.42; .17; .004; 1
1.3,-1.1; 1.78; .03; .003; 1
-1.35,-1.75; 1.62; .27; .13; .95
Нормаль трубки преломляет базу на .16, цвет mix(база*.8,#f6ccd6,.25+.45*диффуз), мягкий блик, слабый френель .28; ширина волнится по углу и шуму. Зерно .03.

Вход 2400ms: ленты доворачиваются и фокусируются, затем кадр стоит. Только при наведении мышью время плавно разгоняется до 1.6 и гаснет после ухода. Вне экрана rAF стоит, DPR до 1.5.

Карточка clip-path inset(3% round 28px)→0, 900ms. Группы: blur 6px, сдвиг 14px, 700ms, задержки 400/450/500ms, cubic-bezier(.23,1,.32,1). Подзаголовок и кнопка: подъём 8px, 600ms, задержки 900/1000ms. Нажатие scale(.97). reduced-motion: статичный кадр.
Скопировать промпт
Код
Вы можете скопировать код и вставить его в вайб блок в раздел код. Подробнее в инструкции.
<section id="vb-w9c-hero" class="vb-w9c-hero" data-section-name="Первый экран WomenClinic" data-vibeblock-unique-section="yes" aria-labelledby="vb-w9c-title">
<style>
.vb-w9c-hero,
.vb-w9c-hero * {
box-sizing: border-box;
}

.vb-w9c-hero input,
.vb-w9c-hero textarea,
.vb-w9c-hero select {
font: inherit;
}

.vb-w9c-hero {
--t-headline-font: Arial, sans-serif;
--t-text-font: Arial, sans-serif;
--pad: clamp(8px, 1vw, 12px);
font-family: var(--t-text-font);
font-size: 17px;
font-weight: 400;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
background: #fbf1f3;
color: #3d0f25;
padding: var(--pad);
width: 100%;
}

.vb-w9c-hero a,
.vb-w9c-hero button {
appearance: none;
-webkit-appearance: none;
font-family: var(--t-text-font);
font-weight: inherit;
color: inherit;
text-decoration: none;
border: 0;
background: none;
padding: 0;
margin: 0;
cursor: pointer;
box-shadow: none;
}

.vb-w9c-hero a:focus-visible,
.vb-w9c-hero button:focus-visible {
outline: 2px solid #3d0f25;
outline-offset: 2px;
}

.vb-w9c-hero .vb-w9c-hero__card {
position: relative;
isolation: isolate;
height: calc(100svh - 2 * var(--pad));
min-height: 560px;
border-radius: 20px;
overflow: hidden;
background: linear-gradient(100deg, #f6d0dc, #eeb0c0 60%, #8c2f52);
animation: vb-w9c-open 900ms cubic-bezier(.77, 0, .175, 1) both;
}

.vb-w9c-hero .vb-w9c-hero__canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
z-index: -2;
display: block;
}

.vb-w9c-hero .vb-w9c-hero__veil {
position: absolute;
inset: 0;
z-index: -1;
background: linear-gradient(to bottom, rgb(255 255 255 / .22), transparent 40%, transparent 72%, rgb(255 255 255 / .28));
pointer-events: none;
}

.vb-w9c-hero .vb-w9c-hero__header {
position: absolute;
z-index: 3;
top: 16px;
left: 16px;
right: 16px;
height: 56px;
padding: 0 8px 0 18px;
border-radius: 14px;
background: rgb(255 250 251 / .68);
backdrop-filter: blur(14px) saturate(1.2);
-webkit-backdrop-filter: blur(14px) saturate(1.2);
display: flex;
align-items: center;
justify-content: space-between;
}

.vb-w9c-hero .vb-w9c-hero__logo {
font-size: 18px;
font-weight: 400;
line-height: 1.5;
letter-spacing: 0;
}

.vb-w9c-hero .vb-w9c-hero__nav {
position: relative;
display: flex;
align-items: center;
gap: 2px;
height: 40px;
}

.vb-w9c-hero .vb-w9c-hero__highlight {
position: absolute;
top: 0;
left: 0;
height: 40px;
background: rgb(61 15 37 / .09);
border-radius: 10px;
pointer-events: none;
opacity: 0;
transition: transform 220ms cubic-bezier(.23, 1, .32, 1), width 220ms cubic-bezier(.23, 1, .32, 1), opacity 150ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__item {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: 40px;
padding: 0 14px;
border-radius: 10px;
font-size: 12px;
font-weight: 500;
line-height: 1;
letter-spacing: .06em;
text-transform: uppercase;
white-space: nowrap;
transition: transform 160ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__item--booking {
margin-left: 6px;
background: #6e1f42;
color: #fff;
}

.vb-w9c-hero .vb-w9c-hero__group {
position: relative;
}

.vb-w9c-hero .vb-w9c-hero__dropdown {
position: absolute;
top: 50px;
left: 0;
width: 280px;
padding: 8px;
border-radius: 14px;
background: #fffafb;
box-shadow: 0 1px 0 rgb(0 0 0 / .04), 0 18px 40px -16px rgb(16 32 24 / .35);
transform-origin: 24px 0;
opacity: 0;
visibility: hidden;
transform: translateY(-4px) scale(.97);
transition: opacity 150ms cubic-bezier(.23, 1, .32, 1), transform 150ms cubic-bezier(.23, 1, .32, 1), visibility 150ms;
pointer-events: none;
}

.vb-w9c-hero .vb-w9c-hero__dropdown--open {
opacity: 1;
visibility: visible;
transform: translateY(0) scale(1);
transition-duration: 200ms;
pointer-events: auto;
}

.vb-w9c-hero .vb-w9c-hero__service {
display: block;
padding: 10px 12px;
border-radius: 10px;
transition: background 150ms ease, transform 160ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__service-name {
display: block;
font-size: 15px;
line-height: 1.4;
}

.vb-w9c-hero .vb-w9c-hero__service-note {
display: block;
margin-top: 2px;
font-size: 13px;
line-height: 1.4;
color: #6b3f52;
}

.vb-w9c-hero .vb-w9c-hero__toggle {
display: none;
width: 40px;
height: 40px;
flex: none;
border-radius: 10px;
background: #6e1f42;
color: #fff;
position: relative;
transition: transform 160ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__line {
position: absolute;
left: 12px;
top: 19.25px;
width: 16px;
height: 1.5px;
background: #fff;
transform: translateY(-3.25px);
transition: transform 220ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__line + .vb-w9c-hero__line {
transform: translateY(3.25px);
}

.vb-w9c-hero .vb-w9c-hero__toggle[aria-pressed="true"] .vb-w9c-hero__line {
transform: rotate(45deg);
}

.vb-w9c-hero .vb-w9c-hero__toggle[aria-pressed="true"] .vb-w9c-hero__line + .vb-w9c-hero__line {
transform: rotate(-45deg);
}

.vb-w9c-hero .vb-w9c-hero__title {
position: absolute;
top: 120px;
left: 32px;
right: 32px;
max-width: 11ch;
margin: 0;
font-family: var(--t-headline-font);
font-weight: 400;
font-size: clamp(48px, 8.2vw, 140.8px);
line-height: .98;
letter-spacing: -.035em;
text-wrap: balance;
}

.vb-w9c-hero .vb-w9c-hero__word {
display: inline-block;
white-space: nowrap;
animation: vb-w9c-word 700ms cubic-bezier(.23, 1, .32, 1) 400ms both;
}

.vb-w9c-hero .vb-w9c-hero__word:nth-child(2) {
animation-delay: 450ms;
}

.vb-w9c-hero .vb-w9c-hero__word:nth-child(3) {
animation-delay: 500ms;
}

.vb-w9c-hero .vb-w9c-hero__bottom {
position: absolute;
left: 32px;
right: 24px;
bottom: 24px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 24px;
}

.vb-w9c-hero .vb-w9c-hero__subtitle {
max-width: 30ch;
margin: 0;
font-size: clamp(17px, 1.4vw, 20px);
line-height: 1.35;
animation: vb-w9c-rise 600ms cubic-bezier(.23, 1, .32, 1) 900ms both;
}

.vb-w9c-hero .vb-w9c-hero__cta {
display: flex;
gap: 6px;
flex-shrink: 0;
animation: vb-w9c-rise 600ms cubic-bezier(.23, 1, .32, 1) 1000ms both;
border-radius: 12px;
}

.vb-w9c-hero .vb-w9c-hero__cta-text {
display: flex;
align-items: center;
justify-content: center;
height: 52px;
padding: 0 20px;
border-radius: 12px;
background: #6e1f42;
color: #fff;
font-size: 13px;
font-weight: 500;
line-height: 1;
letter-spacing: .06em;
text-transform: uppercase;
white-space: nowrap;
transition: background 200ms ease, transform 160ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__cta-square {
position: relative;
display: block;
width: 52px;
height: 52px;
flex: none;
border-radius: 12px;
background: #ffd0dc;
color: #3d0f25;
overflow: hidden;
transition: transform 160ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__arrow {
position: absolute;
left: 18px;
top: 18px;
width: 16px;
height: 16px;
transition: transform 260ms cubic-bezier(.23, 1, .32, 1);
}

.vb-w9c-hero .vb-w9c-hero__arrow--second {
transform: translateX(-44px);
}

.vb-w9c-hero .vb-w9c-hero__item:active,
.vb-w9c-hero .vb-w9c-hero__service:active,
.vb-w9c-hero .vb-w9c-hero__toggle:active {
transform: scale(.97);
}

.vb-w9c-hero .vb-w9c-hero__cta:active .vb-w9c-hero__cta-text,
.vb-w9c-hero .vb-w9c-hero__cta:active .vb-w9c-hero__cta-square {
transform: scale(.97);
}

@media (hover: hover) and (pointer: fine) {
.vb-w9c-hero .vb-w9c-hero__service:hover {
background: rgb(61 15 37 / .07);
}
.vb-w9c-hero .vb-w9c-hero__cta:hover .vb-w9c-hero__cta-text {
background: #541533;
}
.vb-w9c-hero .vb-w9c-hero__cta:hover .vb-w9c-hero__arrow {
transform: translateX(44px);
}
.vb-w9c-hero .vb-w9c-hero__cta:hover .vb-w9c-hero__arrow--second {
transform: translateX(0);
}
}

@media (max-width: 820px) {
.vb-w9c-hero .vb-w9c-hero__nav {
display: none;
}
.vb-w9c-hero .vb-w9c-hero__toggle {
display: block;
}
.vb-w9c-hero .vb-w9c-hero__title {
top: 104px;
left: 20px;
right: 20px;
}
.vb-w9c-hero .vb-w9c-hero__bottom {
left: 20px;
right: 20px;
bottom: 20px;
flex-direction: column;
align-items: flex-start;
gap: 24px;
}
.vb-w9c-hero .vb-w9c-hero__cta {
width: 100%;
}
.vb-w9c-hero .vb-w9c-hero__cta-text {
flex: 1;
}
.vb-w9c-hero .vb-w9c-hero__veil {
background: linear-gradient(to bottom, rgb(255 255 255 / .22), transparent 40%, transparent 60%, rgb(255 255 255 / .66));
}
}

@media (max-width: 520px) {
.vb-w9c-hero .vb-w9c-hero__title {
font-size: min(48px, calc((100vw - 60px)/7.5));
}
}

@media (max-width: 360px) {
.vb-w9c-hero .vb-w9c-hero__veil {
background: linear-gradient(to bottom, rgb(255 255 255 / .45), transparent 55%, rgb(255 255 255 / .78));
}
}

@keyframes vb-w9c-open {
from {
clip-path: inset(3% round 28px);
}
to {
clip-path: inset(0 round 20px);
}
}

@keyframes vb-w9c-word {
from {
opacity: 0;
filter: blur(6px);
transform: translateY(14px);
}
to {
opacity: 1;
filter: blur(0);
transform: translateY(0);
}
}

@keyframes vb-w9c-rise {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

@keyframes vb-w9c-fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

@media (prefers-reduced-motion: reduce) {
.vb-w9c-hero .vb-w9c-hero__card {
animation: none;
}
.vb-w9c-hero .vb-w9c-hero__word,
.vb-w9c-hero .vb-w9c-hero__subtitle,
.vb-w9c-hero .vb-w9c-hero__cta {
animation: vb-w9c-fade 300ms both;
}
.vb-w9c-hero * {
transition: none!important;
}
}
</style>

<div class="vb-w9c-hero__card">
<canvas class="vb-w9c-hero__canvas" aria-hidden="true"></canvas>
<div class="vb-w9c-hero__veil"></div>

<header class="vb-w9c-hero__header">
<a href="#" class="vb-w9c-hero__logo" data-tilda-edit="y">WomenClinic</a>
<nav class="vb-w9c-hero__nav" aria-label="Основная навигация">
<span class="vb-w9c-hero__highlight" aria-hidden="true"></span>
<div class="vb-w9c-hero__group">
<button class="vb-w9c-hero__item" type="button" aria-expanded="false" aria-controls="vb-w9c-directions" data-tilda-edit="y">Направления</button>
<div id="vb-w9c-directions" class="vb-w9c-hero__dropdown" inert>
<a class="vb-w9c-hero__service" href="#">
<span class="vb-w9c-hero__service-name" data-tilda-edit="y">Гинекология</span>
<span class="vb-w9c-hero__service-note" data-tilda-edit="y">Плановые осмотры и анализы</span>
</a>
<a class="vb-w9c-hero__service" href="#">
<span class="vb-w9c-hero__service-name" data-tilda-edit="y">Беременность</span>
<span class="vb-w9c-hero__service-note" data-tilda-edit="y">Ведение от теста до родов</span>
</a>
<a class="vb-w9c-hero__service" href="#">
<span class="vb-w9c-hero__service-name" data-tilda-edit="y">Менопауза</span>
<span class="vb-w9c-hero__service-note" data-tilda-edit="y">Поддержка и терапия</span>
</a>
</div>
</div>
<a href="#" class="vb-w9c-hero__item" data-tilda-edit="y">Врачи</a>
<a href="#" class="vb-w9c-hero__item vb-w9c-hero__item--booking" data-tilda-edit="y">Запись</a>
</nav>
<button class="vb-w9c-hero__toggle" type="button" aria-label="Переключить значок меню" aria-pressed="false"><span class="vb-w9c-hero__line"></span><span class="vb-w9c-hero__line"></span></button>
</header>

<h1 id="vb-w9c-title" class="vb-w9c-hero__title"><span class="vb-w9c-hero__word" data-tilda-edit="y">Доказательная</span> <span class="vb-w9c-hero__word" data-tilda-edit="y">медицина</span> <span class="vb-w9c-hero__word" data-tilda-edit="y">для&nbsp;женщин</span></h1>

<div class="vb-w9c-hero__bottom">
<p class="vb-w9c-hero__subtitle" data-tilda-edit="y">Клиника, где врачи руководствуются только научно доказанными методами и знаниями о здоровье женщины</p>
<a href="#" class="vb-w9c-hero__cta">
<span class="vb-w9c-hero__cta-text" data-tilda-edit="y">Записаться к врачу</span>
<span class="vb-w9c-hero__cta-square" aria-hidden="true">
<svg class="vb-w9c-hero__arrow" viewBox="0 0 16 16" fill="none"><path d="M2 8h11M9 4l4 4-4 4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
<svg class="vb-w9c-hero__arrow vb-w9c-hero__arrow--second" viewBox="0 0 16 16" fill="none"><path d="M2 8h11M9 4l4 4-4 4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
</span>
</a>
</div>
</div>

<script>
(function () {
'use strict';
const scope = document.currentScript?.getRootNode() || document;
const root = scope.querySelector('#vb-w9c-hero');
if (!root) return;
const $ = s => root.querySelector(s),
card = $('.vb-w9c-hero__card'),
nav = $('.vb-w9c-hero__nav'),
highlight = $('.vb-w9c-hero__highlight'),
trigger = $('.vb-w9c-hero__group button'),
dropdown = $('.vb-w9c-hero__dropdown'),
toggle = $('.vb-w9c-hero__toggle'),
mouse = matchMedia('(hover:hover) and (pointer:fine)'),
reduced = matchMedia('(prefers-reduced-motion:reduce)');
let highlighted = false;
function close(focus) {
trigger.setAttribute('aria-expanded', 'false');
dropdown.classList.remove('vb-w9c-hero__dropdown--open');
dropdown.inert = true;
if (focus) trigger.focus()
}
trigger.addEventListener('click', () => {
const open = trigger.getAttribute('aria-expanded') !== 'true';
trigger.setAttribute('aria-expanded', String(open));
dropdown.classList.toggle('vb-w9c-hero__dropdown--open', open);
dropdown.inert = !open
});
document.addEventListener('click', ev => {
if (!ev.composedPath().includes(trigger.parentElement)) close(false)
});
document.addEventListener('keydown', ev => {
if (ev.key === 'Escape' && trigger.getAttribute('aria-expanded') === 'true') {
close(true)
}
});
toggle.addEventListener('click', () => toggle.setAttribute('aria-pressed', String(toggle.getAttribute('aria-pressed') !== 'true')));
root.querySelectorAll('a[href="#"]').forEach(a => a.addEventListener('click', ev => ev.preventDefault()));
function hideHighlight() {
highlight.style.opacity = '0';
highlighted = false
}
nav.addEventListener('pointerleave', hideHighlight);
nav.querySelectorAll('.vb-w9c-hero__item').forEach(item => item.addEventListener('pointerenter', () => {
if (!mouse.matches) return;
if (item.classList.contains('vb-w9c-hero__item--booking')) {
hideHighlight();
return
}
const a = item.getBoundingClientRect(),
b = nav.getBoundingClientRect();
if (!highlighted) highlight.style.transition = 'none';
highlight.style.width = a.width+'px';
highlight.style.transform = 'translateX('+(a.left-b.left)+'px)';
highlight.style.opacity = '1';
if (!highlighted) {
void highlight.offsetWidth;
highlight.style.transition = ''
}
highlighted = true
}));
const canvas = $('canvas');
let gl;
try {
gl = canvas.getContext('webgl', {alpha: false, antialias: false, powerPreference: 'low-power'})
} catch (err) {
}
if (!gl) return;
const vertex = 'attribute vec2 position;void main(){gl_Position=vec4(position,0.,1.);}';
const fragment = `
precision highp float;
uniform vec2 resolution;
uniform float t;
uniform float e;
const vec3 shadow = vec3(140., 47., 82.)/255.;
const vec3 mid = vec3(238., 176., 192.)/255.;
const vec3 light = vec3(246., 208., 220.)/255.;
const vec3 glass = vec3(246., 204., 214.)/255.;
const vec3 accent = vec3(217., 98., 127.)/255.;
vec2 rot(vec2 v, float a) {
return vec2(v.x*cos(a)+v.y*sin(a), -v.x*sin(a)+v.y*cos(a));
}
float h(vec2 v) {
return fract(sin(dot(v, vec2(127.1, 311.7)))*43758.5453);
}
float noise(vec2 v) {
vec2 i = floor(v),
f = fract(v);
f = f*f*(3.-2.*f);
return mix(mix(h(i), h(i+vec2(1., 0.)), f.x), mix(h(i+vec2(0., 1.)), h(i+vec2(1., 1.)), f.x), f.y);
}
vec3 base(vec2 p, vec2 LD) {
float g = clamp(dot(p, normalize(LD))*.62+.5, 0., 1.);
vec3 c = mix(shadow, mid, smoothstep(.05, .6, g));
c = mix(c, light, smoothstep(.55, 1., g));
vec2 r = p-vec2(.45, -.3);
return mix(c, accent, .55*exp(-4.*dot(r, r)));
}
vec3 ribbon(vec3 scene, vec2 p, vec2 LD, vec2 center, float radius, float width, float blur, float amount, float phase, float opacity, float parallax) {
vec2 q = rot(p-center, (1.-e)*.55*parallax+sin(t*.25+phase)*.07*parallax);
float ang = atan(q.y, q.x);
radius += sin(t*.31+phase)*.03*parallax;
blur += (1.-e)*.14;
float d = length(q)-radius-(noise(vec2(ang*1.4+phase, t*.12+phase))-.5)*.1;
float W = width*(.72+.38*sin(ang*2.2+phase+t*.08));
float s = d/W,
b = blur/W;
float coverage = 1.-smoothstep(1.-b, 1.+b, abs(s));
if (coverage<=0.) return scene;
float ss = clamp(s, -1., 1.);
float z = sqrt(max(0., 1.-ss*ss));
vec3 N = normalize(vec3(normalize(q)*ss, z+.05));
vec3 L = normalize(vec3(LD, .9));
float diffuse = max(dot(N, L), 0.);
float spec = pow(max(dot(reflect(-L, N), vec3(0., 0., 1.)), 0.), mix(70., 6., clamp(blur*8., 0., 1.)));
spec *= .45+.55*(.5+.5*sin(3.*ang-1.2*t+phase));
float fresnel = pow(1.-z, 2.2);
vec3 refraction = base(p+N.xy*.16, LD);
vec3 body = mix(glass, accent, amount);
vec3 color = mix(refraction*.8, body, .25+.45*diffuse);
color = mix(color, shadow, .35*(1.-diffuse));
color += vec3(1.)*(spec*.95+fresnel*.28);
float a = coverage*opacity;
return scene*(1.-a)+color*a;
}
void main() {
vec2 pixel = gl_FragCoord.xy;
vec2 p = (pixel-.5*resolution)/resolution.y;
vec2 uv = pixel/resolution;
vec2 LD = rot(vec2(-1., .12), sin(t*.15)*.18);
vec3 color = base(p, LD);
color = ribbon(color, p, LD, vec2(-1.05, 1.5), 1.55, .09, .035, .05, 1.3, .55, .5);
color = ribbon(color, p, LD, vec2(1.25, -1.05), 1.42, .17, .004, .12, 0., 1., 1.);
color = ribbon(color, p, LD, vec2(1.3, -1.1), 1.78, .03, .003, .75, 2.1, 1., 1.15);
color = ribbon(color, p, LD, vec2(-1.35, -1.75), 1.62, .27, .13, .55, 4.2, .95, 1.8);
color *= .9+.18*uv.y;
color = mix(vec3(251., 241., 243.)/255., color, smoothstep(0., 1., e));
color += (h(pixel+fract(t))-.5)*.03;
gl_FragColor = vec4(color, 1.);
}
`;
function compile(type, source) {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
gl.deleteShader(shader);
throw new Error('shader')
}
return shader
}
let program;
try {
program = gl.createProgram();
const vs = compile(gl.VERTEX_SHADER, vertex),
fs = compile(gl.FRAGMENT_SHADER, fragment);
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
gl.deleteShader(vs);
gl.deleteShader(fs);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error('program')
} catch (err) {
canvas.style.display = 'none';
return
}
gl.useProgram(program);
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), gl.STATIC_DRAW);
const position = gl.getAttribLocation(program, 'position');
gl.enableVertexAttribArray(position);
gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);
const ur = gl.getUniformLocation(program, 'resolution'),
ut = gl.getUniformLocation(program, 't'),
ue = gl.getUniformLocation(program, 'e');
let raf = 0,
start = null,
last = null,
time = 0,
speed = 0,
hover = false,
visible = true,
progress = reduced.matches ? 1 : 0,
lost = false,
resizeTimer;
function resize() {
const rect = card.getBoundingClientRect(),
dpr = Math.min(devicePixelRatio || 1, 1.5);
canvas.width = Math.max(1, Math.round(rect.width*dpr));
canvas.height = Math.max(1, Math.round(rect.height*dpr));
gl.viewport(0, 0, canvas.width, canvas.height)
}
function draw() {
if (lost) return;
gl.uniform2f(ur, canvas.width, canvas.height);
gl.uniform1f(ut, time);
gl.uniform1f(ue, progress);
gl.drawArrays(gl.TRIANGLES, 0, 6)
}
function wake() {
if (!raf && visible && !document.hidden && !lost) {
last = null;
raf = requestAnimationFrame(frame)
}
}
function frame(now) {
raf = 0;
if (!visible || document.hidden || lost) return;
if (start === null) start = now;
const dt = last === null ? 0 : Math.min((now-last)/1000, .05);
last = now;
if (reduced.matches) {
progress = 1;
speed = 0;
draw();
return
}
const x = Math.min(1, (now-start)/2400);
progress = 1-Math.pow(1-x, 3);
const target = mouse.matches && hover ? 1 : 0;
speed += (target-speed)*(target?.035 : .05);
if (mouse.matches && (hover || progress>=1)) time += dt*speed*1.6;
draw();
if (progress<1 || target || speed>=.002) raf = requestAnimationFrame(frame);
else speed = 0
}
card.addEventListener('pointerenter', () => {
if (mouse.matches) {
hover = true;
wake()
}
});
card.addEventListener('pointerleave', () => {
hover = false;
wake()
});
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
hover = false;
speed = 0;
if (raf) cancelAnimationFrame(raf);
raf = 0;
last = null
} else wake()
});
if ('IntersectionObserver' in window) new IntersectionObserver(entries => {
visible = entries[0].isIntersecting;
if (visible) wake();
else {
if (raf) cancelAnimationFrame(raf);
raf = 0;
last = null
}
}, {threshold: 0}).observe(root);
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
if (!lost) {
resize();
if (visible && !document.hidden) draw()
}
}, 120)
});
reduced.addEventListener('change', () => {
if (reduced.matches) {
progress = 1;
speed = 0
}
wake()
});
canvas.addEventListener('webglcontextlost', ev => {
ev.preventDefault();
lost = true;
cancelAnimationFrame(raf);
raf = 0;
canvas.style.display = 'none'
});
resize();
wake();
})();
</script>
</section>
Скопировать код
Что выбрать, промпт или код?
Копируйте промпт, если хотите получить похожий результат, но ввести информацию о своём бизнесе и задать свои требования. Например, изменить кнопки, тексты, цвета, фотографии или другие элементы.
Копируйте код, если хотите получить точно такой же блок. Чтобы его изменить, придётся отредактировать html-код.
Начните создание сайта на Тильде с простой регистрации на платформе
Made on
Tilda