docs(site): replace CSS blobs with liquid aurora WebGL
Upgrade the hero background to a domain-warped FBM fluid shader with theme palettes, dithering, soft pointer pull, and motion-safe fallbacks.
This commit is contained in:
+2
-1
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- **Hero aurora background**: soft animated green/teal/violet aurora wash on the marketing site hero, with reduced-motion static fallback. / **Hero 极光背景**:官网首屏加入缓慢漂移的绿/青/紫极光柔光,并在减少动态模式下退回静态。
|
- **Liquid aurora hero**: WebGL2 domain-warped FBM shader — slow green/teal/violet fluid, dithering, pointer pull, offscreen pause, and reduced-motion static frame (CSS gradient fallback). / **液态极光 Hero**:WebGL2 domain-warped FBM 着色器——缓慢绿/青/紫流体、抖动去色带、轻微指针牵引、离屏暂停、减少动态模式下静态帧(CSS 渐变回退)。
|
||||||
- **App Store download badges**: official badges on bilingual READMEs (hero + Get sections) and the website, with China-store `/cn/` links for Chinese and regionless App Store links for English. / **App Store 下载徽章**:中英文 README(顶部与获取区)与官网挂载官方徽章;中文链 `/cn/`,英文用无地区链接。
|
- **App Store download badges**: official badges on bilingual READMEs (hero + Get sections) and the website, with China-store `/cn/` links for Chinese and regionless App Store links for English. / **App Store 下载徽章**:中英文 README(顶部与获取区)与官网挂载官方徽章;中文链 `/cn/`,英文用无地区链接。
|
||||||
- **Website SEO & AI discovery**: richer meta/JSON-LD/FAQ, `llms.txt`, expanded sitemap, English landing, plus install / compare / Mac-dictation content pages. / **官网 SEO 与 AI 发现**:强化 meta/JSON-LD/FAQ、`llms.txt`、sitemap,并新增英文落地页与安装 / 对比 / Mac 听写专题页。
|
- **Website SEO & AI discovery**: richer meta/JSON-LD/FAQ, `llms.txt`, expanded sitemap, English landing, plus install / compare / Mac-dictation content pages. / **官网 SEO 与 AI 发现**:强化 meta/JSON-LD/FAQ、`llms.txt`、sitemap,并新增英文落地页与安装 / 对比 / Mac 听写专题页。
|
||||||
- **Context-aware polish safeguards**: polish can use a redacted cursor-neighborhood snapshot for natural continuation, validates protected terms and identifiers, retries once, and falls back to a conservative local cleanup when needed. / **上下文润色护栏**:润色可使用经截断脱敏的光标附近文字自然衔接,并校验受保护词与标识符;失败时重试一次,仍不合格则降级为本地保守清理。
|
- **Context-aware polish safeguards**: polish can use a redacted cursor-neighborhood snapshot for natural continuation, validates protected terms and identifiers, retries once, and falls back to a conservative local cleanup when needed. / **上下文润色护栏**:润色可使用经截断脱敏的光标附近文字自然衔接,并校验受保护词与标识符;失败时重试一次,仍不合格则降级为本地保守清理。
|
||||||
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- **Polish never answers the transcript**: fun styles (dating / flex / corp) could turn “你觉得这个包怎么样” into a reply such as “还行,挺顺眼的”. A top-priority “polish only, never answer” rule now sits in the global contract, every built-in style pack, the prompt safety boundary, and a router question guard that keeps question drafts as questions. / **润色不再代答转写内容**:趣味风格(直男癌/装逼指南/大厂黑话)曾把「你觉得这个包怎么样」润色成「还行,挺顺眼的」。现已在全局契约、全部内置风格包、提示词安全边界与路由问句守卫四层加入最高优先级的「只润色、不作答」规则,问句必须仍是问句。
|
- **Polish never answers the transcript**: fun styles (dating / flex / corp) could turn “你觉得这个包怎么样” into a reply such as “还行,挺顺眼的”. A top-priority “polish only, never answer” rule now sits in the global contract, every built-in style pack, the prompt safety boundary, and a router question guard that keeps question drafts as questions. / **润色不再代答转写内容**:趣味风格(直男癌/装逼指南/大厂黑话)曾把「你觉得这个包怎么样」润色成「还行,挺顺眼的」。现已在全局契约、全部内置风格包、提示词安全边界与路由问句守卫四层加入最高优先级的「只润色、不作答」规则,问句必须仍是问句。
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- **Website download actions**: App Store and source buttons now share a compact rounded-rectangle shape and matching height instead of mixing badge and pill silhouettes. / **官网操作按钮**:App Store 与源码按钮统一为等高的紧凑圆角矩形,不再混用徽章与胶囊轮廓。
|
||||||
- **Layered bilingual polish prompts**: transcripts are sent once as user data; stable Chinese/English core rules, style policies, dictionaries, and runtime context now have explicit responsibilities for better consistency and provider prefix caching. / **分层双语润色提示词**:转写仅作为用户消息发送一次;稳定的中英文核心规则、风格策略、词典和运行时上下文职责明确,提升一致性并支持服务商前缀缓存。
|
- **Layered bilingual polish prompts**: transcripts are sent once as user data; stable Chinese/English core rules, style policies, dictionaries, and runtime context now have explicit responsibilities for better consistency and provider prefix caching. / **分层双语润色提示词**:转写仅作为用户消息发送一次;稳定的中英文核心规则、风格策略、词典和运行时上下文职责明确,提升一致性并支持服务商前缀缓存。
|
||||||
- **Two-tier short polish skip**: ultra-short (≤4 CJK) still skips the LLM; 5–10 CJK now skips only low-value acks/closings (e.g. “好的我知道了”), while questions and contentful shorts still polish. / **两级短句跳过润色**:≤4 字仍跳过 LLM;5–10 字仅对低价值确认/收束语跳过(如「好的我知道了」),问句与有内容短句仍走润色。
|
- **Two-tier short polish skip**: ultra-short (≤4 CJK) still skips the LLM; 5–10 CJK now skips only low-value acks/closings (e.g. “好的我知道了”), while questions and contentful shorts still polish. / **两级短句跳过润色**:≤4 字仍跳过 LLM;5–10 字仅对低价值确认/收束语跳过(如「好的我知道了」),问句与有内容短句仍走润色。
|
||||||
- **ABE polish routing**: fun styles and daily chat use a local information-density gate, prompt hard-brakes, and style-specific degrade (e.g. DiBa without an opponent quote falls back to chat cleanup) without a second LLM call. / **ABE 润色路由**:趣味风格与日常聊天增加本地信息密度闸、提示词硬刹车与风格专属降级(如帝吧无对方原话时降级日常清理),不增加第二次 LLM 调用。
|
- **ABE polish routing**: fun styles and daily chat use a local information-density gate, prompt hard-brakes, and style-specific degrade (e.g. DiBa without an opponent quote falls back to chat cleanup) without a second LLM call. / **ABE 润色路由**:趣味风格与日常聊天增加本地信息密度闸、提示词硬刹车与风格专属降级(如帝吧无对方原话时降级日常清理),不增加第二次 LLM 调用。
|
||||||
|
|||||||
+349
-92
@@ -310,8 +310,9 @@
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.45rem;
|
gap: 0.45rem;
|
||||||
padding: 0.85rem 1.35rem;
|
height: 44px;
|
||||||
border-radius: 999px;
|
padding: 0 1.2rem;
|
||||||
|
border-radius: 9px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
@@ -337,86 +338,42 @@
|
|||||||
}
|
}
|
||||||
.hero-aurora {
|
.hero-aurora {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: -12% -8% -18%;
|
inset: 0;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.hero-aurora-canvas {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.6s ease;
|
||||||
|
}
|
||||||
|
.hero-aurora.is-ready .hero-aurora-canvas { opacity: 1; }
|
||||||
|
.hero-aurora-fallback {
|
||||||
|
position: absolute;
|
||||||
|
inset: -20% -10%;
|
||||||
|
background:
|
||||||
|
radial-gradient(ellipse 55% 45% at 18% 28%, var(--aurora-a), transparent 70%),
|
||||||
|
radial-gradient(ellipse 50% 40% at 82% 22%, var(--aurora-b), transparent 68%),
|
||||||
|
radial-gradient(ellipse 48% 42% at 52% 62%, var(--aurora-c), transparent 72%),
|
||||||
|
radial-gradient(ellipse 40% 35% at 30% 78%, var(--aurora-d), transparent 70%);
|
||||||
|
filter: blur(40px);
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
.hero-aurora.is-ready .hero-aurora-fallback { opacity: 0; }
|
||||||
.hero-aurora::after {
|
.hero-aurora::after {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background:
|
background:
|
||||||
linear-gradient(180deg, transparent 55%, var(--hero-wash) 96%),
|
linear-gradient(180deg, transparent 52%, var(--hero-wash) 94%),
|
||||||
radial-gradient(ellipse 70% 50% at 50% 0%, transparent 40%, var(--hero-wash) 100%);
|
radial-gradient(ellipse 80% 55% at 50% -5%, transparent 35%, var(--hero-wash) 100%);
|
||||||
opacity: 0.85;
|
|
||||||
}
|
|
||||||
.aurora-blob {
|
|
||||||
position: absolute;
|
|
||||||
border-radius: 50%;
|
|
||||||
filter: blur(72px);
|
|
||||||
will-change: transform, opacity;
|
|
||||||
mix-blend-mode: normal;
|
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
pointer-events: none;
|
||||||
.aurora-blob-1 {
|
|
||||||
width: min(72vw, 720px);
|
|
||||||
height: min(52vw, 520px);
|
|
||||||
top: -8%;
|
|
||||||
left: -6%;
|
|
||||||
background: var(--aurora-a);
|
|
||||||
animation: aurora-drift-1 22s ease-in-out infinite alternate;
|
|
||||||
}
|
|
||||||
.aurora-blob-2 {
|
|
||||||
width: min(64vw, 640px);
|
|
||||||
height: min(48vw, 480px);
|
|
||||||
top: 8%;
|
|
||||||
right: -10%;
|
|
||||||
background: var(--aurora-b);
|
|
||||||
animation: aurora-drift-2 28s ease-in-out infinite alternate;
|
|
||||||
}
|
|
||||||
.aurora-blob-3 {
|
|
||||||
width: min(58vw, 560px);
|
|
||||||
height: min(42vw, 420px);
|
|
||||||
top: 28%;
|
|
||||||
left: 28%;
|
|
||||||
background: var(--aurora-c);
|
|
||||||
animation: aurora-drift-3 26s ease-in-out infinite alternate;
|
|
||||||
}
|
|
||||||
.aurora-blob-4 {
|
|
||||||
width: min(48vw, 440px);
|
|
||||||
height: min(36vw, 360px);
|
|
||||||
bottom: 6%;
|
|
||||||
left: 12%;
|
|
||||||
background: var(--aurora-d);
|
|
||||||
animation: aurora-drift-4 20s ease-in-out infinite alternate;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
@keyframes aurora-drift-1 {
|
|
||||||
0% { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
|
|
||||||
50% { transform: translate3d(12%, 10%, 0) scale(1.12) rotate(8deg); }
|
|
||||||
100% { transform: translate3d(6%, 18%, 0) scale(1.05) rotate(-4deg); }
|
|
||||||
}
|
|
||||||
@keyframes aurora-drift-2 {
|
|
||||||
0% { transform: translate3d(0, 0, 0) scale(1.05) rotate(0deg); }
|
|
||||||
50% { transform: translate3d(-14%, 12%, 0) scale(1.18) rotate(-10deg); }
|
|
||||||
100% { transform: translate3d(-8%, 20%, 0) scale(0.96) rotate(6deg); }
|
|
||||||
}
|
|
||||||
@keyframes aurora-drift-3 {
|
|
||||||
0% { transform: translate3d(0, 0, 0) scale(0.95); opacity: 0.75; }
|
|
||||||
50% { transform: translate3d(-10%, -8%, 0) scale(1.2); opacity: 1; }
|
|
||||||
100% { transform: translate3d(10%, 6%, 0) scale(1.05); opacity: 0.8; }
|
|
||||||
}
|
|
||||||
@keyframes aurora-drift-4 {
|
|
||||||
0% { transform: translate3d(0, 0, 0) scale(1); }
|
|
||||||
100% { transform: translate3d(18%, -12%, 0) scale(1.15); }
|
|
||||||
}
|
|
||||||
html[data-theme="dark"] .aurora-blob,
|
|
||||||
html[data-theme="system"] .aurora-blob {
|
|
||||||
mix-blend-mode: screen;
|
|
||||||
}
|
|
||||||
@media (prefers-color-scheme: light) {
|
|
||||||
html[data-theme="system"] .aurora-blob { mix-blend-mode: normal; }
|
|
||||||
}
|
}
|
||||||
.hero .wrap { position: relative; z-index: 1; }
|
.hero .wrap { position: relative; z-index: 1; }
|
||||||
.hero-copy {
|
.hero-copy {
|
||||||
@@ -460,7 +417,7 @@
|
|||||||
.store-badge {
|
.store-badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
border-radius: 8px;
|
border-radius: 9px;
|
||||||
transition: opacity 0.15s ease, transform 0.15s ease;
|
transition: opacity 0.15s ease, transform 0.15s ease;
|
||||||
}
|
}
|
||||||
.store-badge:hover { opacity: 0.9; transform: translateY(-1px); }
|
.store-badge:hover { opacity: 0.9; transform: translateY(-1px); }
|
||||||
@@ -894,20 +851,7 @@
|
|||||||
}
|
}
|
||||||
.reveal { opacity: 1; transform: none; }
|
.reveal { opacity: 1; transform: none; }
|
||||||
.hero-stage { opacity: 1; transform: none; }
|
.hero-stage { opacity: 1; transform: none; }
|
||||||
.aurora-blob {
|
.hero-aurora-canvas { transition: none; }
|
||||||
filter: blur(64px);
|
|
||||||
opacity: 0.55;
|
|
||||||
will-change: auto;
|
|
||||||
}
|
|
||||||
.aurora-blob-1 { transform: translate3d(4%, 6%, 0); }
|
|
||||||
.aurora-blob-2 { transform: translate3d(-6%, 8%, 0); }
|
|
||||||
.aurora-blob-3 { transform: translate3d(-2%, 0, 0); }
|
|
||||||
.aurora-blob-4 { transform: translate3d(8%, -4%, 0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 720px) {
|
|
||||||
.aurora-blob { filter: blur(56px); }
|
|
||||||
.aurora-blob-4 { display: none; }
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@@ -947,11 +891,9 @@
|
|||||||
<main id="top">
|
<main id="top">
|
||||||
<!-- Hero -->
|
<!-- Hero -->
|
||||||
<section class="hero">
|
<section class="hero">
|
||||||
<div class="hero-aurora" aria-hidden="true">
|
<div class="hero-aurora" id="heroAurora" aria-hidden="true">
|
||||||
<span class="aurora-blob aurora-blob-1"></span>
|
<div class="hero-aurora-fallback"></div>
|
||||||
<span class="aurora-blob aurora-blob-2"></span>
|
<canvas class="hero-aurora-canvas" id="heroAuroraCanvas"></canvas>
|
||||||
<span class="aurora-blob aurora-blob-3"></span>
|
|
||||||
<span class="aurora-blob aurora-blob-4"></span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="hero-copy">
|
<div class="hero-copy">
|
||||||
@@ -1633,6 +1575,319 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Liquid Aurora — domain-warped FBM WebGL2 shader (vanilla, no deps)
|
||||||
|
const liquidAurora = (() => {
|
||||||
|
const wrap = document.getElementById("heroAurora");
|
||||||
|
const canvas = document.getElementById("heroAuroraCanvas");
|
||||||
|
if (!wrap || !canvas) return { setPalette() {}, destroy() {} };
|
||||||
|
|
||||||
|
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||||
|
const gl = canvas.getContext("webgl2", {
|
||||||
|
alpha: true,
|
||||||
|
antialias: false,
|
||||||
|
depth: false,
|
||||||
|
stencil: false,
|
||||||
|
premultipliedAlpha: true,
|
||||||
|
powerPreference: "low-power"
|
||||||
|
});
|
||||||
|
if (!gl) return { setPalette() {}, destroy() {} };
|
||||||
|
|
||||||
|
const VERT = `#version 300 es
|
||||||
|
in vec2 a_pos;
|
||||||
|
void main(){ gl_Position = vec4(a_pos, 0.0, 1.0); }`;
|
||||||
|
|
||||||
|
const FRAG = `#version 300 es
|
||||||
|
precision highp float;
|
||||||
|
uniform vec2 u_res;
|
||||||
|
uniform float u_time;
|
||||||
|
uniform float u_speed;
|
||||||
|
uniform float u_contrast;
|
||||||
|
uniform float u_warp;
|
||||||
|
uniform float u_scale;
|
||||||
|
uniform float u_intensity;
|
||||||
|
uniform vec2 u_pointer;
|
||||||
|
uniform float u_pointerStrength;
|
||||||
|
uniform vec3 u_base;
|
||||||
|
uniform vec3 u_deep;
|
||||||
|
uniform vec3 u_colorA;
|
||||||
|
uniform vec3 u_colorB;
|
||||||
|
uniform vec3 u_hot;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
float hash(vec2 p){
|
||||||
|
p = fract(p * vec2(123.34, 456.21));
|
||||||
|
p += dot(p, p + 45.32);
|
||||||
|
return fract(p.x * p.y);
|
||||||
|
}
|
||||||
|
float noise(vec2 p){
|
||||||
|
vec2 i = floor(p);
|
||||||
|
vec2 f = fract(p);
|
||||||
|
float a = hash(i);
|
||||||
|
float b = hash(i + vec2(1.0, 0.0));
|
||||||
|
float c = hash(i + vec2(0.0, 1.0));
|
||||||
|
float d = hash(i + vec2(1.0, 1.0));
|
||||||
|
vec2 u = f * f * (3.0 - 2.0 * f);
|
||||||
|
return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
|
||||||
|
}
|
||||||
|
float fbm(vec2 p){
|
||||||
|
float v = 0.0;
|
||||||
|
float a = 0.5;
|
||||||
|
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
v += a * noise(p);
|
||||||
|
p = m * p;
|
||||||
|
a *= 0.5;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
vec2 uv = gl_FragCoord.xy / u_res;
|
||||||
|
float aspect = u_res.x / max(u_res.y, 1.0);
|
||||||
|
vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
|
||||||
|
p *= u_scale;
|
||||||
|
|
||||||
|
// Soft pointer pull
|
||||||
|
vec2 ptr = (u_pointer - 0.5) * vec2(aspect, 1.0);
|
||||||
|
p += (ptr - p) * u_pointerStrength * 0.08;
|
||||||
|
|
||||||
|
float t = u_time * u_speed;
|
||||||
|
|
||||||
|
// Domain warp — liquid marble / aurora veins
|
||||||
|
vec2 q = vec2(fbm(p + vec2(0.0, t * 0.15)), fbm(p + vec2(5.2, -t * 0.12)));
|
||||||
|
vec2 r = vec2(
|
||||||
|
fbm(p + u_warp * q + vec2(1.7, 9.2) + t * 0.07),
|
||||||
|
fbm(p + u_warp * q + vec2(8.3, 2.8) - t * 0.05)
|
||||||
|
);
|
||||||
|
float f = fbm(p + u_warp * r);
|
||||||
|
|
||||||
|
// Extra shimmer ribbon
|
||||||
|
float ribbon = fbm(p * 1.4 + r * 1.8 + vec2(t * 0.04, -t * 0.06));
|
||||||
|
float veins = smoothstep(0.35, 0.78, f + ribbon * 0.25);
|
||||||
|
veins = pow(veins, mix(1.8, 0.85, clamp(u_contrast - 0.6, 0.0, 1.0)));
|
||||||
|
|
||||||
|
vec3 col = u_base;
|
||||||
|
col = mix(col, u_deep, smoothstep(0.15, 0.55, f));
|
||||||
|
col = mix(col, u_colorA, veins * 0.95);
|
||||||
|
col = mix(col, u_colorB, smoothstep(0.55, 0.92, ribbon) * veins);
|
||||||
|
col = mix(col, u_hot, pow(smoothstep(0.72, 0.98, f * ribbon), 2.2) * 0.65);
|
||||||
|
|
||||||
|
// Soft vignette so content stays readable
|
||||||
|
float vig = 1.0 - smoothstep(0.35, 1.15, length((uv - 0.5) * vec2(1.05, 1.25)));
|
||||||
|
col *= mix(0.55, 1.0, vig);
|
||||||
|
col *= u_intensity;
|
||||||
|
|
||||||
|
// Blue-noise-ish dither to kill banding
|
||||||
|
float dither = (hash(gl_FragCoord.xy + fract(t * 13.7)) - 0.5) / 255.0;
|
||||||
|
col += dither;
|
||||||
|
|
||||||
|
// Fade toward bottom for hero fade-out
|
||||||
|
float bottom = smoothstep(1.0, 0.55, uv.y);
|
||||||
|
float alpha = clamp(0.35 + veins * 0.75, 0.0, 0.95) * bottom;
|
||||||
|
fragColor = vec4(col * alpha, alpha);
|
||||||
|
}`;
|
||||||
|
|
||||||
|
function compile(type, src) {
|
||||||
|
const s = gl.createShader(type);
|
||||||
|
gl.shaderSource(s, src);
|
||||||
|
gl.compileShader(s);
|
||||||
|
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) {
|
||||||
|
console.warn("[aurora]", gl.getShaderInfoLog(s));
|
||||||
|
gl.deleteShader(s);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const vs = compile(gl.VERTEX_SHADER, VERT);
|
||||||
|
const fs = compile(gl.FRAGMENT_SHADER, FRAG);
|
||||||
|
if (!vs || !fs) return { setPalette() {}, destroy() {} };
|
||||||
|
|
||||||
|
const program = gl.createProgram();
|
||||||
|
gl.attachShader(program, vs);
|
||||||
|
gl.attachShader(program, fs);
|
||||||
|
gl.linkProgram(program);
|
||||||
|
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
||||||
|
console.warn("[aurora]", gl.getProgramInfoLog(program));
|
||||||
|
return { setPalette() {}, destroy() {} };
|
||||||
|
}
|
||||||
|
gl.useProgram(program);
|
||||||
|
|
||||||
|
const buf = gl.createBuffer();
|
||||||
|
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
||||||
|
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
||||||
|
-1, -1, 1, -1, -1, 1,
|
||||||
|
-1, 1, 1, -1, 1, 1
|
||||||
|
]), gl.STATIC_DRAW);
|
||||||
|
const loc = gl.getAttribLocation(program, "a_pos");
|
||||||
|
gl.enableVertexAttribArray(loc);
|
||||||
|
gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
|
const uni = {
|
||||||
|
res: gl.getUniformLocation(program, "u_res"),
|
||||||
|
time: gl.getUniformLocation(program, "u_time"),
|
||||||
|
speed: gl.getUniformLocation(program, "u_speed"),
|
||||||
|
contrast: gl.getUniformLocation(program, "u_contrast"),
|
||||||
|
warp: gl.getUniformLocation(program, "u_warp"),
|
||||||
|
scale: gl.getUniformLocation(program, "u_scale"),
|
||||||
|
intensity: gl.getUniformLocation(program, "u_intensity"),
|
||||||
|
pointer: gl.getUniformLocation(program, "u_pointer"),
|
||||||
|
pointerStrength: gl.getUniformLocation(program, "u_pointerStrength"),
|
||||||
|
base: gl.getUniformLocation(program, "u_base"),
|
||||||
|
deep: gl.getUniformLocation(program, "u_deep"),
|
||||||
|
colorA: gl.getUniformLocation(program, "u_colorA"),
|
||||||
|
colorB: gl.getUniformLocation(program, "u_colorB"),
|
||||||
|
hot: gl.getUniformLocation(program, "u_hot")
|
||||||
|
};
|
||||||
|
|
||||||
|
const palettes = {
|
||||||
|
dark: {
|
||||||
|
base: [0.02, 0.035, 0.04],
|
||||||
|
deep: [0.04, 0.12, 0.14],
|
||||||
|
colorA: [0.18, 0.78, 0.52],
|
||||||
|
colorB: [0.15, 0.72, 0.88],
|
||||||
|
hot: [0.72, 0.62, 1.0],
|
||||||
|
intensity: 1.15,
|
||||||
|
contrast: 1.35
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
base: [0.93, 0.95, 0.94],
|
||||||
|
deep: [0.78, 0.90, 0.86],
|
||||||
|
colorA: [0.22, 0.62, 0.42],
|
||||||
|
colorB: [0.25, 0.68, 0.72],
|
||||||
|
hot: [0.55, 0.48, 0.85],
|
||||||
|
intensity: 0.92,
|
||||||
|
contrast: 1.15
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let palette = palettes.dark;
|
||||||
|
let raf = 0;
|
||||||
|
let running = false;
|
||||||
|
let visible = true;
|
||||||
|
let start = performance.now();
|
||||||
|
let pointer = [0.5, 0.45];
|
||||||
|
let targetPointer = [0.5, 0.45];
|
||||||
|
const dprCap = reduceMotion ? 1 : Math.min(window.devicePixelRatio || 1, 1.5);
|
||||||
|
|
||||||
|
function applyUniforms(timeSec) {
|
||||||
|
gl.uniform2f(uni.res, canvas.width, canvas.height);
|
||||||
|
gl.uniform1f(uni.time, timeSec);
|
||||||
|
gl.uniform1f(uni.speed, reduceMotion ? 0.0 : 0.22);
|
||||||
|
gl.uniform1f(uni.contrast, palette.contrast);
|
||||||
|
gl.uniform1f(uni.warp, 1.55);
|
||||||
|
gl.uniform1f(uni.scale, 1.85);
|
||||||
|
gl.uniform1f(uni.intensity, palette.intensity);
|
||||||
|
gl.uniform2f(uni.pointer, pointer[0], pointer[1]);
|
||||||
|
gl.uniform1f(uni.pointerStrength, reduceMotion ? 0.0 : 0.55);
|
||||||
|
gl.uniform3fv(uni.base, palette.base);
|
||||||
|
gl.uniform3fv(uni.deep, palette.deep);
|
||||||
|
gl.uniform3fv(uni.colorA, palette.colorA);
|
||||||
|
gl.uniform3fv(uni.colorB, palette.colorB);
|
||||||
|
gl.uniform3fv(uni.hot, palette.hot);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
const rect = wrap.getBoundingClientRect();
|
||||||
|
const w = Math.max(1, Math.floor(rect.width * dprCap));
|
||||||
|
const h = Math.max(1, Math.floor(rect.height * dprCap));
|
||||||
|
if (canvas.width !== w || canvas.height !== h) {
|
||||||
|
canvas.width = w;
|
||||||
|
canvas.height = h;
|
||||||
|
}
|
||||||
|
gl.viewport(0, 0, canvas.width, canvas.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
function frame(now) {
|
||||||
|
if (!running) return;
|
||||||
|
raf = requestAnimationFrame(frame);
|
||||||
|
if (!visible || document.hidden) return;
|
||||||
|
|
||||||
|
pointer[0] += (targetPointer[0] - pointer[0]) * 0.04;
|
||||||
|
pointer[1] += (targetPointer[1] - pointer[1]) * 0.04;
|
||||||
|
|
||||||
|
const t = (now - start) / 1000;
|
||||||
|
applyUniforms(reduceMotion ? 8.5 : t);
|
||||||
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startLoop() {
|
||||||
|
if (running) return;
|
||||||
|
running = true;
|
||||||
|
start = performance.now() - (reduceMotion ? 8500 : 0);
|
||||||
|
raf = requestAnimationFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopLoop() {
|
||||||
|
running = false;
|
||||||
|
cancelAnimationFrame(raf);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPalette(mode) {
|
||||||
|
palette = mode === "light" ? palettes.light : palettes.dark;
|
||||||
|
if (reduceMotion) {
|
||||||
|
resize();
|
||||||
|
applyUniforms(8.5);
|
||||||
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resize();
|
||||||
|
setPalette(resolvedTheme());
|
||||||
|
applyUniforms(reduceMotion ? 8.5 : 0);
|
||||||
|
gl.enable(gl.BLEND);
|
||||||
|
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
||||||
|
gl.clearColor(0, 0, 0, 0);
|
||||||
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||||
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||||
|
wrap.classList.add("is-ready");
|
||||||
|
|
||||||
|
if (!reduceMotion) startLoop();
|
||||||
|
|
||||||
|
const ro = new ResizeObserver(() => {
|
||||||
|
resize();
|
||||||
|
if (reduceMotion) {
|
||||||
|
applyUniforms(8.5);
|
||||||
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ro.observe(wrap);
|
||||||
|
|
||||||
|
const io = new IntersectionObserver((entries) => {
|
||||||
|
visible = entries.some((e) => e.isIntersecting);
|
||||||
|
if (!reduceMotion) {
|
||||||
|
if (visible) startLoop();
|
||||||
|
else stopLoop();
|
||||||
|
}
|
||||||
|
}, { threshold: 0.01 });
|
||||||
|
io.observe(wrap);
|
||||||
|
|
||||||
|
const hero = wrap.closest(".hero") || wrap;
|
||||||
|
const onPointer = (e) => {
|
||||||
|
const rect = hero.getBoundingClientRect();
|
||||||
|
targetPointer[0] = (e.clientX - rect.left) / Math.max(rect.width, 1);
|
||||||
|
targetPointer[1] = 1.0 - (e.clientY - rect.top) / Math.max(rect.height, 1);
|
||||||
|
};
|
||||||
|
if (!reduceMotion && window.matchMedia("(hover: hover) and (pointer: fine)").matches) {
|
||||||
|
hero.addEventListener("pointermove", onPointer, { passive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", () => {
|
||||||
|
if (document.hidden) stopLoop();
|
||||||
|
else if (visible && !reduceMotion) startLoop();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
setPalette,
|
||||||
|
destroy() {
|
||||||
|
stopLoop();
|
||||||
|
ro.disconnect();
|
||||||
|
io.disconnect();
|
||||||
|
hero.removeEventListener("pointermove", onPointer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
function applyTheme(theme) {
|
function applyTheme(theme) {
|
||||||
document.documentElement.setAttribute("data-theme", theme);
|
document.documentElement.setAttribute("data-theme", theme);
|
||||||
const icon = document.querySelector("[data-theme-icon]");
|
const icon = document.querySelector("[data-theme-icon]");
|
||||||
@@ -1641,6 +1896,7 @@
|
|||||||
}
|
}
|
||||||
try { localStorage.setItem("osg-theme", theme); } catch (_) {}
|
try { localStorage.setItem("osg-theme", theme); } catch (_) {}
|
||||||
applyShots();
|
applyShots();
|
||||||
|
liquidAurora.setPalette(resolvedTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
function cycleTheme() {
|
function cycleTheme() {
|
||||||
@@ -1713,6 +1969,7 @@
|
|||||||
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
||||||
if ((document.documentElement.getAttribute("data-theme") || "system") === "system") {
|
if ((document.documentElement.getAttribute("data-theme") || "system") === "system") {
|
||||||
applyShots();
|
applyShots();
|
||||||
|
liquidAurora.setPalette(resolvedTheme());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user