Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(background): animate the gradient wallpapers
EtienneLescote78c3fbae2da
diff --git a/crates/compositor/src/compositor_linux.rs b/crates/compositor/src/compositor_linux.rsindex aab2efffd..655864f48 100644--- a/crates/compositor/src/compositor_linux.rs+++ b/crates/compositor/src/compositor_linux.rs@@ -1383,7 +1383,8 @@ impl Compositor {Some(SceneBackground::Color { color }) => {flat(solid(parse_hex(color).unwrap_or(BLACK)))}- Some(SceneBackground::Gradient { angle_deg, stops }) => {+ // Le mouvement ne vaut que pour le fond d'ecran : la bulle garde son degrade immobile.+ Some(SceneBackground::Gradient { angle_deg, stops, .. }) => {let c0 = stops.first().and_then(|s| parse_hex(s)).unwrap_or(BLACK);let c1 = stops.last().and_then(|s| parse_hex(s)).unwrap_or(c0);// angle CSS -> direction unitaire, meme convention que le fond@@ -1938,17 +1939,20 @@ impl Compositor {Some(SceneBackground::Color { color }) => {(parse_hex(&color).unwrap_or(lp.bg_color), None)}- Some(SceneBackground::Gradient { angle_deg, stops }) => {+ Some(SceneBackground::Gradient { angle_deg, stops, motion }) => {let c0 = stops.first().and_then(|s| parse_hex(s)).unwrap_or(lp.bg_color);let c1 = stops.last().and_then(|s| parse_hex(s)).unwrap_or(c0);let a = angle_deg.to_radians();+ let (anim, mb) =+ crate::frame_geometry::gradient_motion_slots(motion, g.programme_t, rw / rh);let cb = LayerCB {dst: [0.0, 0.0, 1.0, 1.0],src: [c1[0], c1[1], c1[2], c1[3]],quad_px: [rw, rh],mode: 5.0,color: c0,- fx: [a.sin(), -a.cos(), 0.0, 0.0],+ fx: [a.sin(), -a.cos(), anim[0], anim[1]],+ mb,..Default::default()};([0.0, 0.0, 0.0, 1.0], Some(BgLayer::Gradient(cb)))diff --git a/crates/compositor/src/compositor_macos.rs b/crates/compositor/src/compositor_macos.rsindex a17a67342..0b3c6c0ed 100644--- a/crates/compositor/src/compositor_macos.rs+++ b/crates/compositor/src/compositor_macos.rs@@ -1016,7 +1016,8 @@ impl Compositor {Some(SceneBackground::Color { color }) => {self.draw_solid(enc, &solid(parse_hex(color).unwrap_or(BLACK)));}- Some(SceneBackground::Gradient { angle_deg, stops }) => {+ // Le mouvement ne vaut que pour le fond d'écran : la bulle garde son dégradé immobile.+ Some(SceneBackground::Gradient { angle_deg, stops, .. }) => {let c0 = stops.first().and_then(|s| parse_hex(s)).unwrap_or(BLACK);let c1 = stops.last().and_then(|s| parse_hex(s)).unwrap_or(c0);// angle CSS → direction unitaire, même convention que le fond d'écran.@@ -1994,10 +1995,12 @@ impl Compositor {&LayerCB { dst: [0.0, 0.0, 1.0, 1.0], mode: 1.0, color: c, ..Default::default() },);}- Some(SceneBackground::Gradient { angle_deg, stops }) => {+ Some(SceneBackground::Gradient { angle_deg, stops, motion }) => {let c0 = stops.first().and_then(|s| parse_hex(s)).unwrap_or(lp.bg_color);let c1 = stops.last().and_then(|s| parse_hex(s)).unwrap_or(c0);let a = angle_deg.to_radians();+ let (anim, mb) =+ crate::frame_geometry::gradient_motion_slots(motion, g.programme_t, rw / rh);self.draw_solid(enc,&LayerCB {@@ -2005,7 +2008,8 @@ impl Compositor {src: [c1[0], c1[1], c1[2], c1[3]],mode: 5.0,color: c0,- fx: [a.sin(), -a.cos(), 0.0, 0.0],+ fx: [a.sin(), -a.cos(), anim[0], anim[1]],+ mb,..Default::default()},);diff --git a/crates/compositor/src/compositor_windows.rs b/crates/compositor/src/compositor_windows.rsindex f3196b41e..bcc1c81d1 100644--- a/crates/compositor/src/compositor_windows.rs+++ b/crates/compositor/src/compositor_windows.rs@@ -968,7 +968,8 @@ impl Compositor {Some(SceneBackground::Color { color }) => {self.draw_solid(&solid(parse_hex(color).unwrap_or(BLACK)));}- Some(SceneBackground::Gradient { angle_deg, stops }) => {+ // Le mouvement ne vaut que pour le fond d'écran : la bulle garde son dégradé immobile.+ Some(SceneBackground::Gradient { angle_deg, stops, .. }) => {let c0 = stops.first().and_then(|s| parse_hex(s)).unwrap_or(BLACK);let c1 = stops.last().and_then(|s| parse_hex(s)).unwrap_or(c0);// angle CSS → direction unitaire, même convention que le fond d'écran.@@ -1662,19 +1663,25 @@ impl Compositor {..Default::default()});}- SceneBackground::Gradient { angle_deg, stops } => {+ SceneBackground::Gradient { angle_deg, stops, motion } => {let c0 = stops.first().and_then(|s| parse_hex(s)).unwrap_or(lp.bg_color);let c1 = stops.last().and_then(|s| parse_hex(s)).unwrap_or(c0);// angle CSS → direction unitaire (espace sortie, y vers le bas) :// 0° = vers le haut, 90° = vers la droite.let a = angle_deg.to_radians();let dir = [a.sin(), -a.cos()];+ let (anim, mb) = crate::frame_geometry::gradient_motion_slots(+ motion,+ g.programme_t,+ self.rw() / self.rh(),+ );self.draw_solid(&LayerCB {dst: [0.0, 0.0, 1.0, 1.0],src: [c1[0], c1[1], c1[2], c1[3]],mode: 5.0,color: c0,- fx: [dir[0], dir[1], 0.0, 0.0],+ fx: [dir[0], dir[1], anim[0], anim[1]],+ mb,..Default::default()});}diff --git a/crates/compositor/src/frame_geometry.rs b/crates/compositor/src/frame_geometry.rsindex af6a47549..bb102c92a 100644--- a/crates/compositor/src/frame_geometry.rs+++ b/crates/compositor/src/frame_geometry.rs@@ -796,6 +796,36 @@ fn same_source_path(a: &str, b: &str) -> bool {a.eq_ignore_ascii_case(b)}+/// Période commune des mouvements de fond (s). Chaque période du shader (20, 24, 30, 40, 12,+/// 120 s) la divise, donc replier le temps dessus ne crée aucun raccord visible — et garde au+/// shader un temps borné, là où un `f32` de plusieurs heures perdrait la finesse du bruit.+pub const GRADIENT_MOTION_PERIOD_S: f32 = 120.0;++/// Emplacements libres du mode 5 pour le fond animé : `fx.zw` = (temps programme replié, indice+/// du mouvement), `mb.x` = aspect w/h de la sortie (les nappes de l'aurore restent rondes).+///+/// `GradientMotion::None` rend les zéros d'avant l'animation, emplacement pour emplacement : le+/// dégradé immobile reste celui d'aujourd'hui, octet pour octet. Fonction pure du temps+/// programme, jamais d'un état porté de frame en frame — preview et export, lecture et seek+/// tombent sur la même image.+pub fn gradient_motion_slots(+ motion: crate::scene::GradientMotion,+ programme_t: f32,+ aspect: f32,+) -> ([f32; 2], [f32; 4]) {+ use crate::scene::GradientMotion as M;+ let index = match motion {+ M::None => return ([0.0, 0.0], [0.0; 4]),+ M::Drift => 1.0,+ M::Aurora => 2.0,+ M::Waves => 3.0,+ };+ (+ [programme_t.rem_euclid(GRADIENT_MOTION_PERIOD_S), index],+ [aspect, 0.0, 0.0, 0.0],+ )+}+/// True when this clip really has a camera to draw.////// TWO ways the app says "no camera", and both must be caught here, because the@@ -2607,6 +2637,23 @@ mod tests {assert_eq!(plan_frame(&sought).programme_t, 90.0 / FPS);}+ /// Sans mouvement, les emplacements restent les zéros d'avant (dégradé inchangé) ; avec,+ /// le temps est replié sur la période commune et l'indice suit l'ordre du shader.+ #[test]+ fn gradient_motion_slots_are_zero_when_still_and_wrap_the_clock() {+ use crate::scene::GradientMotion as M;+ assert_eq!(gradient_motion_slots(M::None, 37.5, 16.0 / 9.0), ([0.0, 0.0], [0.0; 4]));+ let (fx, mb) = gradient_motion_slots(M::Drift, 125.0, 2.0);+ assert_eq!(fx, [5.0, 1.0]);+ assert_eq!(mb, [2.0, 0.0, 0.0, 0.0]);+ assert_eq!(gradient_motion_slots(M::Aurora, 0.0, 1.0).0[1], 2.0);+ assert_eq!(gradient_motion_slots(M::Waves, 240.0, 1.0).0, [0.0, 3.0]);+ // Chaque période du shader divise la période de repli : pas de raccord au bouclage.+ for p in [20.0, 24.0, 30.0, 40.0, 12.0, 120.0] {+ assert_eq!(GRADIENT_MOTION_PERIOD_S % p, 0.0, "période {p}");+ }+ }+/// Le contrat cross-backend, verrouillé octet par octet. Un shader qui lit un champ/// décalé ne lève rien : il rend faux, en silence.#[test]diff --git a/crates/compositor/src/scene.rs b/crates/compositor/src/scene.rsindex 4b606e4bc..3da7e1332 100644--- a/crates/compositor/src/scene.rs+++ b/crates/compositor/src/scene.rs@@ -173,10 +173,30 @@ pub enum SceneBackground {#[serde(rename = "angleDeg")]angle_deg: f32,stops: Vec<String>,+ /// Absent pour un fond immobile : l'app n'émet la clé que si un mouvement est choisi,+ /// donc la scène d'un projet sans animation ne bouge pas d'un octet.+ #[serde(default)]+ motion: GradientMotion,},Image { path: String },}+/// Mouvement lent d'un fond dégradé (`settings.wallpaperMotion`), lu par le mode 5 dans `fx.w`.+///+/// Une valeur inconnue (projet ouvert par une version plus ancienne que celle qui l'a écrit)+/// retombe sur `None` au lieu de faire échouer le parse de toute la scène.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum GradientMotion {+ Drift,+ Aurora,+ Waves,+ // Dernier : serde n'accepte `other` que sur la dernière variante.+ #[default]+ #[serde(other)]+ None,+}+/// Une annotation de la timeline (temps en secondes, source du clip).////// Espace de coordonnées — à respecter au rendu : `x`/`y`/`w`/`h` sont des fractions du **rect@@ -658,9 +678,10 @@ mod tests {assert!(scene.layout.webcam_mirror);assert!((scene.effects.roundness_frac - 0.0222).abs() < 1e-6);match scene.background {- SceneBackground::Gradient { angle_deg, ref stops } => {+ SceneBackground::Gradient { angle_deg, ref stops, motion } => {assert_eq!(angle_deg, 135.0);assert_eq!(stops.len(), 2);+ assert_eq!(motion, GradientMotion::None);}_ => panic!("expected gradient"),}@@ -683,6 +704,20 @@ mod tests {assert_eq!(s.output.fps, Some(30.0));}+ #[test]+ fn gradient_motion_parses_and_tolerates_an_unknown_value() {+ let motion_of = |json: &str| match serde_json::from_str::<SceneBackground>(json).expect("parse") {+ SceneBackground::Gradient { motion, .. } => motion,+ _ => panic!("expected gradient"),+ };+ let g = |m: &str| format!(r##"{{"kind":"gradient","angleDeg":90,"stops":["#000","#fff"]{m}}}"##);+ assert_eq!(motion_of(&g("")), GradientMotion::None);+ assert_eq!(motion_of(&g(r#","motion":"drift""#)), GradientMotion::Drift);+ assert_eq!(motion_of(&g(r#","motion":"aurora""#)), GradientMotion::Aurora);+ assert_eq!(motion_of(&g(r#","motion":"waves""#)), GradientMotion::Waves);+ assert_eq!(motion_of(&g(r#","motion":"plasma""#)), GradientMotion::None);+ }+#[test]fn parses_webcam_rect_payload() {// webcamRect est une fraction 0..1 du cadre de sortie ; sa présence doit désactiverdiff --git a/crates/compositor/src/shaders.hlsl b/crates/compositor/src/shaders.hlslindex 25a916706..2f822a18d 100644--- a/crates/compositor/src/shaders.hlsl+++ b/crates/compositor/src/shaders.hlsl@@ -174,6 +174,61 @@ float3 quad_inverse_bilinear(float2 P, float2 c00, float2 c10, float2 c11, floatreturn (r0.z > 0.5) ? r0 : r1;}+// Hash 2D -> [0,1) sans sin() : le hash `frac(sin(x) * 43758)` dépend de la précision du GPU,+// celui-ci (Hoskins, « hash12 ») ne fait que des produits de petites valeurs.+float hash12(float2 p)+{+ float3 p3 = frac(float3(p.x, p.y, p.x) * 0.1031);+ p3 += dot(p3, p3.yzx + 33.33);+ return frac((p3.x + p3.y) * p3.z);+}++// Bruit de valeur lissé (hermite), sans texture.+float value_noise(float2 q)+{+ float2 i = floor(q);+ float2 f = frac(q);+ float2 u = f * f * (3.0 - 2.0 * f);+ float a = hash12(i);+ float b = hash12(i + float2(1.0, 0.0));+ float c = hash12(i + float2(0.0, 1.0));+ float d = hash12(i + float2(1.0, 1.0));+ return lerp(lerp(a, b, u.x), lerp(c, d, u.x), u.y);+}++// Mouvements 2 (aurore) et 3 (vagues) du mode 5, dans les deux couleurs des stops seulement.+// `gp` 0..1 sur le quad, `dir`/`denom` ceux du dégradé, `time` = temps programme replié sur+// 120 s (toutes les périodes ci-dessous le divisent), `aspect` = w/h de la sortie. Périodes+// longues et contraste bas : le fond ne doit jamais prendre l'attention.+float3 gradient_motion(float2 gp, float2 dir, float denom, float3 c0, float3 c1, float time,+ float motion, float aspect)+{+ const float TAU = 6.2831853;+ float u = dot(gp - 0.5, dir) / denom; // position le long de l'axe, -0.5..0.5+ if (motion < 2.5)+ {+ // Aurore : rampe perturbée par un bruit lent (dont l'origine tourne en 120 s), puis+ // trois nappes gaussiennes sur des Lissajous de 20 à 40 s. Coordonnées corrigées de+ // l'aspect pour que les nappes restent rondes.+ float2 p = float2((gp.x - 0.5) * aspect, gp.y - 0.5);+ float ph = TAU * time / 120.0;+ float n = value_noise(p * 2.5 + 1.5 * float2(cos(ph), sin(ph)));+ float3 g = lerp(c0, c1, saturate(0.5 + u + 0.3 * (n - 0.5)));+ float2 b0 = float2(0.35 * aspect * sin(TAU * time / 20.0), 0.25 * sin(TAU * time / 30.0 + 1.0));+ float2 b1 = float2(0.30 * aspect * sin(TAU * time / 24.0 + 2.0), 0.22 * cos(TAU * time / 40.0));+ float2 b2 = float2(0.25 * aspect * cos(TAU * time / 30.0 + 4.0), 0.28 * sin(TAU * time / 24.0 + 3.0));+ g = lerp(g, c1, 0.45 * exp(-dot(p - b0, p - b0) / 0.08));+ g = lerp(g, c0, 0.45 * exp(-dot(p - b1, p - b1) / 0.06));+ g = lerp(g, c1, 0.35 * exp(-dot(p - b2, p - b2) / 0.05));+ return g;+ }+ // Vagues : trois bandes sinus perpendiculaires à l'axe, qui avancent d'une bande en 12 s,+ // légèrement ondulées le long des bandes (20 s). Elles décalent la rampe, rien d'autre.+ float v = dot(gp - 0.5, float2(-dir.y, dir.x)) / denom;+ float w = sin(TAU * (3.0 * u + 0.04 * sin(TAU * (1.5 * v + time / 20.0)) - time / 12.0));+ return lerp(c0, c1, saturate(0.5 + u + 0.07 * w));+}+// Fond flouté pour le mode "blur" de la webcam.// Disque de Vogel (spirale à angle d'or) à 21 échantillons avec pondération gaussienne et// rotation par pixel via Interleaved Gradient Noise (IGN) pour un bokeh photographique doux, isotrope et rapide.@@ -478,9 +533,19 @@ float4 ps_main(VSOut i) : SV_Target// mode 5 : gradient linéaire 2 stops (parité web wallpaper dégradé). color = stop0,// src.xyz = stop1, fx.xy = direction unitaire (espace sortie, y vers le bas). t est// normalisé coin-à-coin (dénominateur = |dx|+|dy|) pour couvrir toute la diagonale.+ // Fond animé : fx.z = temps programme (s, replié sur 120), fx.w = mouvement (0 immobile,+ // 1 dérive, 2 aurore, 3 vagues), mb.x = aspect w/h. 0 rend le dégradé d'avant à l'octet.if (mode > 4.5){float2 dir = fx.xy;+ if (fx.w > 0.5 && fx.w < 1.5)+ {+ // Dérive : l'axe respire de ±15° (0.2617994 rad) en 20 s.+ float da = 0.2617994 * sin(6.2831853 * fx.z / 20.0);+ float sa = sin(da);+ float ca = cos(da);+ dir = float2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);+ }float denom = max(abs(dir.x) + abs(dir.y), 1e-4);// Paramétré sur le QUAD dès qu'il en a un (la bulle webcam), sinon sur la sortie. Pour le// fond plein cadre les deux coïncident ; pour une bulle dans un coin, `pout` ne montrerait@@ -489,6 +554,10 @@ float4 ps_main(VSOut i) : SV_Targetfloat2 gp = (quad_px.x > 0.0 && quad_px.y > 0.0) ? (i.local / quad_px) : i.pout;float t = saturate(0.5 + dot(gp - 0.5, dir) / denom);float3 g = lerp(color.rgb, src.xyz, t);+ if (fx.w > 1.5)+ {+ g = gradient_motion(gp, dir, denom, color.rgb, src.xyz, fx.z, fx.w, mb.x);+ }float a = quad_round_alpha(i.local, quad_px, radius_px);return float4(g * a, a); // prémultiplié}diff --git a/crates/compositor/src/shaders.metal b/crates/compositor/src/shaders.metalindex b5737e1f2..319647c33 100644--- a/crates/compositor/src/shaders.metal+++ b/crates/compositor/src/shaders.metal@@ -310,6 +310,55 @@ static float4 cursor_extruded(float2 local, constant Layer &layer,return acc;}+// Hash 2D -> [0,1) sans sin(). Miroir de `hash12` côté HLSL.+inline float hash12(float2 p)+{+ float3 p3 = fract(float3(p.x, p.y, p.x) * 0.1031);+ p3 += dot(p3, p3.yzx + 33.33);+ return fract((p3.x + p3.y) * p3.z);+}++// Bruit de valeur lissé (hermite), sans texture. Miroir de `value_noise` côté HLSL.+inline float value_noise(float2 q)+{+ float2 i = floor(q);+ float2 f = fract(q);+ float2 u = f * f * (3.0 - 2.0 * f);+ float a = hash12(i);+ float b = hash12(i + float2(1.0, 0.0));+ float c = hash12(i + float2(0.0, 1.0));+ float d = hash12(i + float2(1.0, 1.0));+ return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);+}++// Mouvements 2 (aurore) et 3 (vagues) du mode 5. Miroir ligne pour ligne de+// `gradient_motion` côté HLSL (commentaires complets là-bas).+inline float3 gradient_motion(float2 gp, float2 dir, float denom, float3 c0, float3 c1,+ float time, float motion, float aspect)+{+ const float TAU = 6.2831853;+ float u = dot(gp - 0.5, dir) / denom; // position le long de l'axe, -0.5..0.5+ if (motion < 2.5)+ {+ // Aurore : rampe perturbée par un bruit lent, puis trois nappes gaussiennes.+ float2 p = float2((gp.x - 0.5) * aspect, gp.y - 0.5);+ float ph = TAU * time / 120.0;+ float n = value_noise(p * 2.5 + 1.5 * float2(cos(ph), sin(ph)));+ float3 g = mix(c0, c1, clamp(0.5 + u + 0.3 * (n - 0.5), 0.0, 1.0));+ float2 b0 = float2(0.35 * aspect * sin(TAU * time / 20.0), 0.25 * sin(TAU * time / 30.0 + 1.0));+ float2 b1 = float2(0.30 * aspect * sin(TAU * time / 24.0 + 2.0), 0.22 * cos(TAU * time / 40.0));+ float2 b2 = float2(0.25 * aspect * cos(TAU * time / 30.0 + 4.0), 0.28 * sin(TAU * time / 24.0 + 3.0));+ g = mix(g, c1, 0.45 * exp(-dot(p - b0, p - b0) / 0.08));+ g = mix(g, c0, 0.45 * exp(-dot(p - b1, p - b1) / 0.06));+ g = mix(g, c1, 0.35 * exp(-dot(p - b2, p - b2) / 0.05));+ return g;+ }+ // Vagues : trois bandes sinus perpendiculaires à l'axe (12 s), ondulées (20 s).+ float v = dot(gp - 0.5, float2(-dir.y, dir.x)) / denom;+ float w = sin(TAU * (3.0 * u + 0.04 * sin(TAU * (1.5 * v + time / 20.0)) - time / 12.0));+ return mix(c0, c1, clamp(0.5 + u + 0.07 * w, 0.0, 1.0));+}+fragment float4 ps_main(VSOut i [[stage_in]],constant Layer &layer [[buffer(0)]],texture2d<float, access::sample> texY [[texture(0)]],@@ -455,9 +504,20 @@ fragment float4 ps_main(VSOut i [[stage_in]],//// Le port avait remplacé tout ce calcul par une couleur plate : un dégradé s'affichait// comme son premier stop, uniformément.+ //+ // Fond animé : fx.z = temps programme (s, replié sur 120), fx.w = mouvement (0 immobile,+ // 1 dérive, 2 aurore, 3 vagues), mb.x = aspect w/h. 0 rend le dégradé d'avant à l'octet.if (layer.mode > 4.5 && layer.mode < 5.5){float2 dir = layer.fx.xy;+ if (layer.fx.w > 0.5 && layer.fx.w < 1.5)+ {+ // Dérive : l'axe respire de ±15° (0.2617994 rad) en 20 s.+ float da = 0.2617994 * sin(6.2831853 * layer.fx.z / 20.0);+ float sa = sin(da);+ float ca = cos(da);+ dir = float2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);+ }float denom = max(abs(dir.x) + abs(dir.y), 1e-4);// Paramétré sur le QUAD dès qu'il en a un (la bulle webcam), sinon sur la sortie. Pour le// fond plein cadre les deux coïncident ; pour une bulle dans un coin, `pout` ne montrerait@@ -468,6 +528,11 @@ fragment float4 ps_main(VSOut i [[stage_in]],: i.pout;float t = clamp(0.5 + dot(gp - 0.5, dir) / denom, 0.0, 1.0);float3 g = mix(layer.color.rgb, layer.src.xyz, t);+ if (layer.fx.w > 1.5)+ {+ g = gradient_motion(gp, dir, denom, layer.color.rgb, layer.src.xyz, layer.fx.z,+ layer.fx.w, layer.mb.x);+ }float a = quad_round_alpha(i.local, layer.quad_px, layer.radius_px);return float4(g * a, a); // prémultiplié}diff --git a/crates/compositor/src/vk_shaders/layer.wgsl b/crates/compositor/src/vk_shaders/layer.wgslindex ec55fa4ee..78ad4760a 100644--- a/crates/compositor/src/vk_shaders/layer.wgsl+++ b/crates/compositor/src/vk_shaders/layer.wgsl@@ -24,10 +24,10 @@ struct Layer {radius_px: f32,mode: f32, // 0 = vidéo NV12, 1 = couleur pleine, 2 = ombre, 8 = écran tilté, 9 = flèche, 10 = flou/mosaïque, 12 = ombre du quad tilté, 13 = curseur tiltécolor: vec4<f32>,- fx: vec4<f32>, // mode 2 : spread ombre en px ; modes 8/12/13 : coins TL,TR du quad projeté ; mode 9 : hampe de la flèche ; mode 10 : (flou?, rayon/bloc px, ovale?, teinté?)+ fx: vec4<f32>, // mode 2 : spread ombre en px ; mode 5 : (direction xy, temps programme replie, mouvement 0..3) ; modes 8/12/13 : coins TL,TR du quad projeté ; mode 9 : hampe de la flèche ; mode 10 : (flou?, rayon/bloc px, ovale?, teinté?)src_prev: vec4<f32>, // modes 8/12/13 : coins BR,BL du quad projeté ; mode 9 : barbe 1 ; mode 10 incliné : coins BR,BL du masquedst_prev: vec4<f32>, // mode 8 : taille du plan en px AVANT projection (le rayon y vit) ; mode 13 : rect de clip ; mode 9 : barbe 2 ; mode 10 incliné : coins TL,TR du masque- mb: vec4<f32>, // mode 12 : mb.y = spread de la pénombre en px ; mode 9 : mb.y = demi-épaisseur du trait en px ; mode 10 : mb.z = 1 si masque incliné ; mode 13 : mb.xy = vecteur d'extrusion en px, mb.z = nombre de copies (volume, <= 1 = plat)+ mb: vec4<f32>, // mode 5 : mb.x = aspect w/h de la sortie (fond anime) ; mode 12 : mb.y = spread de la pénombre en px ; mode 9 : mb.y = demi-épaisseur du trait en px ; mode 10 : mb.z = 1 si masque incliné ; mode 13 : mb.xy = vecteur d'extrusion en px, mb.z = nombre de copies (volume, <= 1 = plat)}@group(0) @binding(0) var<uniform> layer: Layer;@@ -221,6 +221,51 @@ fn quad_inverse_bilinear(P: vec2<f32>, c00: vec2<f32>, c10: vec2<f32>, c11: vec2return r1;}+// Hash 2D -> [0,1) sans sin(). Miroir de `hash12` cote HLSL.+fn hash12(p: vec2<f32>) -> f32 {+ var p3 = fract(vec3<f32>(p.x, p.y, p.x) * 0.1031);+ p3 = p3 + vec3<f32>(dot(p3, p3.yzx + vec3<f32>(33.33)));+ return fract((p3.x + p3.y) * p3.z);+}++// Bruit de valeur lisse (hermite), sans texture. Miroir de `value_noise` cote HLSL.+fn value_noise(q: vec2<f32>) -> f32 {+ let i = floor(q);+ let f = fract(q);+ let u = f * f * (vec2<f32>(3.0) - 2.0 * f);+ let a = hash12(i);+ let b = hash12(i + vec2<f32>(1.0, 0.0));+ let c = hash12(i + vec2<f32>(0.0, 1.0));+ let d = hash12(i + vec2<f32>(1.0, 1.0));+ return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);+}++// Mouvements 2 (aurore) et 3 (vagues) du mode 5. Miroir ligne pour ligne de+// `gradient_motion` cote HLSL (commentaires complets la-bas).+fn gradient_motion(gp: vec2<f32>, dir: vec2<f32>, denom: f32, c0: vec3<f32>, c1: vec3<f32>,+ time: f32, motion: f32, aspect: f32) -> vec3<f32> {+ let TAU = 6.2831853;+ let u = dot(gp - vec2<f32>(0.5), dir) / denom; // position le long de l'axe, -0.5..0.5+ if motion < 2.5 {+ // Aurore : rampe perturbee par un bruit lent, puis trois nappes gaussiennes.+ let p = vec2<f32>((gp.x - 0.5) * aspect, gp.y - 0.5);+ let ph = TAU * time / 120.0;+ let n = value_noise(p * 2.5 + 1.5 * vec2<f32>(cos(ph), sin(ph)));+ var g = mix(c0, c1, clamp(0.5 + u + 0.3 * (n - 0.5), 0.0, 1.0));+ let b0 = vec2<f32>(0.35 * aspect * sin(TAU * time / 20.0), 0.25 * sin(TAU * time / 30.0 + 1.0));+ let b1 = vec2<f32>(0.30 * aspect * sin(TAU * time / 24.0 + 2.0), 0.22 * cos(TAU * time / 40.0));+ let b2 = vec2<f32>(0.25 * aspect * cos(TAU * time / 30.0 + 4.0), 0.28 * sin(TAU * time / 24.0 + 3.0));+ g = mix(g, c1, 0.45 * exp(-dot(p - b0, p - b0) / 0.08));+ g = mix(g, c0, 0.45 * exp(-dot(p - b1, p - b1) / 0.06));+ g = mix(g, c1, 0.35 * exp(-dot(p - b2, p - b2) / 0.05));+ return g;+ }+ // Vagues : trois bandes sinus perpendiculaires a l'axe (12 s), ondulees (20 s).+ let v = dot(gp - vec2<f32>(0.5), vec2<f32>(-dir.y, dir.x)) / denom;+ let w = sin(TAU * (3.0 * u + 0.04 * sin(TAU * (1.5 * v + time / 20.0)) - time / 12.0));+ return mix(c0, c1, clamp(0.5 + u + 0.07 * w, 0.0, 1.0));+}+// Fond flouté pour le mode "blur" de la webcam.// Disque de Vogel (spirale à angle d'or) à 21 échantillons avec pondération gaussienne et// rotation par pixel via Interleaved Gradient Noise (IGN) pour un bokeh photographique doux, isotrope et rapide.@@ -361,7 +406,17 @@ fn fs_main(i: VsOut) -> @location(0) vec4<f32> {// la direction fx.xy (sin, -cos de l'angle). Parite avec le HLSL/MSL.// `denom` : HLSL et MSL normalisent coin-a-coin (|dx|+|dy|) pour couvrir toute la// diagonale. Il manquait ici, donc le meme degrade ne rendait pas pareil sur Linux.- let denom = max(abs(layer.fx.x) + abs(layer.fx.y), 1e-4);+ // Fond anime : fx.z = temps programme (s, replie sur 120), fx.w = mouvement (0 immobile,+ // 1 derive, 2 aurore, 3 vagues), mb.x = aspect w/h. 0 rend le degrade d'avant a l'octet.+ var dir = layer.fx.xy;+ if layer.fx.w > 0.5 && layer.fx.w < 1.5 {+ // Derive : l'axe respire de +-15 deg (0.2617994 rad) en 20 s.+ let da = 0.2617994 * sin(6.2831853 * layer.fx.z / 20.0);+ let sa = sin(da);+ let ca = cos(da);+ dir = vec2<f32>(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);+ }+ let denom = max(abs(dir.x) + abs(dir.y), 1e-4);// Parametre sur le QUAD des qu'il en a un (la bulle webcam), sinon sur la sortie. Pour// le fond plein cadre les deux coincident ; pour une bulle dans un coin, `pout` ne// montrerait que la tranche du degrade plein cadre qui passe dessous.@@ -369,8 +424,12 @@ fn fs_main(i: VsOut) -> @location(0) vec4<f32> {if layer.quad_px.x > 0.0 && layer.quad_px.y > 0.0 {gp = i.local / layer.quad_px;}- let t = clamp(0.5 + dot(gp - vec2<f32>(0.5), layer.fx.xy) / denom, 0.0, 1.0);+ let t = clamp(0.5 + dot(gp - vec2<f32>(0.5), dir) / denom, 0.0, 1.0);rgb = mix(layer.color.rgb, layer.src.rgb, t);+ if layer.fx.w > 1.5 {+ rgb = gradient_motion(gp, dir, denom, layer.color.rgb, layer.src.rgb, layer.fx.z,+ layer.fx.w, layer.mb.x);+ }} else if layer.mode > 10.5 && layer.mode < 11.5 {// Mode 11 : texte. texY est l'atlas R8 (couverture alpha au canal .r,// produit par text_cosmic::TextRasterizer), teinte par layer.color.diff --git a/crates/compositor/tests/animated_background.rs b/crates/compositor/tests/animated_background.rsnew file mode 100644index 000000000..fb8dc3488--- /dev/null+++ b/crates/compositor/tests/animated_background.rs@@ -0,0 +1,134 @@+//! Un fond dégradé animé (mode 5, `fx.w`) est une fonction pure du temps programme :+//! immobile, il ne dépend pas de l'instant ; animé, chaque mouvement donne une image propre à+//! chacun des trois instants fixes, et différente du dégradé immobile.+//!+//! Rend de vraies frames par le compositeur D3D11. Piloté par l'environnement, comme+//! `privacy_blur_under_zoom.rs`, dont il réutilise la source (n'importe quel MP4 d'au moins+//! 6 s convient) :+//!+//! ```powershell+//! $env:OPENSCREEN_PRIVACY_SECRET = "...\secret.mp4"+//! cargo test -p openscreen-compositor --test animated_background -- --nocapture+//! ```+//!+//! `OPENSCREEN_BACKGROUND_OUT` (facultatif) reçoit un PPM par cas, pour l'inspection à l'œil.+//! Les empreintes imprimées sont celles de CE GPU : le rendu « none » se compare à celui du+//! shader d'avant le fond animé en relançant le test sur l'ancien `shaders.hlsl`.++// Windows seulement : le readback et le décodage D3D11VA de ce harnais n'existent que là.+#![cfg(windows)]++use std::collections::hash_map::DefaultHasher;+use std::hash::{Hash, Hasher};++use openscreen_compositor::compositor::Compositor;+use openscreen_compositor::config;+use openscreen_compositor::d3d::Gpu;+use openscreen_compositor::frame_geometry::live_params_from_scene;+use openscreen_compositor::live::Player;+use openscreen_compositor::scene::Scene;++const W: u32 = 960;+const H: u32 = 540;+/// Trois clips de 6 s du même fichier : le clip `k` lu à 3 s source tombe à `6k + 3` s de+/// programme. La frame vidéo est la même, seul le temps programme change.+const PROGRAMME_TIMES: [f32; 3] = [3.0, 9.0, 15.0];++fn write_ppm(path: &std::path::Path, rgba: &[u8], w: u32, h: u32) -> std::io::Result<()> {+ let mut out = Vec::with_capacity(rgba.len() / 4 * 3 + 32);+ out.extend_from_slice(format!("P6\n{w} {h}\n255\n").as_bytes());+ for px in rgba.chunks_exact(4) {+ out.extend_from_slice(&px[..3]);+ }+ std::fs::write(path, out)+}++/// `motion` : fragment JSON inséré tel quel dans le fond (`""` = clé absente).+fn scene_json(source: &str, motion: &str) -> String {+ let s = source.replace('\\', "/");+ let clip = format!(+ r#"{{"screenPath":"{s}","webcamPath":"","sourceStartSec":0,"sourceEndSec":6,"webcamOffsetSec":0,"hasAudio":false}}"#+ );+ format!(+ r##"{{+ "clips": [{clip},{clip},{clip}],+ "layout": {{"preset":"no-webcam","webcamSize":1.0,"webcamShape":"rounded","webcamMirror":false,"webcamPosition":null,"webcamReactiveZoom":false}},+ "effects": {{"padding":1.0,"blur":false,"shadow":0.0,"roundnessFrac":0.02,"motionBlur":0.0}},+ "background": {{"kind":"gradient","angleDeg":135,"stops":["#2b3a67","#b8577f"]{motion}}},+ "zoomRegions": [],+ "speedRegions": [],+ "cursor": {{"show":false,"size":1,"smoothing":0,"motionBlur":0,"clickBounce":0,"clipToBounds":false,"theme":"default"}},+ "cropByClip": [null, null, null],+ "output": {{"width":{W},"height":{H},"fps":30}}+ }}"##+ )+}++fn render(gpu: &Gpu, source: &str, motion: &str, clip: usize) -> Vec<u8> {+ let mut cfg = config::all().pop().expect("au moins une config");+ cfg.zoom = false;+ cfg.layout_anim = false;+ let comp = Compositor::new_sized(gpu, W, H).expect("compositor");+ let scene = Scene::from_json(&scene_json(source, motion)).expect("scene valide");+ comp.set_live_params(live_params_from_scene(&scene));+ comp.set_scene(Some(scene.clone()));+ comp.clear_cursor();+ unsafe {+ let mut player = Player::open(source, "", gpu).expect("ouvrir la source");+ player.set_programme_clock(Some(&scene), clip);+ player.present_frame(&comp, &cfg, 3.0).expect("composer la frame");+ let t = player.programme_time().expect("horloge programme");+ assert!((t - PROGRAMME_TIMES[clip]).abs() < 0.05, "temps programme {t} pour le clip {clip}");+ comp.readback_resized(W, H).expect("readback")+ }+}++fn hash(rgba: &[u8]) -> u64 {+ let mut h = DefaultHasher::new();+ rgba.hash(&mut h);+ h.finish()+}++#[test]+fn each_motion_is_a_distinct_pure_function_of_programme_time() {+ let Ok(source) = std::env::var("OPENSCREEN_PRIVACY_SECRET") else {+ println!("SKIP: definir OPENSCREEN_PRIVACY_SECRET (voir l'en-tete du fichier).");+ return;+ };+ let out_dir = std::env::var("OPENSCREEN_BACKGROUND_OUT").ok().map(std::path::PathBuf::from);+ if let Some(dir) = &out_dir {+ std::fs::create_dir_all(dir).expect("creer le dossier de sortie");+ }+ let gpu = Gpu::create(false).expect("device d3d11");+ let shoot = |name: &str, motion: &str, clip: usize| {+ let rgba = render(&gpu, &source, motion, clip);+ if let Some(dir) = &out_dir {+ let file = format!("{name}-t{:02}.ppm", PROGRAMME_TIMES[clip] as u32);+ write_ppm(&dir.join(file), &rgba, W, H).expect("ecrire le ppm");+ }+ let h = hash(&rgba);+ println!("{name:<8} t={:>4} {h:016x}", PROGRAMME_TIMES[clip]);+ h+ };++ // Immobile : clé absente, "none" et une valeur inconnue rendent la même image, à tout instant.+ let still = shoot("absent", "", 0);+ for clip in 0..3 {+ assert_eq!(shoot("none", r#","motion":"none""#, clip), still, "none au clip {clip}");+ }+ assert_eq!(shoot("unknown", r#","motion":"plasma""#, 2), still);++ for name in ["drift", "aurora", "waves"] {+ let motion = format!(r#","motion":"{name}""#);+ let hashes: Vec<u64> = (0..3).map(|clip| shoot(name, &motion, clip)).collect();+ for (k, h) in hashes.iter().enumerate() {+ assert_ne!(*h, still, "{name} a t={} rend le degrade immobile", PROGRAMME_TIMES[k]);+ }+ assert!(+ hashes[0] != hashes[1] && hashes[1] != hashes[2] && hashes[0] != hashes[2],+ "{name} : deux instants rendent la meme image ({hashes:x?})"+ );+ // Fonction pure : le même instant recomposé par un autre compositeur donne le même octet.+ assert_eq!(shoot(name, &motion, 1), hashes[1], "{name} n'est pas reproductible");+ }+}diff --git a/crates/fixture/scene-gradient-aurora.json b/crates/fixture/scene-gradient-aurora.jsonnew file mode 100644index 000000000..bb2e89a13--- /dev/null+++ b/crates/fixture/scene-gradient-aurora.json@@ -0,0 +1,37 @@+{+ "clips": [],+ "layout": {+ "preset": "picture-in-picture",+ "webcamSize": 1,+ "webcamShape": "rectangle",+ "webcamMirror": false,+ "webcamPosition": null,+ "webcamReactiveZoom": false+ },+ "effects": {+ "padding": 0.5,+ "blur": false,+ "shadow": 0.8,+ "roundnessFrac": 0.0222,+ "motionBlur": 0+ },+ "background": {+ "kind": "gradient",+ "angleDeg": 135,+ "stops": ["#2b3a67", "#b8577f"],+ "motion": "aurora"+ },+ "zoomRegions": [],+ "speedRegions": [],+ "cursor": {+ "show": false,+ "size": 1,+ "smoothing": 0,+ "motionBlur": 0,+ "clickBounce": 0,+ "clipToBounds": false,+ "theme": "default"+ },+ "cropByClip": [],+ "output": { "width": 1920, "height": 1080, "fps": 60 }+}diff --git a/crates/fixture/scene-gradient-still.json b/crates/fixture/scene-gradient-still.jsonnew file mode 100644index 000000000..d25db4154--- /dev/null+++ b/crates/fixture/scene-gradient-still.json@@ -0,0 +1,32 @@+{+ "clips": [],+ "layout": {+ "preset": "picture-in-picture",+ "webcamSize": 1,+ "webcamShape": "rectangle",+ "webcamMirror": false,+ "webcamPosition": null,+ "webcamReactiveZoom": false+ },+ "effects": {+ "padding": 0.5,+ "blur": false,+ "shadow": 0.8,+ "roundnessFrac": 0.0222,+ "motionBlur": 0+ },+ "background": { "kind": "gradient", "angleDeg": 135, "stops": ["#2b3a67", "#b8577f"] },+ "zoomRegions": [],+ "speedRegions": [],+ "cursor": {+ "show": false,+ "size": 1,+ "smoothing": 0,+ "motionBlur": 0,+ "clickBounce": 0,+ "clipToBounds": false,+ "theme": "default"+ },+ "cropByClip": [],+ "output": { "width": 1920, "height": 1080, "fps": 60 }+}diff --git a/crates/poc-d3d/src/bench.rs b/crates/poc-d3d/src/bench.rsindex aa2de7d60..4b7a6e0c7 100644--- a/crates/poc-d3d/src/bench.rs+++ b/crates/poc-d3d/src/bench.rs@@ -7,7 +7,7 @@ use anyhow::{Context as _, Result};use openscreen_compositor::compositor::Compositor;use openscreen_compositor::gif_export::{GifExportParams, GifStats};use openscreen_compositor::pipeline::ClipSource;-use openscreen_compositor::{config, cursor, d3d, gif_export, live, pipeline, scene};+use openscreen_compositor::{config, cursor, d3d, frame_geometry, gif_export, live, pipeline, scene};use std::fmt::Write as _;use std::path::Path;@@ -134,7 +134,11 @@ fn run_bench(args: &[String]) -> Result<()> {if !scene_arg.is_empty() {let json = std::fs::read_to_string(&scene_arg).with_context(|| format!("lecture de la scène {scene_arg}"))?;- comp.set_scene(Some(scene::Scene::from_json(&json)?));+ let s = scene::Scene::from_json(&json)?;+ // Comme l'export de l'app : sans ces réglages, le padding de la scène est ignoré, la+ // vidéo couvre tout le cadre et le fond n'apparaît pas dans la preuve visuelle.+ comp.set_live_params(frame_geometry::live_params_from_scene(&s));+ comp.set_scene(Some(s));println!("scène chargée depuis {scene_arg}");}diff --git a/electron/ai-edition/style-preset-service.test.ts b/electron/ai-edition/style-preset-service.test.tsindex afd5600ae..c50f80edc 100644--- a/electron/ai-edition/style-preset-service.test.ts+++ b/electron/ai-edition/style-preset-service.test.ts@@ -7,6 +7,7 @@ import { StylePresetError, StylePresetService } from "./style-preset-service";const APPEARANCE: StylePresetAppearance = {wallpaper: "#000000",+ wallpaperMotion: "none",aspectRatio: "16:9",shadowIntensity: 0.2,showBlur: false,diff --git a/electron/ipc/nativeBridge.presets.test.ts b/electron/ipc/nativeBridge.presets.test.tsindex 93c6ba6df..ade58983c 100644--- a/electron/ipc/nativeBridge.presets.test.ts+++ b/electron/ipc/nativeBridge.presets.test.ts@@ -27,6 +27,7 @@ vi.mock("../native-bridge/services/aiEditionService", () => ({const APPEARANCE: StylePresetAppearance = {wallpaper: "#000000",+ wallpaperMotion: "none",aspectRatio: "16:9",shadowIntensity: 0.2,showBlur: false,diff --git a/src/components/ai-edition/RightPanes.backgroundMotion.test.tsx b/src/components/ai-edition/RightPanes.backgroundMotion.test.tsxnew file mode 100644index 000000000..aef460a58--- /dev/null+++ b/src/components/ai-edition/RightPanes.backgroundMotion.test.tsx@@ -0,0 +1,66 @@+// @vitest-environment jsdom+// The background animation control moves only what the compositor draws as a gradient. On any+// other wallpaper it must be dead and say why, not hold a choice that changes nothing on screen.++import "@testing-library/jest-dom";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { I18nProvider } from "@/contexts/I18nContext";+import { LOCALE_STORAGE_KEY } from "@/i18n/config";+import { createEmptyDocument } from "@/lib/ai-edition/schema";+import { useProjectStore } from "@/lib/ai-edition/store/projectStore";+import { VideoEffectsPane } from "./RightPanes";++const REASON = /applies to gradient backgrounds only/i;++function renderWith(legacyEditor: Record<string, unknown>) {+ const base = createEmptyDocument({ projectId: "project_motion", title: "Motion" });+ useProjectStore.setState({+ projectId: base.project.id,+ document: { ...base, legacyEditor },+ revision: 1,+ status: "ready",+ });+ return render(+ <I18nProvider>+ <VideoEffectsPane />+ </I18nProvider>,+ );+}++const control = () => screen.getByRole("combobox", { name: "Animation" });++beforeEach(() => {+ localStorage.clear();+ localStorage.setItem(LOCALE_STORAGE_KEY, "en");+});++afterEach(() => {+ cleanup();+ localStorage.clear();+ useProjectStore.getState().clear();+});++describe("background animation control", () => {+ it("animates a gradient wallpaper", () => {+ renderWith({ wallpaper: "linear-gradient(135deg, #2b3a67, #b8577f)" });+ expect(control()).toBeEnabled();+ expect(control()).toHaveValue("none");+ expect(screen.queryByText(REASON)).not.toBeInTheDocument();++ fireEvent.change(control(), { target: { value: "aurora" } });+ expect(useProjectStore.getState().document?.legacyEditor).toMatchObject({+ wallpaperMotion: "aurora",+ });+ });++ it("is disabled with its reason on an image, and keeps the stored choice", () => {+ renderWith({ wallpaper: "/wallpapers/wallpaper1.jpg", wallpaperMotion: "waves" });+ expect(control()).toBeDisabled();+ expect(control()).toHaveValue("none");+ expect(screen.getByText(REASON)).toBeInTheDocument();+ expect(useProjectStore.getState().document?.legacyEditor).toMatchObject({+ wallpaperMotion: "waves",+ });+ });+});diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex b1ced5196..ba32fc6da 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -43,6 +43,7 @@ import { toast } from "sonner";import defaultCursorPreviewUrl from "@/assets/cursors/Cursor=Default.svg";import GradientEditor, { type GradientEditorState } from "@/components/ui/gradient-editor";import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";+import { WALLPAPER_MOTIONS, type WallpaperMotion } from "@/components/video-editor/types";import { useI18n, useScopedT } from "@/contexts/I18nContext";import { resolveCaptionLane } from "@/lib/ai-edition/captions/settings";import { collapseTracksToPills, trackGroupId } from "@/lib/ai-edition/document/audioTracks";@@ -100,6 +101,7 @@ import {WALLPAPER_THUMB_PATHS,} from "@/lib/wallpaper";import { isNativeCompositorActive, setNativeParam } from "@/native";+import { wallpaperAcceptsMotion } from "@/native/sceneDescription";import {ASPECT_RATIO_PRESETS,type AspectRatio,@@ -323,6 +325,13 @@ function useWallpaperFileInput(onPicked: (dataUrl: string) => void): {};}+const WALLPAPER_MOTION_LABEL_KEYS: Record<WallpaperMotion, string> = {+ none: "background.motionNone",+ drift: "background.motionDrift",+ aurora: "background.motionAurora",+ waves: "background.motionWaves",+};+// Wallpaper picker — image / solid color / gradient tabs.//// Wallpapers round-trip through the legacyEditor envelope exactly as they did@@ -336,6 +345,7 @@ function BackgroundSection() {const { pick: handlePickFile, input: fileInput } = useWallpaperFileInput((dataUrl) =>set({ wallpaper: dataUrl }),);+ const motionApplies = wallpaperAcceptsMotion(settings.wallpaper);return (<>@@ -390,6 +400,38 @@ function BackgroundSection() {which closes the popover and would unmount the input mid-pick, dropping thefile. It has no layout to cost us here. */}{fileInput}+ {/* Beside the picker because it moves what the picker chose. Only the compositor's own+ gradient can move; on anything else the control says so instead of holding a+ choice that changes nothing on screen. The stored choice is kept and comes back+ with the next gradient. */}+ <div className={styles.field}>+ <label htmlFor="background-motion">{ts("background.motion")}</label>+ <select+ id="background-motion"+ value={motionApplies ? settings.wallpaperMotion : "none"}+ disabled={!hasDocument || !motionApplies}+ title={motionApplies ? undefined : ts("background.motionGradientOnly")}+ onChange={(e) => void set({ wallpaperMotion: e.target.value as WallpaperMotion })}+ >+ {WALLPAPER_MOTIONS.map((motion) => (+ <option key={motion} value={motion}>+ {ts(WALLPAPER_MOTION_LABEL_KEYS[motion])}+ </option>+ ))}+ </select>+ </div>+ {motionApplies ? null : (+ <p+ style={{+ margin: 0,+ padding: "0 var(--sp-4) 8px",+ font: "400 var(--fs-app-sm) var(--font-body)",+ color: "var(--muted)",+ }}+ >+ {ts("background.motionGradientOnly")}+ </p>+ )}{/* Reads in the order it acts: pick a background, then blur it. Lived under"Effects" while that was a separate facet, which is how a control named"Blur BG" ended up in the tab that doesn't say background. */}diff --git a/src/components/video-editor/projectPersistence.test.ts b/src/components/video-editor/projectPersistence.test.tsindex 9c610eda3..a19b92568 100644--- a/src/components/video-editor/projectPersistence.test.ts+++ b/src/components/video-editor/projectPersistence.test.ts@@ -32,6 +32,7 @@ describe("projectPersistence media compatibility", () => {},{wallpaper: "/wallpapers/wallpaper1.jpg",+ wallpaperMotion: "none",shadowIntensity: 0,showBlur: false,motionBlurAmount: 0,@@ -69,6 +70,16 @@ describe("projectPersistence media compatibility", () => {expect(validateProjectData(project)).toBe(true);});+ // The CLI export reads projects through this function: a dropped key is a motion the+ // preview shows and the export does not.+ it("keeps a known wallpaper motion and drops an unknown one", () => {+ expect(normalizeProjectEditor({ wallpaperMotion: "drift" }).wallpaperMotion).toBe("drift");+ expect(normalizeProjectEditor({}).wallpaperMotion).toBe("none");+ expect(normalizeProjectEditor({ wallpaperMotion: "plasma" as never }).wallpaperMotion).toBe(+ "none",+ );+ });+it("normalizes webcam mask shape values safely", () => {expect(normalizeProjectEditor({ webcamMaskShape: "rounded" }).webcamMaskShape).toBe("rounded");expect(diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.tsindex ccbb31567..a2c41398f 100644--- a/src/components/video-editor/projectPersistence.ts+++ b/src/components/video-editor/projectPersistence.ts@@ -32,6 +32,7 @@ import {DEFAULT_WEBCAM_REACTIVE_ZOOM,DEFAULT_ZOOM_DEPTH,DEFAULT_ZOOM_MOTION_BLUR,+ isWallpaperMotion,MAX_BLUR_BLOCK_SIZE,MAX_BLUR_INTENSITY,MAX_PLAYBACK_SPEED,@@ -40,6 +41,7 @@ import {MIN_PLAYBACK_SPEED,type SpeedRegion,type TrimRegion,+ type WallpaperMotion,type WebcamLayoutPreset,type WebcamMaskShape,type WebcamPosition,@@ -68,6 +70,7 @@ export const PROJECT_VERSION = 2;export interface ProjectEditorState {wallpaper: string;+ wallpaperMotion: WallpaperMotion;shadowIntensity: number;showBlur: boolean;motionBlurAmount: number;@@ -476,6 +479,9 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Protypeof editor.wallpaper === "string"? normalizeWallpaperValue(editor.wallpaper): DEFAULT_EDITOR_LAYOUT_SETTINGS.wallpaper,+ // Carried here too: the CLI export reads the project through this function, and a+ // key it drops is a motion the preview shows and the export does not.+ wallpaperMotion: isWallpaperMotion(editor.wallpaperMotion) ? editor.wallpaperMotion : "none",shadowIntensity:typeof editor.shadowIntensity === "number"? editor.shadowIntensitydiff --git a/src/components/video-editor/types.ts b/src/components/video-editor/types.tsindex a9996bf4f..e6bfdd795 100644--- a/src/components/video-editor/types.ts+++ b/src/components/video-editor/types.ts@@ -36,6 +36,16 @@ export function isWebcamBackgroundMode(value: unknown): value is WebcamBackgrounexport const DEFAULT_WEBCAM_BACKGROUND_MODE: WebcamBackgroundMode = "none";+/** Slow motion of a gradient wallpaper, rendered by the native compositor from programme+ * time. Only a `linear-gradient(...)` wallpaper moves; any other keeps its value and ignores it. */+export const WALLPAPER_MOTIONS = ["none", "drift", "aurora", "waves"] as const;++export type WallpaperMotion = (typeof WALLPAPER_MOTIONS)[number];++export function isWallpaperMotion(value: unknown): value is WallpaperMotion {+ return (WALLPAPER_MOTIONS as readonly unknown[]).includes(value);+}+export const DEFAULT_WEBCAM_BLUR_INTENSITY = 0.5;/** When true, the picture-in-picture webcam scales inversely with zoom (shrinks as you zoom in). */diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.jsonindex fba6d9c8b..f7bf5c1f3 100644--- a/src/i18n/locales/ar/settings.json+++ b/src/i18n/locales/ar/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "التحريك",+ "motionNone": "بلا",+ "motionDrift": "انجراف",+ "motionAurora": "شفق",+ "motionWaves": "أمواج",+ "motionGradientOnly": "ينطبق التحريك على الخلفيات المتدرجة فقط. اختر تدرجًا لتحريكه.","gradientLabel": "تدرج لوني {{index}}","uploadCustom": "رفع صورة مخصصة","unsupportedImage": "صورة غير مدعومة. استخدم ملف JPG أو PNG.",diff --git a/src/i18n/locales/cs/settings.json b/src/i18n/locales/cs/settings.jsonindex a96ebcbb0..b02b6fd20 100644--- a/src/i18n/locales/cs/settings.json+++ b/src/i18n/locales/cs/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animace",+ "motionNone": "Žádný",+ "motionDrift": "Posun",+ "motionAurora": "Polární záře",+ "motionWaves": "Vlny",+ "motionGradientOnly": "Animace platí jen pro přechodová pozadí. Vyberte přechod, který chcete animovat.","gradientLabel": "Přechod {{index}}","uploadCustom": "Nahrát vlastní","unsupportedImage": "Nepodporovaný obrázek. Použijte soubor JPG nebo PNG.",diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.jsonindex 8a120b5c1..c1198cfd6 100644--- a/src/i18n/locales/en/settings.json+++ b/src/i18n/locales/en/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animation",+ "motionNone": "None",+ "motionDrift": "Drift",+ "motionAurora": "Aurora",+ "motionWaves": "Waves",+ "motionGradientOnly": "Animation applies to gradient backgrounds only. Pick a gradient to animate it.","gradientLabel": "Gradient {{index}}","uploadCustom": "Upload Custom","unsupportedImage": "Unsupported image. Use a JPG or PNG file.",diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex e404b5cf3..cfeafe913 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animación",+ "motionNone": "Ninguno",+ "motionDrift": "Deriva",+ "motionAurora": "Aurora",+ "motionWaves": "Ondas",+ "motionGradientOnly": "La animación solo se aplica a fondos degradados. Elige un degradado para animarlo.","gradientLabel": "Degradado {{index}}","uploadCustom": "Subir personalizado","unsupportedImage": "Imagen no compatible. Usa un archivo JPG o PNG.",diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.jsonindex 3001a70b4..226f3b809 100644--- a/src/i18n/locales/fr/settings.json+++ b/src/i18n/locales/fr/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animation",+ "motionNone": "Aucun",+ "motionDrift": "Dérive",+ "motionAurora": "Aurore",+ "motionWaves": "Vagues",+ "motionGradientOnly": "L'animation ne s'applique qu'aux fonds dégradés. Choisissez un dégradé pour l'animer.","gradientLabel": "Dégradé {{index}}","uploadCustom": "Téléverser une image","unsupportedImage": "Image non prise en charge. Utilisez un fichier JPG ou PNG.",diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.jsonindex 989725604..9fd8454d7 100644--- a/src/i18n/locales/it/settings.json+++ b/src/i18n/locales/it/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animazione",+ "motionNone": "Nessuno",+ "motionDrift": "Deriva",+ "motionAurora": "Aurora",+ "motionWaves": "Onde",+ "motionGradientOnly": "L'animazione si applica solo agli sfondi sfumati. Scegli una sfumatura per animarla.","gradientLabel": "Sfumatura {{index}}","uploadCustom": "Carica personalizzato","unsupportedImage": "Immagine non supportata. Usa un file JPG o PNG.",diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.jsonindex 7c3058a34..fd0770886 100644--- a/src/i18n/locales/ja-JP/settings.json+++ b/src/i18n/locales/ja-JP/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "アニメーション",+ "motionNone": "なし",+ "motionDrift": "ドリフト",+ "motionAurora": "オーロラ",+ "motionWaves": "ウェーブ",+ "motionGradientOnly": "アニメーションはグラデーション背景にのみ適用されます。アニメーションするにはグラデーションを選択してください。","gradientLabel": "グラデーション {{index}}","uploadCustom": "カスタム画像を読み込む","unsupportedImage": "対応していない画像です。JPG または PNG ファイルを使用してください。",diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.jsonindex 6a1cc8e6a..7521c1768 100644--- a/src/i18n/locales/ko-KR/settings.json+++ b/src/i18n/locales/ko-KR/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "애니메이션",+ "motionNone": "없음",+ "motionDrift": "드리프트",+ "motionAurora": "오로라",+ "motionWaves": "물결",+ "motionGradientOnly": "애니메이션은 그라데이션 배경에만 적용됩니다. 애니메이션을 적용하려면 그라데이션을 선택하세요.","gradientLabel": "그라디언트 {{index}}","uploadCustom": "직접 업로드","unsupportedImage": "지원하지 않는 이미지입니다. JPG 또는 PNG 파일을 사용하세요.",diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.jsonindex e1e6faca9..ce83a1aa5 100644--- a/src/i18n/locales/pt-BR/settings.json+++ b/src/i18n/locales/pt-BR/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animação",+ "motionNone": "Nenhum",+ "motionDrift": "Deriva",+ "motionAurora": "Aurora",+ "motionWaves": "Ondas",+ "motionGradientOnly": "A animação só se aplica a fundos em degradê. Escolha um degradê para animá-lo.","gradientLabel": "Gradiente {{index}}","uploadCustom": "Enviar Personalizada","unsupportedImage": "Imagem não suportada. Use um arquivo JPG ou PNG.",diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.jsonindex 895d97520..adfc828a0 100644--- a/src/i18n/locales/ru/settings.json+++ b/src/i18n/locales/ru/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Анимация",+ "motionNone": "Нет",+ "motionDrift": "Дрейф",+ "motionAurora": "Сияние",+ "motionWaves": "Волны",+ "motionGradientOnly": "Анимация применяется только к градиентным фонам. Выберите градиент, чтобы анимировать его.","gradientLabel": "Градиент {{index}}","uploadCustom": "Загрузить свой","unsupportedImage": "Неподдерживаемое изображение. Используйте файл JPG или PNG.",diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex 3a3f35e50..b2602f925 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Animasyon",+ "motionNone": "Yok",+ "motionDrift": "Kayma",+ "motionAurora": "Kutup ışığı",+ "motionWaves": "Dalgalar",+ "motionGradientOnly": "Animasyon yalnızca gradyan arka planlara uygulanır. Canlandırmak için bir gradyan seçin.","gradientLabel": "Gradyan {{index}}","uploadCustom": "Özel Yükle","unsupportedImage": "Desteklenmeyen görsel. JPG veya PNG dosyası kullanın.",diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.jsonindex af4ddc1ec..3eb117354 100644--- a/src/i18n/locales/vi/settings.json+++ b/src/i18n/locales/vi/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "Hoạt ảnh",+ "motionNone": "Không",+ "motionDrift": "Trôi",+ "motionAurora": "Cực quang",+ "motionWaves": "Sóng",+ "motionGradientOnly": "Hoạt ảnh chỉ áp dụng cho nền chuyển sắc. Hãy chọn một nền chuyển sắc để tạo hoạt ảnh.","gradientLabel": "Dải màu {{index}}","uploadCustom": "Tải lên tùy chỉnh","unsupportedImage": "Ảnh không được hỗ trợ. Hãy dùng tệp JPG hoặc PNG.",diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex f081f7b73..52d4ee9a6 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "动画",+ "motionNone": "无",+ "motionDrift": "漂移",+ "motionAurora": "极光",+ "motionWaves": "波浪",+ "motionGradientOnly": "动画仅适用于渐变背景。请选择一个渐变来启用动画。","gradientLabel": "渐变 {{index}}","uploadCustom": "上传自定义","unsupportedImage": "不支持的图片格式。请使用 JPG 或 PNG 文件。",diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.jsonindex 423835ac8..4c0276e2e 100644--- a/src/i18n/locales/zh-TW/settings.json+++ b/src/i18n/locales/zh-TW/settings.json@@ -1,5 +1,11 @@{"background": {+ "motion": "動畫",+ "motionNone": "無",+ "motionDrift": "漂移",+ "motionAurora": "極光",+ "motionWaves": "波浪",+ "motionGradientOnly": "動畫僅適用於漸層背景。請選擇一個漸層來啟用動畫。","gradientLabel": "漸層 {{index}}","uploadCustom": "上傳自訂","unsupportedImage": "不支援的圖片格式。請使用 JPG 或 PNG 檔案。",diff --git a/src/lib/ai-edition/document/migrate.test.ts b/src/lib/ai-edition/document/migrate.test.tsindex efbc01379..2ff944006 100644--- a/src/lib/ai-edition/document/migrate.test.ts+++ b/src/lib/ai-edition/document/migrate.test.ts@@ -14,6 +14,7 @@ function makeV2Project(overrides: Partial<EditorProjectData> = {}): EditorProjecmedia: { screenVideoPath: "/recordings/screen.webm" },editor: {wallpaper: "/wallpapers/wallpaper1.jpg",+ wallpaperMotion: "none",shadowIntensity: 0,showBlur: false,motionBlurAmount: 0,@@ -262,6 +263,21 @@ describe("migrateAxcutDocumentToProjectData", () => {expect(back.editor.webcamMaskShape).toBe("circle");});+ it("defaults wallpaperMotion to none when legacyEditor lacks it", () => {+ const doc = migrateProjectDataToAxcutDocument(makeV2Project());+ const { wallpaperMotion: _omitted, ...legacy } = doc.legacyEditor as Record<string, unknown>;+ const back = migrateAxcutDocumentToProjectData({ ...doc, legacyEditor: legacy });+ expect(back.editor.wallpaperMotion).toBe("none");+ });++ it("keeps a legacy wallpaperMotion over the default", () => {+ const v2 = makeV2Project({+ editor: { ...makeV2Project().editor, wallpaperMotion: "aurora" },+ });+ const back = migrateAxcutDocumentToProjectData(migrateProjectDataToAxcutDocument(v2));+ expect(back.editor.wallpaperMotion).toBe("aurora");+ });+it("round-trips zoomRegions and annotationRegions back to ms", () => {const v2 = makeV2Project({editor: {diff --git a/src/lib/ai-edition/document/migrate.ts b/src/lib/ai-edition/document/migrate.tsindex ba6d7fda5..c3a2b74bc 100644--- a/src/lib/ai-edition/document/migrate.ts+++ b/src/lib/ai-edition/document/migrate.ts@@ -287,6 +287,7 @@ export function migrateAxcutDocumentToProjectData(input: AxcutDocument): EditorPconst editor: ProjectEditorState = {wallpaper: "",+ wallpaperMotion: "none",shadowIntensity: 0,showBlur: false,motionBlurAmount: 0,diff --git a/src/lib/ai-edition/store/editorSettings.test.ts b/src/lib/ai-edition/store/editorSettings.test.tsindex 759266a2b..23f82ee1c 100644--- a/src/lib/ai-edition/store/editorSettings.test.ts+++ b/src/lib/ai-edition/store/editorSettings.test.ts@@ -283,6 +283,14 @@ describe("patchEditorSettings", () => {expect(getEditorSettings(doc).webcamBackgroundMode).toBe("none");});+ it("round-trips the wallpaper motion and rejects an unknown one", () => {+ expect(getEditorSettings(baseDoc).wallpaperMotion).toBe("none");+ const patched = patchEditorSettings(baseDoc, { wallpaperMotion: "aurora" });+ expect(getEditorSettings(patched).wallpaperMotion).toBe("aurora");+ const doc = { ...baseDoc, legacyEditor: { wallpaperMotion: "plasma" } } as typeof baseDoc;+ expect(getEditorSettings(doc).wallpaperMotion).toBe("none");+ });+it("clamps a stored webcam blur intensity into 0..1", () => {const tooHigh = { ...baseDoc, legacyEditor: { webcamBlurIntensity: 1000 } } as typeof baseDoc;expect(getEditorSettings(tooHigh).webcamBlurIntensity).toBe(1);diff --git a/src/lib/ai-edition/store/editorSettings.ts b/src/lib/ai-edition/store/editorSettings.tsindex 46271dbe5..7b297b311 100644--- a/src/lib/ai-edition/store/editorSettings.ts+++ b/src/lib/ai-edition/store/editorSettings.ts@@ -13,7 +13,9 @@ import {type CursorVisualSettings,DEFAULT_CROP_REGION,DEFAULT_WEBCAM_POSITION,+ isWallpaperMotion,isWebcamBackgroundMode,+ type WallpaperMotion,type WebcamBackgroundMode,type WebcamLayoutPreset,type WebcamMaskShape,@@ -72,6 +74,8 @@ const DEFAULT_CROP_PAN: CropPan = { x: 0.5, y: 0.5 };export interface EditorSettingsSnapshot {wallpaper: string;+ /** Only a gradient wallpaper moves; kept as chosen when the wallpaper changes kind. */+ wallpaperMotion: WallpaperMotion;aspectRatio: AspectRatio;shadowIntensity: number;showBlur: boolean;@@ -115,6 +119,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettingsSnapshot = {interface LegacyShape {wallpaper?: string;+ wallpaperMotion?: WallpaperMotion;aspectRatio?: AspectRatio;shadowIntensity?: number;showBlur?: boolean;@@ -191,6 +196,9 @@ export function getEditorSettings(doc: AxcutDocument | null | undefined): Editorreturn {wallpaper: str(legacy?.wallpaper, DEFAULT_EDITOR_SETTINGS.wallpaper),+ wallpaperMotion: isWallpaperMotion(legacy?.wallpaperMotion)+ ? legacy.wallpaperMotion+ : DEFAULT_EDITOR_SETTINGS.wallpaperMotion,aspectRatio: legacy?.aspectRatio ?? DEFAULT_EDITOR_SETTINGS.aspectRatio,shadowIntensity: num(legacy?.shadowIntensity, DEFAULT_EDITOR_SETTINGS.shadowIntensity),showBlur: bool(legacy?.showBlur, DEFAULT_EDITOR_SETTINGS.showBlur),@@ -234,6 +242,7 @@ export function getEditorSettings(doc: AxcutDocument | null | undefined): Editor}export interface EditorSettingsPatch {wallpaper?: string;+ wallpaperMotion?: WallpaperMotion;aspectRatio?: AspectRatio;shadowIntensity?: number;showBlur?: boolean;diff --git a/src/lib/ai-edition/stylePresets.test.ts b/src/lib/ai-edition/stylePresets.test.tsindex 5e3f31964..a2132f547 100644--- a/src/lib/ai-edition/stylePresets.test.ts+++ b/src/lib/ai-edition/stylePresets.test.ts@@ -15,6 +15,7 @@ import {function appearance(overrides: Partial<StylePresetAppearance> = {}): StylePresetAppearance {return {wallpaper: "/wallpapers/wallpaper3.jpg",+ wallpaperMotion: "drift",aspectRatio: "16:9",shadowIntensity: 0.2,showBlur: false,@@ -56,6 +57,15 @@ describe("parseStylePresetAppearance", () => {expect(() => parseStylePresetAppearance(rest)).toThrow(/padding/);});+ // Added after format version 1 shipped: an older preset has a still wallpaper.+ it("reads a preset without a wallpaper motion as still, and refuses an unknown one", () => {+ const { wallpaperMotion: _motion, ...older } = appearance();+ expect(parseStylePresetAppearance(older).wallpaperMotion).toBe("none");+ expect(() =>+ parseStylePresetAppearance({ ...appearance(), wallpaperMotion: "plasma" }),+ ).toThrow(/wallpaperMotion/);+ });+it("rejects out-of-range numbers, wrong types and unknown enum values", () => {expect(() => parseStylePresetAppearance(appearance({ padding: 101 }))).toThrow(TypeError);expect(() => parseStylePresetAppearance(appearance({ borderRadius: -1 }))).toThrow(diff --git a/src/lib/ai-edition/stylePresets.ts b/src/lib/ai-edition/stylePresets.tsindex 5253a84e1..f4910b1b5 100644--- a/src/lib/ai-edition/stylePresets.ts+++ b/src/lib/ai-edition/stylePresets.ts@@ -12,6 +12,7 @@import type {CursorVisualSettings,+ WallpaperMotion,WebcamBackgroundMode,WebcamLayoutPreset,WebcamMaskShape,@@ -34,6 +35,7 @@ const CSS_WALLPAPER_MAX_LENGTH = 10_000;/** The appearance fields of `EditorSettingsSnapshot`, in the snapshot's own shape. */export interface StylePresetAppearance {wallpaper: string;+ wallpaperMotion: WallpaperMotion;aspectRatio: AspectRatio;shadowIntensity: number;showBlur: boolean;@@ -92,6 +94,12 @@ const WEBCAM_BACKGROUND_MODES = ["blur","custom",] as const satisfies readonly WebcamBackgroundMode[];+const WALLPAPER_MOTIONS = [+ "none",+ "drift",+ "aurora",+ "waves",+] as const satisfies readonly WallpaperMotion[];// Bounds are the editor sliders' (RightPanes.tsx), in stored units. `getEditorSettings`// only clamps two of these, so a preset is the stricter gate: a value no slider can@@ -205,8 +213,9 @@ export function parseStylePresetWallpaper(value: unknown, key = "wallpaper"): st* lenient field is `cursorTheme`: themes come and go between builds, so an id this build* does not ship falls back to the default cursor instead of rejecting a preset that is* otherwise sound (the editor does the same when it renders one). `cursor.volume` may be- * absent: it postdates format version 1, and a preset without it was authored flat. Unknown- * extra keys are dropped.+ * absent: it postdates format version 1, and a preset without it was authored flat.+ * `wallpaperMotion` may be absent too: a preset saved before it has a still wallpaper, which+ * is exactly what "none" means. Unknown extra keys are dropped.*/export function parseStylePresetAppearance(value: unknown): StylePresetAppearance {if (!isRecord(value)) {@@ -224,6 +233,10 @@ export function parseStylePresetAppearance(value: unknown): StylePresetAppearanc}return {wallpaper: parseStylePresetWallpaper(value.wallpaper),+ wallpaperMotion:+ value.wallpaperMotion === undefined+ ? "none"+ : readEnum(value, "wallpaperMotion", WALLPAPER_MOTIONS),aspectRatio: value.aspectRatio,shadowIntensity: readNumber(value, "shadowIntensity", NUMBER_RANGES.shadowIntensity),showBlur: readBoolean(value, "showBlur"),diff --git a/src/lib/ai-edition/stylePresetsEditor.test.ts b/src/lib/ai-edition/stylePresetsEditor.test.tsindex 6b3a96273..bc588ab65 100644--- a/src/lib/ai-edition/stylePresetsEditor.test.ts+++ b/src/lib/ai-edition/stylePresetsEditor.test.ts@@ -26,6 +26,7 @@ function styledSettings(): EditorSettingsSnapshot {return {...DEFAULT_EDITOR_SETTINGS,wallpaper: "linear-gradient(90deg, #000, #fff)",+ wallpaperMotion: "waves",aspectRatio: "9:16",shadowIntensity: 0.8,showBlur: true,diff --git a/src/lib/ai-edition/stylePresetsEditor.ts b/src/lib/ai-edition/stylePresetsEditor.tsindex e3dc79d58..b24dcb7a7 100644--- a/src/lib/ai-edition/stylePresetsEditor.ts+++ b/src/lib/ai-edition/stylePresetsEditor.ts@@ -15,6 +15,7 @@ export function stylePresetAppearanceFromSettings(): StylePresetAppearance {return {wallpaper: settings.wallpaper,+ wallpaperMotion: settings.wallpaperMotion,aspectRatio: settings.aspectRatio,shadowIntensity: settings.shadowIntensity,showBlur: settings.showBlur,@@ -58,6 +59,7 @@ export function factoryStylePresetAppearance(): StylePresetAppearance {export function stylePresetPatch(appearance: StylePresetAppearance): EditorSettingsPatch {return {wallpaper: appearance.wallpaper,+ wallpaperMotion: appearance.wallpaperMotion,aspectRatio: appearance.aspectRatio,shadowIntensity: appearance.shadowIntensity,showBlur: appearance.showBlur,diff --git a/src/lib/projectDefaults.ts b/src/lib/projectDefaults.tsindex b78b67dad..c508e76e1 100644--- a/src/lib/projectDefaults.ts+++ b/src/lib/projectDefaults.ts@@ -1,5 +1,6 @@export interface ProjectAppearanceDefaults {wallpaper: string;+ wallpaperMotion: "none" | "drift" | "aurora" | "waves";aspectRatio: `${number}:${number}` | "native";shadowIntensity: number;showBlur: boolean;@@ -33,6 +34,7 @@ export interface ProjectAppearanceDefaults {/** The factory appearance every new project starts from. */export const DEFAULT_PROJECT_APPEARANCE: ProjectAppearanceDefaults = {wallpaper: "/wallpapers/wallpaper1.jpg",+ wallpaperMotion: "none",aspectRatio: "16:9",shadowIntensity: 0.2,showBlur: false,diff --git a/src/native/browserShim.presets.test.ts b/src/native/browserShim.presets.test.tsindex 5678db9ff..285b0ce7f 100644--- a/src/native/browserShim.presets.test.ts+++ b/src/native/browserShim.presets.test.ts@@ -11,6 +11,7 @@ import {const APPEARANCE: StylePresetAppearance = {wallpaper: "#000000",+ wallpaperMotion: "none",aspectRatio: "16:9",shadowIntensity: 0.2,showBlur: false,diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex 6f807b4e6..f9418be5b 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -19,7 +19,7 @@ import type {} from "@/lib/ai-edition/schema";import { axcutSchemaVersion } from "@/lib/ai-edition/schema";import { getFocusBoundsForScale } from "@/lib/zoomMath/focusUtils";-import { buildSceneDescription } from "./sceneDescription";+import { buildSceneDescription, wallpaperAcceptsMotion } from "./sceneDescription";// --- Fixture helpers --------------------------------------------------------// Keep fixtures minimal & deterministic — every field the serializer consults is filled in;@@ -178,6 +178,52 @@ describe("buildSceneDescription.background", () => {});});+describe("buildSceneDescription.background motion", () => {+ const gradient = "linear-gradient(135deg, #eaebed, #bcc0c6)";++ it("attaches the chosen motion to a gradient", () => {+ const doc = makeDoc({ legacyEditor: { wallpaper: gradient, wallpaperMotion: "aurora" } });+ expect(buildSceneDescription(doc).background).toEqual({+ kind: "gradient",+ angleDeg: 135,+ stops: ["#eaebed", "#bcc0c6"],+ motion: "aurora",+ });+ });++ // The Rust side defaults the key: a still gradient sends the payload it sent before.+ it("omits the key when the gradient is still", () => {+ for (const wallpaperMotion of ["none", undefined, "plasma"]) {+ const doc = makeDoc({ legacyEditor: { wallpaper: gradient, wallpaperMotion } });+ expect(buildSceneDescription(doc).background).not.toHaveProperty("motion");+ }+ });++ it("never moves a colour, an image or the webcam's own gradient", () => {+ const doc = makeDoc({+ legacyEditor: {+ wallpaper: "/wallpapers/wallpaper1.jpg",+ wallpaperMotion: "waves",+ webcamBackgroundMode: "custom",+ webcamWallpaper: gradient,+ },+ });+ const scene = buildSceneDescription(doc);+ expect(scene.background).toEqual({ kind: "image", path: "/wallpapers/wallpaper1.jpg" });+ expect(scene.webcamEffect?.background).not.toHaveProperty("motion");+ const colour = makeDoc({ legacyEditor: { wallpaper: "#123456", wallpaperMotion: "drift" } });+ expect(buildSceneDescription(colour).background).toEqual({ kind: "color", color: "#123456" });+ });++ it("enables the control exactly for the wallpapers the compositor animates", () => {+ expect(wallpaperAcceptsMotion(gradient)).toBe(true);+ expect(wallpaperAcceptsMotion("#123456")).toBe(false);+ expect(wallpaperAcceptsMotion("/wallpapers/wallpaper1.jpg")).toBe(false);+ // Drawn by the web preview only; the compositor paints it as an image path.+ expect(wallpaperAcceptsMotion("radial-gradient(#fff, #000)")).toBe(false);+ });+});+describe("buildSceneDescription.webcamEffect", () => {// Omitted rather than sent as {mode:"none"}: the Rust side defaults the field, so every// project without an effect would otherwise carry it for nothing.diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.tsindex 13d05d3ae..0de4d36c8 100644--- a/src/native/sceneDescription.ts+++ b/src/native/sceneDescription.ts@@ -18,6 +18,7 @@import type {CameraFullscreenRegion,SpeedRegion,+ WallpaperMotion,WebcamBackgroundMode,} from "@/components/video-editor/types";import { DEFAULT_CROP_REGION, getZoomScale } from "@/components/video-editor/types";@@ -57,7 +58,14 @@ import type { CompositorClipInput } from "./contracts";/** Background behind the screen. Parsed from `settings.wallpaper`. */export type SceneBackground =| { kind: "color"; color: string } // "#rrggbb"- | { kind: "gradient"; angleDeg: number; stops: string[] } // linear-gradient(deg, c1, c2, …)+ // linear-gradient(deg, c1, c2, …). `motion` is omitted when still, so a project without+ // animation sends the same payload as before the setting existed.+ | {+ kind: "gradient";+ angleDeg: number;+ stops: string[];+ motion?: Exclude<WallpaperMotion, "none">;+ }| { kind: "image"; path: string }; // "/wallpapers/…" or a data: URL/** A timeline zoom region (from `document.zoomRanges`). Times in seconds. */@@ -509,6 +517,23 @@ function parseWallpaper(wallpaper: string) {return { kind: "image", path: wallpaper } as const;}+/**+ * True when `settings.wallpaperMotion` has something to move: the compositor animates only+ * the gradient it draws itself. The motion control asks this, not its own guess at what a+ * gradient is, so it is enabled exactly when the export would show the motion.+ */+export function wallpaperAcceptsMotion(wallpaper: string): boolean {+ return parseWallpaper(wallpaper).kind === "gradient";+}++/** The screen background with the chosen motion attached, when there is one to attach. */+function sceneBackground(wallpaper: string, motion: WallpaperMotion): SceneBackground {+ const background = parseWallpaper(wallpaper);+ return background.kind === "gradient" && motion !== "none"+ ? { ...background, motion }+ : background;+}+/*** The ONE clip list every native-facing consumer must build from — trim-narrowed* (`resolvePlaybackSegments`, so word-level cuts from the transcript editor actually reach@@ -1046,7 +1071,7 @@ export function buildSceneDescription(gainDb: settings.audioGainDb,},audioTracks,- background: parseWallpaper(settings.wallpaper),+ background: sceneBackground(settings.wallpaper, settings.wallpaperMotion),zoomRegions: projectedZoomRegions.map((region) => ({id: region.id,startSec: region.startMs / 1000,diff --git a/technical-documentation/engineering/rendering-performance.md b/technical-documentation/engineering/rendering-performance.mdindex ea5b63cf1..9238c3ba5 100644--- a/technical-documentation/engineering/rendering-performance.md+++ b/technical-documentation/engineering/rendering-performance.md@@ -172,6 +172,46 @@ The encoder is not the bottleneck either way — the two CPU rows differ by 5 %,gap to hardware is 18×. That gap is the blur and motion-blur shaders (see the table above),not the codec.+### Animated background (C9) — 2026-09-16++The animated gradient (`background.motion`, shader mode 5) is not a `Cfg` flag: it only+exists in a scene. So its row is an A/B of two scenes that differ by that one key,+[`scene-gradient-still.json`](../../crates/fixture/scene-gradient-still.json) and+[`scene-gradient-aurora.json`](../../crates/fixture/scene-gradient-aurora.json). Aurora is+the priced motion because it is the most expensive: value noise plus three gaussians on+every output pixel.++```bash+x.bat run --release -- --cfg C3,C8 --preview --frames 300 --repeat 5 --scene fixture/scene-gradient-aurora.json+x.bat run --release -- --cfg C3,C8 --export --scene fixture/scene-gradient-aurora.json+x.bat run --release -- --cfg C3 --backend cpu --preview --frames 300 --repeat 3 --scene fixture/scene-gradient-aurora.json+```++One machine (RTX 4070 Ti, Ryzen 7 5800X, ~55 browser processes live), not the reference+iGPU. The frozen fixture media were absent, so the sources are two 6 s `-c copy` cuts of a+local 1080p60 recording. One warm-up pass discarded, then three rounds with still and+aurora interleaved. Each cell is the best of the three rounds, and each round is itself+best-of-5 (preview), best-of-3 (WARP) or a single run (export).++| path | cfg | still ms/f | aurora ms/f | Δ ms/f | spread (per round) |+|---|---|---:|---:|---:|---|+| HW preview | C3 | 4.20 | 4.20 | 0.00 | 59–70 % |+| HW preview | C8 | 6.76 | 6.77 | +0.01 | 5.8–9.0 % |+| HW export | C3 | 2.22 | 2.24 | +0.02 | 2.22–2.36 over rounds |+| HW export | C8 | 2.17 | 2.19 | +0.02 | 2.17–2.26 over rounds |+| WARP preview | C3 | 12.54 | 19.69 | **+7.15** | 5.9/6.3 % still, 3.2/2.2 % aurora |++**Free on a GPU, +57 % on WARP.** On the hardware backend the delta is below the noise in+every path. On WARP the shader costs ~7 ms per 1080p frame, the same shape as the blur+cliffs above: fine for a real GPU, heavy for a per-pixel loop on the CPU rasteriser.++> **HW preview C3 is not admissible** under [§ spread thresholds](#spread-thresholds): its+> first repeat is a cold outlier in every round, so only its best-of is readable. One WARP+> round per arm blew the gate too (still 42.8 %, aurora 24.1 %) and is left out of the+> table. The export rows are single runs per round. The export does animate: a 60 px strip+> of the aurora export moves by up to 22/255 between frames 0 and 300, against 4/255 for the+> still one.+## The macOS export path — 2026-09-03/04Everything above is the Windows reference machine. This section is a **different machine and a different pipeline**: a Mac mini M1 (8 cores, 8 GiB, macOS 26.5), Metal compositor, VideoToolbox on both ends. Nothing here transfers to the Windows numbers, and the reverse held too — of the three levers that mattered on Windows and Linux, **none applied here**.