diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs
index db055d15e5..8fdb8ebcdd 100644
--- a/osu.Game/Graphics/Backgrounds/Background.cs
+++ b/osu.Game/Graphics/Backgrounds/Background.cs
@@ -6,23 +6,28 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
+using osu.Framework.Graphics.Transforms;
+using osuTK;
namespace osu.Game.Graphics.Backgrounds
{
- public class Background : BufferedContainer
+ ///
+ /// A background which offer blurring on demand.
+ ///
+ public class Background : CompositeDrawable
{
public Sprite Sprite;
private readonly string textureName;
+ private BufferedContainer bufferedContainer;
+
public Background(string textureName = @"")
{
- CacheDrawnFrameBuffer = true;
-
this.textureName = textureName;
RelativeSizeAxes = Axes.Both;
- Add(Sprite = new Sprite
+ AddInternal(Sprite = new Sprite
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
@@ -37,5 +42,28 @@ namespace osu.Game.Graphics.Backgrounds
if (!string.IsNullOrEmpty(textureName))
Sprite.Texture = textures.Get(textureName);
}
+
+ public Vector2 BlurSigma => bufferedContainer?.BlurSigma ?? Vector2.Zero;
+
+ ///
+ /// Smoothly adjusts over time.
+ ///
+ /// A to which further transforms can be added.
+ public void BlurTo(Vector2 newBlurSigma, double duration = 0, Easing easing = Easing.None)
+ {
+ if (bufferedContainer == null)
+ {
+ RemoveInternal(Sprite);
+
+ AddInternal(bufferedContainer = new BufferedContainer
+ {
+ CacheDrawnFrameBuffer = true,
+ RelativeSizeAxes = Axes.Both,
+ Child = Sprite
+ });
+ }
+
+ bufferedContainer.BlurTo(newBlurSigma, duration, easing);
+ }
}
}