// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osuTK; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; namespace osu.Framework.Graphics.Animations { /// /// An animation that switches the displayed texture when a new frame is displayed. /// public class TextureAnimation : Animation { private Sprite textureHolder; public TextureAnimation(bool startAtCurrentTime = true) : base(startAtCurrentTime) { } public override Drawable CreateContent() => textureHolder = new Sprite { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, }; protected override void DisplayFrame(Texture content) => textureHolder.Texture = content; protected override float GetFillAspectRatio() => textureHolder.FillAspectRatio; protected override Vector2 GetCurrentDisplaySize() => new Vector2(textureHolder.Texture?.DisplayWidth ?? 0, textureHolder.Texture?.DisplayHeight ?? 0); } }